anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 6 | % OOO PPPP EEEE RRRR AA TTTTT III OOO N N % |
| 7 | % O O P P E R R A A T I O O NN N % |
| 8 | % O O PPPP EEE RRRR AAAA T I O O N N N % |
| 9 | % O O P E R R A A T I O O N NN % |
| 10 | % OOO P EEEE R RR A A T III OOO N N % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 11 | % % |
| 12 | % % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 13 | % CLI Magick Option Methods % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 14 | % % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 15 | % Dragon Computing % |
cristy | 9e58efd | 2012-01-30 14:27:34 +0000 | [diff] [blame] | 16 | % Anthony Thyssen % |
cristy | 0a0ca4f | 2011-09-28 01:15:28 +0000 | [diff] [blame] | 17 | % September 2011 % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 18 | % % |
| 19 | % % |
cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +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 | % Apply the given options (settings, and simple, or sequence operations) to |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 37 | % the given image(s) according to the current "image_info", "draw_info", and |
| 38 | % "quantize_info" settings, stored in a special CLI Image Wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 39 | % |
| 40 | % The final goal is to allow the execution in a strict one option at a time |
| 41 | % manner that is needed for 'pipelining and file scripting' of options in |
| 42 | % IMv7. |
| 43 | % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 44 | % Anthony Thyssen, September 2011 |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 45 | */ |
| 46 | |
| 47 | /* |
| 48 | Include declarations. |
| 49 | */ |
| 50 | #include "MagickWand/studio.h" |
| 51 | #include "MagickWand/MagickWand.h" |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 52 | #include "MagickWand/magick-wand-private.h" |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 53 | #include "MagickWand/operation.h" |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 54 | #include "MagickWand/operation-private.h" |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 55 | #include "MagickWand/wand.h" |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 56 | #include "MagickCore/monitor-private.h" |
| 57 | #include "MagickCore/thread-private.h" |
| 58 | #include "MagickCore/string-private.h" |
| 59 | |
| 60 | /* |
| 61 | Define declarations. |
| 62 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 63 | #define USE_WAND_METHODS 0 |
| 64 | #define MAX_STACK_DEPTH 32 |
| 65 | #define UNDEFINED_COMPRESSION_QUALITY 0UL |
| 66 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 67 | /* |
| 68 | Constant declaration. (temporary exports) |
| 69 | */ |
| 70 | static const char |
| 71 | BackgroundColor[] = "#fff", /* white */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 72 | BorderColor[] = "#dfdfdf", /* sRGB gray */ |
| 73 | MatteColor[] = "#bdbdbd"; /* slightly darker gray */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 74 | |
| 75 | /* |
| 76 | ** Function to report on the progress of image operations |
| 77 | */ |
| 78 | static MagickBooleanType MonitorProgress(const char *text, |
| 79 | const MagickOffsetType offset,const MagickSizeType extent, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 80 | void *wand_unused(cli_wandent_data)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 81 | { |
| 82 | char |
| 83 | message[MaxTextExtent], |
| 84 | tag[MaxTextExtent]; |
| 85 | |
| 86 | const char |
| 87 | *locale_message; |
| 88 | |
| 89 | register char |
| 90 | *p; |
| 91 | |
| 92 | if (extent < 2) |
| 93 | return(MagickTrue); |
| 94 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 95 | p=strrchr(tag,'/'); |
| 96 | if (p != (char *) NULL) |
| 97 | *p='\0'; |
| 98 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
| 99 | locale_message=GetLocaleMessage(message); |
| 100 | if (locale_message == message) |
| 101 | locale_message=tag; |
| 102 | if (p == (char *) NULL) |
| 103 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 104 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 105 | (100L*offset/(extent-1))); |
| 106 | else |
| 107 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
| 108 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 109 | (100L*offset/(extent-1))); |
| 110 | if (offset == (MagickOffsetType) (extent-1)) |
| 111 | (void) FormatLocaleFile(stderr,"\n"); |
| 112 | (void) fflush(stderr); |
| 113 | return(MagickTrue); |
| 114 | } |
| 115 | |
| 116 | /* |
| 117 | ** GetImageCache() will read an image into a image cache if not already |
| 118 | ** present then return the image that is in the cache under that filename. |
| 119 | */ |
| 120 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 121 | ExceptionInfo *exception) |
| 122 | { |
| 123 | char |
| 124 | key[MaxTextExtent]; |
| 125 | |
| 126 | ExceptionInfo |
| 127 | *sans_exception; |
| 128 | |
| 129 | Image |
| 130 | *image; |
| 131 | |
| 132 | ImageInfo |
| 133 | *read_info; |
| 134 | |
| 135 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
| 136 | sans_exception=AcquireExceptionInfo(); |
| 137 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 138 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 139 | if (image != (Image *) NULL) |
| 140 | return(image); |
| 141 | read_info=CloneImageInfo(image_info); |
| 142 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 143 | image=ReadImage(read_info,exception); |
| 144 | read_info=DestroyImageInfo(read_info); |
| 145 | if (image != (Image *) NULL) |
| 146 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 147 | return(image); |
| 148 | } |
| 149 | |
| 150 | /* |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 151 | SparseColorOption() parse the complex -sparse-color argument into an |
| 152 | an array of floating point values than call SparseColorImage(). |
| 153 | Argument is a complex mix of floating-point pixel coodinates, and color |
| 154 | specifications (or direct floating point numbers). The number of floats |
| 155 | needed to represent a color varies depending on teh current channel |
| 156 | setting. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 157 | |
| 158 | This really should be in MagickCore, so that other API's can make use of it. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 159 | */ |
| 160 | static Image *SparseColorOption(const Image *image, |
| 161 | const SparseColorMethod method,const char *arguments, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 162 | ExceptionInfo *exception) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 163 | { |
| 164 | char |
| 165 | token[MaxTextExtent]; |
| 166 | |
| 167 | const char |
| 168 | *p; |
| 169 | |
| 170 | double |
| 171 | *sparse_arguments; |
| 172 | |
| 173 | Image |
| 174 | *sparse_image; |
| 175 | |
| 176 | PixelInfo |
| 177 | color; |
| 178 | |
| 179 | MagickBooleanType |
| 180 | error; |
| 181 | |
| 182 | register size_t |
| 183 | x; |
| 184 | |
| 185 | size_t |
| 186 | number_arguments, |
| 187 | number_colors; |
| 188 | |
| 189 | assert(image != (Image *) NULL); |
| 190 | assert(image->signature == MagickSignature); |
| 191 | if (image->debug != MagickFalse) |
| 192 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 193 | assert(exception != (ExceptionInfo *) NULL); |
| 194 | assert(exception->signature == MagickSignature); |
| 195 | /* |
| 196 | Limit channels according to image - and add up number of color channel. |
| 197 | */ |
| 198 | number_colors=0; |
| 199 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 200 | number_colors++; |
| 201 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 202 | number_colors++; |
| 203 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 204 | number_colors++; |
| 205 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 206 | (image->colorspace == CMYKColorspace)) |
| 207 | number_colors++; |
| 208 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
| 209 | (image->matte != MagickFalse)) |
| 210 | number_colors++; |
| 211 | |
| 212 | /* |
| 213 | Read string, to determine number of arguments needed, |
| 214 | */ |
| 215 | p=arguments; |
| 216 | x=0; |
| 217 | while( *p != '\0' ) |
| 218 | { |
| 219 | GetMagickToken(p,&p,token); |
| 220 | if ( token[0] == ',' ) continue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 221 | if ( isalpha((int) token[0]) || token[0] == '#' ) |
| 222 | x += number_colors; /* color argument found */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 223 | else |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 224 | x++; /* floating point argument */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 225 | } |
| 226 | error=MagickTrue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 227 | /* control points and color values */ |
| 228 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 229 | number_arguments=x; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 230 | if ( error ) { |
| 231 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 232 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 233 | "Invalid number of Arguments"); |
| 234 | return( (Image *)NULL); |
| 235 | } |
| 236 | |
| 237 | /* Allocate and fill in the floating point arguments */ |
| 238 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 239 | sizeof(*sparse_arguments)); |
| 240 | if (sparse_arguments == (double *) NULL) { |
| 241 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 242 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 243 | return( (Image *)NULL); |
| 244 | } |
| 245 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 246 | sizeof(*sparse_arguments)); |
| 247 | p=arguments; |
| 248 | x=0; |
| 249 | while( *p != '\0' && x < number_arguments ) { |
| 250 | /* X coordinate */ |
| 251 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 252 | if ( token[0] == '\0' ) break; |
| 253 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 254 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 255 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 256 | "Color found, instead of X-coord"); |
| 257 | error = MagickTrue; |
| 258 | break; |
| 259 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 260 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 261 | /* Y coordinate */ |
| 262 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 263 | if ( token[0] == '\0' ) break; |
| 264 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 265 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 266 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 267 | "Color found, instead of Y-coord"); |
| 268 | error = MagickTrue; |
| 269 | break; |
| 270 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 271 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 272 | /* color name or function given in string argument */ |
| 273 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 274 | if ( token[0] == '\0' ) break; |
| 275 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 276 | /* Color string given */ |
| 277 | (void) QueryColorCompliance(token,AllCompliance,&color, |
| 278 | exception); |
| 279 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 280 | sparse_arguments[x++] = QuantumScale*color.red; |
| 281 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 282 | sparse_arguments[x++] = QuantumScale*color.green; |
| 283 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 284 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 285 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 286 | (image->colorspace == CMYKColorspace)) |
| 287 | sparse_arguments[x++] = QuantumScale*color.black; |
| 288 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
| 289 | (image->matte != MagickFalse)) |
| 290 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 291 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 292 | else { |
| 293 | /* Colors given as a set of floating point values - experimental */ |
| 294 | /* NB: token contains the first floating point value to use! */ |
| 295 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 296 | { |
| 297 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 298 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 299 | break; |
| 300 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 301 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 302 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 303 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 304 | { |
| 305 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 306 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 307 | break; |
| 308 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 309 | token[0] = ','; /* used this token - get another */ |
| 310 | } |
| 311 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 312 | { |
| 313 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 314 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 315 | break; |
| 316 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 317 | token[0] = ','; /* used this token - get another */ |
| 318 | } |
| 319 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 320 | (image->colorspace == CMYKColorspace)) |
| 321 | { |
| 322 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 323 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 324 | break; |
| 325 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 326 | token[0] = ','; /* used this token - get another */ |
| 327 | } |
| 328 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
| 329 | (image->matte != MagickFalse)) |
| 330 | { |
| 331 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 332 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 333 | break; |
| 334 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 335 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 336 | } |
| 337 | } |
| 338 | } |
| 339 | if ( number_arguments != x && !error ) { |
| 340 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 341 | "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 342 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 343 | return( (Image *)NULL); |
| 344 | } |
| 345 | if ( error ) |
| 346 | return( (Image *)NULL); |
| 347 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 348 | /* Call the Sparse Color Interpolation function with the parsed arguments */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 349 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 350 | exception); |
| 351 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 352 | return( sparse_image ); |
| 353 | } |
| 354 | |
| 355 | /* |
| 356 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 357 | % % |
| 358 | % % |
| 359 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 360 | + A c q u i r e W a n d C L I % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 361 | % % |
| 362 | % % |
| 363 | % % |
| 364 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 365 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 366 | % AcquireMagickCLI() creates a new CLI wand (an expanded form of Magick |
| 367 | % Wand). The given image_info and exception is included as is if provided. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 368 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 369 | % Use DestroyMagickCLI() to dispose of the CLI wand when it is no longer |
| 370 | % needed. |
| 371 | % |
| 372 | % The format of the NewMagickWand method is: |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 373 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 374 | % MagickCLI *AcquireMagickCLI(ImageInfo *image_info, |
| 375 | % ExceptionInfo *exception) |
| 376 | % |
| 377 | */ |
| 378 | WandExport MagickCLI *AcquireMagickCLI(ImageInfo *image_info, |
| 379 | ExceptionInfo *exception) |
| 380 | { |
| 381 | MagickCLI |
| 382 | *cli_wand; |
| 383 | |
| 384 | /* precaution - as per NewMagickWand() */ |
| 385 | { |
| 386 | size_t depth = MAGICKCORE_QUANTUM_DEPTH; |
| 387 | const char *quantum = GetMagickQuantumDepth(&depth); |
| 388 | if (depth != MAGICKCORE_QUANTUM_DEPTH) |
| 389 | ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); |
| 390 | } |
| 391 | |
| 392 | /* allocate memory for MgaickCLI */ |
| 393 | cli_wand=(MagickCLI *) AcquireMagickMemory(sizeof(*cli_wand)); |
| 394 | if (cli_wand == (MagickCLI *) NULL) |
| 395 | { |
| 396 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 397 | GetExceptionMessage(errno)); |
| 398 | return((MagickCLI *)NULL); |
| 399 | } |
| 400 | |
| 401 | /* Initialize Wand Part of MagickCLI |
| 402 | FUTURE: this is a repeat of code from NewMagickWand() |
| 403 | However some parts may be given fro man external source! |
| 404 | */ |
| 405 | cli_wand->wand.id=AcquireWandId(); |
| 406 | (void) FormatLocaleString(cli_wand->wand.name,MaxTextExtent, |
| 407 | "%s-%.20g","MagickWandCLI", (double) cli_wand->wand.id); |
| 408 | cli_wand->wand.images=NewImageList(); |
| 409 | if ( image_info == (ImageInfo *)NULL) |
| 410 | cli_wand->wand.image_info=AcquireImageInfo(); |
| 411 | else |
| 412 | cli_wand->wand.image_info=image_info; |
| 413 | if ( exception == (ExceptionInfo *)NULL) |
| 414 | cli_wand->wand.exception=AcquireExceptionInfo(); |
| 415 | else |
| 416 | cli_wand->wand.exception=exception; |
| 417 | cli_wand->wand.debug=IsEventLogging(); |
| 418 | cli_wand->wand.signature=WandSignature; |
| 419 | |
| 420 | /* Initialize CLI Part of MagickCLI */ |
| 421 | cli_wand->draw_info=CloneDrawInfo(cli_wand->wand.image_info,(DrawInfo *) NULL); |
| 422 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 423 | cli_wand->image_list_stack=(Stack *)NULL; |
| 424 | cli_wand->image_info_stack=(Stack *)NULL; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 425 | cli_wand->location="'%s'"; /* option location not known by default */ |
| 426 | cli_wand->location2="'%s' '%s'"; |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 427 | cli_wand->filename=cli_wand->wand.name; |
anthony | 1cdc5b7 | 2012-03-03 02:31:18 +0000 | [diff] [blame] | 428 | cli_wand->line=0; |
| 429 | cli_wand->column=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 430 | cli_wand->signature=WandSignature; |
| 431 | |
| 432 | if (cli_wand->wand.debug != MagickFalse) |
| 433 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 434 | return(cli_wand); |
| 435 | } |
| 436 | |
| 437 | /* |
| 438 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 439 | % % |
| 440 | % % |
| 441 | % % |
| 442 | + D e s t r o y W a n d C L I % |
| 443 | % % |
| 444 | % % |
| 445 | % % |
| 446 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 447 | % |
| 448 | % DestroyMagickCLI() destorys everything in a CLI wand, including image_info |
| 449 | % and any exceptions, if still present in the wand. |
| 450 | % |
| 451 | % The format of the NewMagickWand method is: |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 452 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 453 | % MagickWand *DestroyMagickCLI() |
| 454 | % Exception *exception) |
| 455 | % |
| 456 | */ |
| 457 | WandExport MagickCLI *DestroyMagickCLI(MagickCLI *cli_wand) |
| 458 | { |
| 459 | Stack |
| 460 | *node; |
| 461 | |
| 462 | assert(cli_wand != (MagickCLI *) NULL); |
| 463 | assert(cli_wand->signature == WandSignature); |
| 464 | assert(cli_wand->wand.signature == WandSignature); |
| 465 | if (cli_wand->wand.debug != MagickFalse) |
| 466 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 467 | |
| 468 | /* Destroy CLI part of MagickCLI */ |
| 469 | if (cli_wand->draw_info != (DrawInfo *) NULL ) |
| 470 | cli_wand->draw_info=DestroyDrawInfo(cli_wand->draw_info); |
| 471 | if (cli_wand->quantize_info != (QuantizeInfo *) NULL ) |
| 472 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 473 | while(cli_wand->image_list_stack != (Stack *)NULL) |
| 474 | { |
| 475 | node=cli_wand->image_list_stack; |
| 476 | cli_wand->image_list_stack=node->next; |
| 477 | (void) DestroyImageList((Image *)node->data); |
| 478 | (void) RelinquishMagickMemory(node); |
| 479 | } |
| 480 | while(cli_wand->image_info_stack != (Stack *)NULL) |
| 481 | { |
| 482 | node=cli_wand->image_info_stack; |
| 483 | cli_wand->image_info_stack=node->next; |
| 484 | (void) DestroyImageInfo((ImageInfo *)node->data); |
| 485 | (void) RelinquishMagickMemory(node); |
| 486 | } |
| 487 | cli_wand->signature=(~WandSignature); |
| 488 | |
| 489 | /* Destroy Wand part MagickCLI */ |
| 490 | cli_wand->wand.images=DestroyImageList(cli_wand->wand.images); |
| 491 | if (cli_wand->wand.image_info != (ImageInfo *) NULL ) |
| 492 | cli_wand->wand.image_info=DestroyImageInfo(cli_wand->wand.image_info); |
| 493 | if (cli_wand->wand.exception != (ExceptionInfo *) NULL ) |
| 494 | cli_wand->wand.exception=DestroyExceptionInfo(cli_wand->wand.exception); |
| 495 | RelinquishWandId(cli_wand->wand.id); |
| 496 | cli_wand->wand.signature=(~WandSignature); |
| 497 | |
| 498 | return((MagickCLI *)NULL); |
| 499 | } |
| 500 | |
| 501 | /* |
| 502 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 503 | % % |
| 504 | % % |
| 505 | % % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 506 | + C L I C a t c h E x c e p t i o n % |
| 507 | % % |
| 508 | % % |
| 509 | % % |
| 510 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 511 | % |
| 512 | % CLICatchException() will report exceptions, either just non-fatal warnings |
| 513 | % only, or all errors, according to 'all_execeptions' boolean argument. |
| 514 | % |
| 515 | % The function returns true is errors are fatal, in which case the caller |
| 516 | % should abort and re-call with an 'all_exceptions' argument of true before |
| 517 | % quitting. |
| 518 | % |
| 519 | % The cut-off level between fatal and non-fatal may be controlled by options |
| 520 | % (FUTURE), but defaults to 'Error' exceptions. |
| 521 | % |
| 522 | % The format of the CLICatchException method is: |
| 523 | % |
| 524 | % MagickBooleanType CLICatchException(MagickCLI *cli_wand, |
| 525 | % const MagickBooleanType all_exceptions ); |
| 526 | % |
| 527 | */ |
| 528 | WandExport MagickBooleanType CLICatchException(MagickCLI *cli_wand, |
| 529 | const MagickBooleanType all_exceptions ) |
| 530 | { |
| 531 | MagickBooleanType |
| 532 | status; |
| 533 | assert(cli_wand != (MagickCLI *) NULL); |
| 534 | assert(cli_wand->signature == WandSignature); |
| 535 | assert(cli_wand->wand.signature == WandSignature); |
| 536 | if (cli_wand->wand.debug != MagickFalse) |
| 537 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 538 | |
| 539 | // FUTURE: '-regard_warning' should make this more sensitive. |
| 540 | // Note pipelined options may like more control over this level |
| 541 | |
| 542 | status = MagickFalse; |
| 543 | if (cli_wand->wand.exception->severity > ErrorException) |
| 544 | status = MagickTrue; |
| 545 | |
| 546 | if ( status == MagickFalse || all_exceptions != MagickFalse ) |
| 547 | CatchException(cli_wand->wand.exception); /* output and clear exceptions */ |
| 548 | |
| 549 | return(status); |
| 550 | } |
| 551 | |
| 552 | /* |
| 553 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 554 | % % |
| 555 | % % |
| 556 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 557 | + C L I S e t t i n g O p t i o n I n f o % |
| 558 | % % |
| 559 | % % |
| 560 | % % |
| 561 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 562 | % |
| 563 | % CLISettingOptionInfo() applies a single settings option into a CLI wand |
| 564 | % holding the image_info, draw_info, quantize_info structures that will be |
| 565 | % used when processing the images. |
| 566 | % |
| 567 | % These options do no require images to be present in the CLI wand for them |
| 568 | % to be able to be set, in which case they will generally be applied to image |
| 569 | % that are read in later |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 570 | % |
| 571 | % Options handled by this function are listed in CommandOptions[] of |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 572 | % "option.c" that is one of "SettingOptionFlags" option flags. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 573 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 574 | % The format of the CLISettingOptionInfo method is: |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 575 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 576 | % void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 577 | % const char *option, const char *arg1) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 578 | % |
| 579 | % A description of each parameter follows: |
| 580 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 581 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 582 | % |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 583 | % o option: The option string to be set |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 584 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 585 | % o arg1: The single argument used to set this option. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 586 | % |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 587 | % Example usage... |
| 588 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 589 | % CLISettingOptionInfo(cli_wand, "-background", "Red"); // set value |
| 590 | % CLISettingOptionInfo(cli_wand, "-adjoin", NULL); // set boolean |
| 591 | % CLISettingOptionInfo(cli_wand, "+adjoin", NULL); // unset |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 592 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 593 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 594 | % |
| 595 | % argc,argv |
| 596 | % i=index in argv |
| 597 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 598 | % option_info = GetCommandOptionInfo(argv[i]); |
| 599 | % count=option_info->type; |
| 600 | % option_type=option_info->flags; |
| 601 | % |
| 602 | % if ( (option_type & SettingOperatorOptionFlags) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 603 | % CLISettingOptionInfo(cli_wand, argv[i], |
| 604 | % (count>0) ? argv[i+1] : (char *)NULL); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 605 | % i += count+1; |
| 606 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 607 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 608 | WandExport void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 609 | const char *option,const char *arg1) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 610 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 611 | ssize_t |
| 612 | parse; /* option argument parsing (string to value table lookup) */ |
| 613 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 614 | assert(cli_wand != (MagickCLI *) NULL); |
| 615 | assert(cli_wand->signature == WandSignature); |
| 616 | assert(cli_wand->wand.signature == WandSignature); |
| 617 | if (cli_wand->wand.debug != MagickFalse) |
| 618 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 619 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 620 | #define _image_info (cli_wand->wand.image_info) |
| 621 | #define _exception (cli_wand->wand.exception) |
| 622 | #define _draw_info (cli_wand->draw_info) |
| 623 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 624 | #define IfSetOption (*option=='-') |
| 625 | #define ArgBoolean (IfSetOption?MagickTrue:MagickFalse) |
| 626 | #define ArgBooleanNot (IfSetOption?MagickFalse:MagickTrue) |
| 627 | #define ArgBooleanString (IfSetOption?"true":"false") |
| 628 | #define ArgOption(def) (IfSetOption?arg1:(const char *)(def)) |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 629 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 630 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 631 | { |
| 632 | case 'a': |
| 633 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 634 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 635 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 636 | _image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 637 | break; |
| 638 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 639 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 640 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 641 | /* DEPRECIATED: _draw_info setting only: for -draw and -transform */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 642 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 643 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 644 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 645 | GetAffineMatrix(&_draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 646 | break; |
| 647 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 648 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 649 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 650 | _image_info->antialias = |
| 651 | _draw_info->stroke_antialias = |
| 652 | _draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 653 | break; |
| 654 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 655 | if (LocaleCompare("attenuate",option+1) == 0) |
| 656 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 657 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 658 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 659 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 660 | break; |
| 661 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 662 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 663 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 664 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 665 | break; |
| 666 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 667 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 668 | } |
| 669 | case 'b': |
| 670 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 671 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 672 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 673 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 674 | _image_info only used directly for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 675 | SyncImageSettings() used to set per-image attribute. |
| 676 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 677 | FUTURE: if _image_info->background_color is not set then |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 678 | we should fall back to per-image background_color |
| 679 | |
| 680 | At this time -background will 'wipe out' the per-image |
| 681 | background color! |
| 682 | |
| 683 | Better error handling of QueryColorCompliance() needed. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 684 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 685 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 686 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 687 | &_image_info->background_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 688 | break; |
| 689 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 690 | if (LocaleCompare("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 691 | { |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 692 | /* FUTURE: bias OBSOLETED, replaced by "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 693 | as it is actually rarely used except in direct convolve operations |
| 694 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 695 | |
| 696 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 697 | */ |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 698 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 699 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 700 | (void) SetImageOption(_image_info,option+1,ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 701 | break; |
| 702 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 703 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 704 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 705 | /* Used as a image chromaticity setting |
| 706 | SyncImageSettings() used to set per-image attribute. |
| 707 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 708 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 709 | break; |
| 710 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 711 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 712 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 713 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 714 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 715 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 716 | */ |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 717 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 718 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 719 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 720 | break; |
| 721 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 722 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 723 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 724 | /* FUTURE: both _image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 725 | SyncImageSettings() used to set per-image attribute. |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 726 | Better error checking of QueryColorCompliance(). |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 727 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 728 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 729 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 730 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 731 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 732 | &_image_info->border_color,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 733 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 734 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 735 | break; |
| 736 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 737 | (void) DeleteImageOption(_image_info,option+1); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 738 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 739 | &_image_info->border_color,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 740 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 741 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 742 | break; |
| 743 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 744 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 745 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 746 | /* DEPRECIATED - now "undercolor" */ |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 747 | CLISettingOptionInfo(cli_wand,"undercolor",arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 748 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 749 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 750 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 751 | } |
| 752 | case 'c': |
| 753 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 754 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 755 | { |
| 756 | MagickSizeType |
| 757 | limit; |
| 758 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 759 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 760 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 761 | limit=MagickResourceInfinity; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 762 | if (LocaleCompare("unlimited",arg1) != 0) |
| 763 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 764 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 765 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 766 | break; |
| 767 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 768 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 769 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 770 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 771 | break; |
| 772 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 773 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 774 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 775 | arg1=ArgOption("default"); |
| 776 | parse=ParseChannelOption(arg1); |
| 777 | if (parse < 0) |
| 778 | CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType", |
| 779 | option,arg1); |
| 780 | _image_info->channel=(ChannelType) parse; |
| 781 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 782 | break; |
| 783 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 784 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 785 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 786 | /* Setting used for new images via AquireImage() |
| 787 | But also used as a SimpleImageOperator |
| 788 | Undefined colorspace means don't modify images on |
| 789 | read or as a operation */ |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 790 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 791 | ArgOption("undefined")); |
| 792 | if (parse < 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 793 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 794 | option,arg1); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 795 | _image_info->colorspace=(ColorspaceType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 796 | break; |
| 797 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 798 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 799 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 800 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 801 | break; |
| 802 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 803 | if (LocaleCompare("compose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 804 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 805 | /* FUTURE: _image_info should be used, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 806 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 807 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 808 | This setting should NOT be used to set image 'compose' |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 809 | "-layer" operators shoud use _image_info if defined otherwise |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 810 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 811 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 812 | parse = ParseCommandOption(MagickComposeOptions,MagickFalse, |
| 813 | ArgOption("undefined")); |
| 814 | if (parse < 0) |
| 815 | CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", |
| 816 | option,arg1); |
| 817 | _image_info->compose=(CompositeOperator) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 818 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 819 | break; |
| 820 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 821 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 822 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 823 | /* FUTURE: What should be used? _image_info or ImageOption ??? |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 824 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 825 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 826 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 827 | The coders appears to use _image_info, not Image_Option |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 828 | however the image attribute (for save) is set from the |
| 829 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 830 | |
| 831 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 832 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 833 | parse = ParseCommandOption(MagickCompressOptions,MagickFalse, |
| 834 | ArgOption("undefined")); |
| 835 | if (parse < 0) |
| 836 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", |
| 837 | option,arg1); |
| 838 | _image_info->compression=(CompressionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 839 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 840 | break; |
| 841 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 842 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 843 | } |
| 844 | case 'd': |
| 845 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 846 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 847 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 848 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 849 | arg1=ArgOption("none"); |
| 850 | parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); |
| 851 | if (parse < 0) |
| 852 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", |
| 853 | option,arg1); |
| 854 | (void) SetLogEventMask(arg1); |
| 855 | _image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 856 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 857 | break; |
| 858 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 859 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 860 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 861 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 862 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 863 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 864 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 865 | else |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 866 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 867 | break; |
| 868 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 869 | /* DefineImageOption() equals SetImageOption() but with '=' */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 870 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 871 | (void) DefineImageOption(_image_info,arg1); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 872 | else if ( DeleteImageOption(_image_info,arg1) == MagickFalse ) |
| 873 | CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 874 | break; |
| 875 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 876 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 877 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 878 | /* Only used for new images via AcquireImage() |
| 879 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 880 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 881 | arg1=ArgOption("0"); |
| 882 | if (IsGeometry(arg1) == MagickFalse) |
| 883 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 884 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 885 | break; |
| 886 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 887 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 888 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 889 | /* FUTURE: strings used in _image_info attr and _draw_info! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 890 | Basically as density can be in a XxY form! |
| 891 | |
| 892 | SyncImageSettings() used to set per-image attribute. |
| 893 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 894 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 895 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 896 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 897 | (void) CloneString(&_image_info->density,ArgOption(NULL)); |
| 898 | (void) CloneString(&_draw_info->density,_image_info->density); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 899 | break; |
| 900 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 901 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 902 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 903 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 904 | SyncImageSettings() used to set per-image attribute. |
| 905 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 906 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 907 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 908 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 909 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 910 | break; |
| 911 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 912 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 913 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 914 | /* Image Option is only used to set _draw_info */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 915 | arg1=ArgOption("undefined"); |
| 916 | parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); |
| 917 | if (parse < 0) |
| 918 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", |
| 919 | option,arg1); |
| 920 | _draw_info->direction=(DirectionType) parse; |
| 921 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 922 | break; |
| 923 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 924 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 925 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 926 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); |
| 927 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 928 | break; |
| 929 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 930 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 931 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 932 | /* only used in setting new images */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 933 | arg1=ArgOption("undefined"); |
| 934 | parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); |
| 935 | if (parse < 0) |
| 936 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", |
| 937 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 938 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 939 | break; |
| 940 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 941 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 942 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 943 | /* _image_info attr (on/off), _quantize_info attr (on/off) |
| 944 | but also ImageInfo and _quantize_info method! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 945 | FUTURE: merge the duality of the dithering options |
| 946 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 947 | _image_info->dither = _quantize_info->dither = ArgBoolean; |
| 948 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); |
| 949 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 950 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 951 | if (_quantize_info->dither_method == NoDitherMethod) |
| 952 | _image_info->dither = _quantize_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 953 | break; |
| 954 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 955 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 956 | } |
| 957 | case 'e': |
| 958 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 959 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 960 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 961 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); |
| 962 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 963 | break; |
| 964 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 965 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 966 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 967 | /* Both _image_info attr and ImageInfo */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 968 | arg1 = ArgOption("undefined"); |
| 969 | parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); |
| 970 | if (parse < 0) |
| 971 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", |
| 972 | option,arg1); |
| 973 | _image_info->endian=(EndianType) arg1; |
| 974 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 975 | break; |
| 976 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 977 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 978 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 979 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 980 | break; |
| 981 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 982 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 983 | } |
| 984 | case 'f': |
| 985 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 986 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 987 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 988 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 989 | break; |
| 990 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 991 | if (LocaleCompare("fill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 992 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 993 | /* Set "fill" OR "fill-pattern" in _draw_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 994 | The original fill color is preserved if a fill-pattern is given. |
| 995 | That way it does not effect other operations that directly using |
| 996 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 997 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 998 | MagickBooleanType |
| 999 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 1000 | |
| 1001 | ExceptionInfo |
| 1002 | *sans; |
| 1003 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1004 | PixelInfo |
| 1005 | color; |
| 1006 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1007 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1008 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1009 | if (_draw_info->fill_pattern != (Image *) NULL) |
| 1010 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1011 | |
| 1012 | /* is it a color or a image? -- ignore exceptions */ |
| 1013 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1014 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1015 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1016 | |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 1017 | if (status == MagickFalse) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1018 | _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1019 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1020 | _draw_info->fill=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1021 | break; |
| 1022 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1023 | if (LocaleCompare("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1024 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1025 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1026 | arg1 = ArgOption("undefined"); |
| 1027 | parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); |
| 1028 | if (parse < 0) |
| 1029 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", |
| 1030 | option,arg1); |
| 1031 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1032 | break; |
| 1033 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1034 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1035 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1036 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); |
| 1037 | (void) CloneString(&_image_info->font,_draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1038 | break; |
| 1039 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1040 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1041 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1042 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 1043 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1044 | register const char |
| 1045 | *q; |
| 1046 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1047 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1048 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1049 | _image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1050 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1051 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1052 | break; |
| 1053 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1054 | if (LocaleCompare("fuzz",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1055 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1056 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1057 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1058 | SyncImageSettings() used to set per-image attribute. |
| 1059 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1060 | FUTURE: Can't find anything else using _image_info->fuzz directly! |
| 1061 | remove direct sttribute from image_info |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 1062 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1063 | arg1=ArgOption("0"); |
| 1064 | if (IsGeometry(arg1) == MagickFalse) |
| 1065 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1066 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 1067 | QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1068 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1069 | break; |
| 1070 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1071 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1072 | } |
| 1073 | case 'g': |
| 1074 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1075 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1076 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1077 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1078 | arg1 = ArgOption("none"); |
| 1079 | parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); |
| 1080 | if (parse < 0) |
| 1081 | CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", |
| 1082 | option,arg1); |
| 1083 | (void) SetImageOption(_image_info,option+1,arg1); |
| 1084 | _draw_info->gravity=(GravityType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1085 | break; |
| 1086 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1087 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1088 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1089 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1090 | SyncImageSettings() used to set per-image attribute. |
| 1091 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1092 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1093 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 1094 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1095 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1096 | break; |
| 1097 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1098 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1099 | } |
| 1100 | case 'i': |
| 1101 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1102 | if (LocaleCompare("intent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1103 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1104 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1105 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1106 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1107 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1108 | arg1 = ArgOption("indefined"); |
| 1109 | parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); |
| 1110 | if (parse < 0) |
| 1111 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", |
| 1112 | option,arg1); |
| 1113 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1114 | break; |
| 1115 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1116 | if (LocaleCompare("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1117 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1118 | /* _image_info is directly used by coders (so why an image setting?) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1119 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1120 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1121 | arg1 = ArgOption("undefined"); |
| 1122 | parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); |
| 1123 | if (parse < 0) |
| 1124 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", |
| 1125 | option,arg1); |
| 1126 | _image_info->interlace=(InterlaceType) parse; |
| 1127 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1128 | break; |
| 1129 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1130 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1131 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1132 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 1133 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1134 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1135 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1136 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1137 | break; |
| 1138 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1139 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1140 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1141 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1142 | arg1 = ArgOption("undefined"); |
| 1143 | parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); |
| 1144 | if (parse < 0) |
| 1145 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", |
| 1146 | option,arg1); |
| 1147 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1148 | break; |
| 1149 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1150 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1151 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1152 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 1153 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1154 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1155 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1156 | break; |
| 1157 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1158 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1159 | } |
| 1160 | case 'k': |
| 1161 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1162 | if (LocaleCompare("kerning",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1163 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1164 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 1165 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1166 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1167 | _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1168 | break; |
| 1169 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1170 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1171 | } |
| 1172 | case 'l': |
| 1173 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1174 | if (LocaleCompare("label",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1175 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1176 | /* only used for new images - not in SyncImageOptions() */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1177 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1178 | break; |
| 1179 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1180 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1181 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1182 | if (IfSetOption) { |
| 1183 | if ((strchr(arg1,'%') == (char *) NULL)) |
| 1184 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1185 | (void) SetLogFormat(arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1186 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1187 | break; |
| 1188 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1189 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1190 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1191 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1192 | arg1=ArgOption("0"); |
| 1193 | if (IsGeometry(arg1) == MagickFalse) |
| 1194 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1195 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1196 | break; |
| 1197 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1198 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1199 | } |
| 1200 | case 'm': |
| 1201 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1202 | if (LocaleCompare("mattecolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1203 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1204 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1205 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1206 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1207 | &_image_info->matte_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1208 | break; |
| 1209 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1210 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1211 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1212 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1213 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1214 | break; |
| 1215 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1216 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1217 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1218 | /* Setting (used by some input coders!) -- why? |
| 1219 | Warning: This is also Special '-type' SimpleOperator |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1220 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1221 | _image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1222 | break; |
| 1223 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1224 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1225 | } |
| 1226 | case 'o': |
| 1227 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1228 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1229 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1230 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1231 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1232 | FUTURE: make set meta-data operator instead. |
| 1233 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1234 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 1235 | parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
| 1236 | ArgOption("undefined")); |
| 1237 | if (parse < 0) |
| 1238 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", |
| 1239 | option,arg1); |
| 1240 | _image_info->orientation=(OrientationType)parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1241 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1242 | break; |
| 1243 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1244 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1245 | } |
| 1246 | case 'p': |
| 1247 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1248 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1249 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 1250 | /* Only used for new images and image generators. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1251 | SyncImageSettings() used to set per-image attribute. ????? |
| 1252 | That last is WRONG!!!! |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 1253 | FUTURE: adjust named 'page' sizes according density |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1254 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1255 | char |
| 1256 | *canonical_page, |
| 1257 | page[MaxTextExtent]; |
| 1258 | |
| 1259 | const char |
| 1260 | *image_option; |
| 1261 | |
| 1262 | MagickStatusType |
| 1263 | flags; |
| 1264 | |
| 1265 | RectangleInfo |
| 1266 | geometry; |
| 1267 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1268 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1269 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1270 | (void) DeleteImageOption(_image_info,option+1); |
| 1271 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1272 | break; |
| 1273 | } |
| 1274 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1275 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1276 | if (image_option != (const char *) NULL) |
| 1277 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1278 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1279 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1280 | canonical_page=DestroyString(canonical_page); |
| 1281 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1282 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1283 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1284 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1285 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1286 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1287 | (void) SetImageOption(_image_info,option+1,page); |
| 1288 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1289 | break; |
| 1290 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1291 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1292 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1293 | _image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1294 | break; |
| 1295 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1296 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1297 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 1298 | if (IsGeometry(arg1) == MagickFalse) |
| 1299 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1300 | _image_info->pointsize=_draw_info->pointsize= |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1301 | StringToDouble(ArgOption("12"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1302 | break; |
| 1303 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1304 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1305 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1306 | (void) SetMagickPrecision(StringToInteger(ArgOption("-1"))); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1307 | break; |
| 1308 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1309 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1310 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1311 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1312 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1313 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1314 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1315 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1316 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1317 | break; |
| 1318 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1319 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1320 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1321 | } |
| 1322 | case 'q': |
| 1323 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1324 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1325 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 1326 | if (IsGeometry(arg1) == MagickFalse) |
| 1327 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1328 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1329 | _image_info->quality=UNDEFINED_COMPRESSION_QUALITY; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1330 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1331 | _image_info->quality=StringToUnsignedLong(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1332 | break; |
| 1333 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1334 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1335 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1336 | /* Just a set direct in _quantize_info */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 1337 | arg1=ArgOption("undefined"); |
| 1338 | parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
| 1339 | if (parse < 0) |
| 1340 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 1341 | option,arg1); |
| 1342 | _quantize_info->colorspace=(ColorspaceType)parse; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1343 | break; |
| 1344 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1345 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1346 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1347 | /* FUTURE: if two -quiet is performed you can not do +quiet! */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1348 | static WarningHandler |
| 1349 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1350 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1351 | WarningHandler |
| 1352 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1353 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1354 | if ( tmp != (WarningHandler) NULL) |
| 1355 | warning_handler = tmp; /* remember the old handler */ |
| 1356 | if (!IfSetOption) /* set the old handler */ |
| 1357 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1358 | break; |
| 1359 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1360 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1361 | } |
| 1362 | case 'r': |
| 1363 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1364 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1365 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1366 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1367 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1368 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1369 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1370 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 1371 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1372 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1373 | break; |
| 1374 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1375 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1376 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1377 | /* _draw_info only setting */ |
| 1378 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1379 | break; |
| 1380 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1381 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1382 | } |
| 1383 | case 's': |
| 1384 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1385 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1386 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1387 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1388 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1389 | break; |
| 1390 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1391 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1392 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1393 | /* SyncImageSettings() used to set per-image attribute. |
| 1394 | What ??? Why ???? |
| 1395 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1396 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1397 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1398 | break; |
| 1399 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1400 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1401 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1402 | SeedPseudoRandomGenerator( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1403 | IfSetOption ? (size_t) StringToUnsignedLong(arg1) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1404 | : (size_t) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1405 | break; |
| 1406 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1407 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1408 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1409 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1410 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1411 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1412 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1413 | break; |
| 1414 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1415 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1416 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1417 | _draw_info->stretch=(StretchType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1418 | MagickStretchOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1419 | break; |
| 1420 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1421 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1422 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1423 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1424 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1425 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1426 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1427 | MagickBooleanType |
| 1428 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1429 | |
| 1430 | ExceptionInfo |
| 1431 | *sans; |
| 1432 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1433 | PixelInfo |
| 1434 | color; |
| 1435 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1436 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1437 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1438 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1439 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1440 | |
| 1441 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1442 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1443 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1444 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1445 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1446 | if (status == MagickFalse) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1447 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1448 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1449 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1450 | break; |
| 1451 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1452 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1453 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1454 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1455 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1456 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1457 | break; |
| 1458 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1459 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1460 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1461 | _draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1462 | MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1463 | break; |
| 1464 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1465 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1466 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1467 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1468 | break; |
| 1469 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1470 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1471 | } |
| 1472 | case 't': |
| 1473 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1474 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1475 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1476 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1477 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1478 | break; |
| 1479 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1480 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1481 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1482 | /* FUTURE: move _image_info string to option splay-tree */ |
| 1483 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1484 | break; |
| 1485 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1486 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1487 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1488 | _draw_info->fill_pattern=IfSetOption |
| 1489 | ?GetImageCache(_image_info,arg1,_exception) |
| 1490 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1491 | break; |
| 1492 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1493 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1494 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1495 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1496 | (void) SetImageOption(_image_info,option+1,ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1497 | break; |
| 1498 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1499 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1500 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1501 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1502 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1503 | SyncImageSettings() used to set per-image attribute. |
| 1504 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1505 | Note that +transparent-color, means fall-back to image |
| 1506 | attribute so ImageOption is deleted, not set to a default. |
| 1507 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1508 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1509 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1510 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1511 | break; |
| 1512 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1513 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1514 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1515 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1516 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1517 | break; |
| 1518 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1519 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1520 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1521 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1522 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1523 | _image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1524 | MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1525 | break; |
| 1526 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1527 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1528 | } |
| 1529 | case 'u': |
| 1530 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1531 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1532 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1533 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1534 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1535 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1536 | break; |
| 1537 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1538 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1539 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1540 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1541 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1542 | FUTURE: this probably should be part of the density setting |
| 1543 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1544 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1545 | _image_info->units=(ResolutionType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1546 | MagickResolutionOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1547 | break; |
| 1548 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1549 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1550 | } |
| 1551 | case 'v': |
| 1552 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1553 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1554 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1555 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1556 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1557 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1558 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1559 | _image_info->verbose= ArgBoolean; |
| 1560 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1561 | break; |
| 1562 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1563 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1564 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1565 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1566 | Only used by coder FPX |
| 1567 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1568 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1569 | break; |
| 1570 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1571 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1572 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1573 | /* SyncImageSettings() used to set per-image attribute. |
| 1574 | This is VERY deep in the image caching structure. |
| 1575 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1576 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1577 | break; |
| 1578 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1579 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1580 | } |
| 1581 | case 'w': |
| 1582 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1583 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1584 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1585 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1586 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1587 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1588 | if (!IfSetOption) |
| 1589 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1590 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1591 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1592 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1593 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1594 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1595 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1596 | if (_draw_info->weight <= 800) |
| 1597 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1598 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1599 | if (_draw_info->weight >= 100) |
| 1600 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1601 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1602 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1603 | break; |
| 1604 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1605 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1606 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1607 | /* Used as a image chromaticity setting |
| 1608 | SyncImageSettings() used to set per-image attribute. |
| 1609 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1610 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1611 | break; |
| 1612 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1613 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1614 | } |
| 1615 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1616 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1617 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1618 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1619 | #undef _image_info |
| 1620 | #undef _exception |
| 1621 | #undef _draw_info |
| 1622 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1623 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1624 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1625 | #undef ArgBooleanNot |
| 1626 | #undef ArgBooleanString |
| 1627 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1628 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1629 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1630 | } |
| 1631 | |
| 1632 | /* |
| 1633 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1634 | % % |
| 1635 | % % |
| 1636 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1637 | + C L I S i m p l e O p e r a t o r I m a g e s % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1638 | % % |
| 1639 | % % |
| 1640 | % % |
| 1641 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1642 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1643 | % WandSimpleOperatorImages() applys one simple image operation given to all |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1644 | % the images in the CLI wand, with the settings that was previously saved in |
| 1645 | % the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1646 | % |
| 1647 | % It is assumed that any per-image settings are up-to-date with respect to |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1648 | % extra settings that were already saved in the wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1649 | % |
anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1650 | % The format of the WandSimpleOperatorImage method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1651 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1652 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1653 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1654 | % |
| 1655 | % A description of each parameter follows: |
| 1656 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1657 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1658 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1659 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1660 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1661 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1662 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1663 | % Any problems will be added to the 'exception' entry of the given wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1664 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1665 | % Example usage... |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1666 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1667 | % CLISimpleOperatorImages(cli_wand, "-crop","100x100+20+30",NULL); |
| 1668 | % CLISimpleOperatorImages(cli_wand, "+repage",NULL,NULL); |
| 1669 | % CLISimpleOperatorImages(cli_wand, "+distort","SRT","45"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1670 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1671 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1672 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1673 | % cli_wand |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1674 | % argc,argv |
| 1675 | % i=index in argv |
| 1676 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 1677 | % option_info = GetCommandOptionInfo(argv[i]); |
| 1678 | % count=option_info->type; |
| 1679 | % option_type=option_info->flags; |
| 1680 | % |
| 1681 | % if ( (option_type & SimpleOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1682 | % CLISimpleOperatorImages(cli_wand, argv[i], |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1683 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 1684 | % count>=2 ? argv[i+2] : (char *)NULL ); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1685 | % i += count+1; |
| 1686 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1687 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1688 | |
| 1689 | /* |
| 1690 | Internal subrountine to apply one simple image operation to the current |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1691 | image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1692 | |
| 1693 | The image in the list may be modified in three different ways... |
| 1694 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1695 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1696 | * one image replace by a list of images (-separate and -crop only!) |
| 1697 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1698 | In each case the result replaces the single original image in the list, as |
| 1699 | well as the pointer to the modified image (last image added if replaced by a |
| 1700 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1701 | |
| 1702 | As the image pointed to may be replaced, the first image in the list may |
| 1703 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1704 | return the Image pointer to the first image in list. |
| 1705 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1706 | static void CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1707 | const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1708 | { |
| 1709 | Image * |
| 1710 | new_image; |
| 1711 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1712 | GeometryInfo |
| 1713 | geometry_info; |
| 1714 | |
| 1715 | RectangleInfo |
| 1716 | geometry; |
| 1717 | |
| 1718 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1719 | flags; |
| 1720 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1721 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1722 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1723 | |
| 1724 | #define _image_info (cli_wand->wand.image_info) |
| 1725 | #define _image (cli_wand->wand.images) |
| 1726 | #define _exception (cli_wand->wand.exception) |
| 1727 | #define _draw_info (cli_wand->draw_info) |
| 1728 | #define _quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1729 | #define IfNormalOp (*option=='-') |
| 1730 | #define IfPlusOp (*option!='-') |
| 1731 | #define normal_op (IfNormalOp?MagickTrue:MagickFalse) |
| 1732 | #define plus_alt_op (IfNormalOp?MagickFalse:MagickTrue) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1733 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1734 | assert(cli_wand != (MagickCLI *) NULL); |
| 1735 | assert(cli_wand->signature == WandSignature); |
| 1736 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1737 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1738 | if (cli_wand->wand.debug != MagickFalse) |
| 1739 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1740 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1741 | (void) SyncImageSettings(_image_info,_image,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1742 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1743 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1744 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1745 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1746 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1747 | /* FUTURE: We may need somthing a little more optimized than this! |
| 1748 | Perhaps, do the 'sync' if 'settings tainted' before next operator. |
| 1749 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1750 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1751 | { |
| 1752 | case 'a': |
| 1753 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1754 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1755 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1756 | if (IsGeometry(arg1) == MagickFalse) |
| 1757 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1758 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1759 | if ((flags & SigmaValue) == 0) |
| 1760 | geometry_info.sigma=1.0; |
| 1761 | if ((flags & XiValue) == 0) |
| 1762 | geometry_info.xi=0.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1763 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
| 1764 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1765 | break; |
| 1766 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1767 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1768 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1769 | /* FUTURE: Roll into a resize special operator */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1770 | if (IsGeometry(arg1) == MagickFalse) |
| 1771 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1772 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1773 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
| 1774 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1775 | break; |
| 1776 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1777 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1778 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1779 | if (IsGeometry(arg1) == MagickFalse) |
| 1780 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1781 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1782 | if ((flags & SigmaValue) == 0) |
| 1783 | geometry_info.sigma=1.0; |
| 1784 | if ((flags & XiValue) == 0) |
| 1785 | geometry_info.xi=0.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1786 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
| 1787 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1788 | break; |
| 1789 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1790 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1791 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1792 | parse=ParseCommandOption(MagickAlphaOptions,MagickFalse,arg1); |
| 1793 | if (parse < 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1794 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelType", |
| 1795 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1796 | (void) SetImageAlphaChannel(_image,(AlphaChannelType)parse, |
| 1797 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1798 | break; |
| 1799 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1800 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1801 | { |
| 1802 | char |
| 1803 | *text, |
| 1804 | geometry[MaxTextExtent]; |
| 1805 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1806 | if (IsGeometry(arg1) == MagickFalse) |
| 1807 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1808 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1809 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1810 | if ((flags & SigmaValue) == 0) |
| 1811 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1812 | text=InterpretImageProperties(_image_info,_image,arg2, |
| 1813 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1814 | if (text == (char *) NULL) |
| 1815 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1816 | (void) CloneString(&_draw_info->text,text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1817 | text=DestroyString(text); |
| 1818 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1819 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1820 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1821 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1822 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1823 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1824 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1825 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1826 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1827 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1828 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1829 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1830 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1831 | break; |
| 1832 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1833 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1834 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1835 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1836 | break; |
| 1837 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1838 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1839 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1840 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1841 | break; |
| 1842 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1843 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1844 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1845 | /* This should probably be a MagickCore function */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1846 | switch (_image->orientation) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1847 | { |
| 1848 | case TopRightOrientation: |
| 1849 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1850 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1851 | break; |
| 1852 | } |
| 1853 | case BottomRightOrientation: |
| 1854 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1855 | new_image=RotateImage(_image,180.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1856 | break; |
| 1857 | } |
| 1858 | case BottomLeftOrientation: |
| 1859 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1860 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1861 | break; |
| 1862 | } |
| 1863 | case LeftTopOrientation: |
| 1864 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1865 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1866 | break; |
| 1867 | } |
| 1868 | case RightTopOrientation: |
| 1869 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1870 | new_image=RotateImage(_image,90.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1871 | break; |
| 1872 | } |
| 1873 | case RightBottomOrientation: |
| 1874 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1875 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1876 | break; |
| 1877 | } |
| 1878 | case LeftBottomOrientation: |
| 1879 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1880 | new_image=RotateImage(_image,270.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1881 | break; |
| 1882 | } |
| 1883 | default: |
| 1884 | break; |
| 1885 | } |
| 1886 | if (new_image != (Image *) NULL) |
| 1887 | new_image->orientation=TopLeftOrientation; |
| 1888 | break; |
| 1889 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1890 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1891 | } |
| 1892 | case 'b': |
| 1893 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1894 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1895 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1896 | if (IsGeometry(arg1) == MagickFalse) |
| 1897 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1898 | (void) BlackThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1899 | break; |
| 1900 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1901 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1902 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1903 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1904 | if (IfNormalOp) { |
| 1905 | if (IsGeometry(arg1) == MagickFalse) |
| 1906 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1907 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1908 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1909 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1910 | break; |
| 1911 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1912 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1913 | { |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1914 | /* FUTURE: use of "bias" in a blur is non-sensible */ |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1915 | if (IsGeometry(arg1) == MagickFalse) |
| 1916 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1917 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1918 | if ((flags & SigmaValue) == 0) |
| 1919 | geometry_info.sigma=1.0; |
| 1920 | if ((flags & XiValue) == 0) |
| 1921 | geometry_info.xi=0.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1922 | new_image=BlurImage(_image,geometry_info.rho, |
| 1923 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1924 | break; |
| 1925 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1926 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1927 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1928 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1929 | compose; |
| 1930 | |
| 1931 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1932 | value; |
| 1933 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1934 | if (IsGeometry(arg1) == MagickFalse) |
| 1935 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1936 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1937 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1938 | if (value != (const char *) NULL) |
| 1939 | compose=(CompositeOperator) ParseCommandOption( |
| 1940 | MagickComposeOptions,MagickFalse,value); |
| 1941 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1942 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1943 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1944 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1945 | if ((flags & SigmaValue) == 0) |
| 1946 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1947 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1948 | break; |
| 1949 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1950 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1951 | { |
| 1952 | double |
| 1953 | brightness, |
| 1954 | contrast; |
| 1955 | |
| 1956 | GeometryInfo |
| 1957 | geometry_info; |
| 1958 | |
| 1959 | MagickStatusType |
| 1960 | flags; |
| 1961 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1962 | if (IsGeometry(arg1) == MagickFalse) |
| 1963 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1964 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1965 | brightness=geometry_info.rho; |
| 1966 | contrast=0.0; |
| 1967 | if ((flags & SigmaValue) != 0) |
| 1968 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1969 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1970 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1971 | break; |
| 1972 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1973 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1974 | } |
| 1975 | case 'c': |
| 1976 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1977 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1978 | { |
| 1979 | char |
| 1980 | *color_correction_collection; |
| 1981 | |
| 1982 | /* |
| 1983 | Color correct with a color decision list. |
| 1984 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1985 | color_correction_collection=FileToString(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1986 | if (color_correction_collection == (char *) NULL) |
| 1987 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1988 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 1989 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1990 | break; |
| 1991 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1992 | if (LocaleCompare("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1993 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1994 | if (IsGeometry(arg1) == MagickFalse) |
| 1995 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1996 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1997 | if ((flags & SigmaValue) == 0) |
| 1998 | geometry_info.sigma=1.0; |
| 1999 | if ((flags & XiValue) == 0) |
| 2000 | geometry_info.xi=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2001 | new_image=CharcoalImage(_image,geometry_info.rho, |
| 2002 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2003 | break; |
| 2004 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2005 | if (LocaleCompare("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2006 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2007 | if (IsGeometry(arg1) == MagickFalse) |
| 2008 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2009 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 2010 | new_image=ChopImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2011 | break; |
| 2012 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2013 | if (LocaleCompare("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2014 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2015 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2016 | break; |
| 2017 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2018 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2019 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2020 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2021 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 2022 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2023 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2024 | break; |
| 2025 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2026 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2027 | { |
| 2028 | CacheView |
| 2029 | *mask_view; |
| 2030 | |
| 2031 | Image |
| 2032 | *mask_image; |
| 2033 | |
| 2034 | register Quantum |
| 2035 | *restrict q; |
| 2036 | |
| 2037 | register ssize_t |
| 2038 | x; |
| 2039 | |
| 2040 | ssize_t |
| 2041 | y; |
| 2042 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2043 | if (IfPlusOp) { |
| 2044 | /* "+clip-mask" Remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2045 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2046 | break; |
| 2047 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2048 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2049 | if (mask_image == (Image *) NULL) |
| 2050 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2051 | if (SetImageStorageClass(mask_image,DirectClass,_exception) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2052 | == MagickFalse) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2053 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2054 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2055 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2056 | mask_view=AcquireCacheView(mask_image); |
| 2057 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 2058 | { |
| 2059 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2060 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2061 | if (q == (Quantum *) NULL) |
| 2062 | break; |
| 2063 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 2064 | { |
| 2065 | if (mask_image->matte == MagickFalse) |
| 2066 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 2067 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2068 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2069 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2070 | q+=GetPixelChannels(mask_image); |
| 2071 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2072 | if (SyncCacheViewAuthenticPixels(mask_view,_exception) == MagickFalse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2073 | break; |
| 2074 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2075 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2076 | mask_view=DestroyCacheView(mask_view); |
| 2077 | mask_image->matte=MagickTrue; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2078 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2079 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2080 | break; |
| 2081 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2082 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2083 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2084 | (void) ClipImagePath(_image,arg1,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2085 | break; |
| 2086 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2087 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2088 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2089 | if (IsGeometry(arg1) == MagickFalse) |
| 2090 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2091 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2092 | break; |
| 2093 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2094 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2095 | { |
| 2096 | KernelInfo |
| 2097 | *kernel; |
| 2098 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2099 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2100 | if (kernel == (KernelInfo *) NULL) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2101 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2102 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2103 | kernel=DestroyKernelInfo(kernel); |
| 2104 | break; |
| 2105 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2106 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2107 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2108 | /* Reduce the number of colors in the image. |
| 2109 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2110 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2111 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2112 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2113 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2114 | if ((_image->storage_class == DirectClass) || |
| 2115 | _image->colors > _quantize_info->number_colors) |
| 2116 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2117 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2118 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2119 | break; |
| 2120 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2121 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2122 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2123 | /* WARNING: this is both a image_info setting (already done) |
| 2124 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2125 | |
| 2126 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2127 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2128 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2129 | Note that +colorspace sets "undefined" or no effect on |
| 2130 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2131 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2132 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2133 | (void) TransformImageColorspace(_image, |
| 2134 | IfNormalOp ? _image_info->colorspace : RGBColorspace, |
| 2135 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2136 | break; |
| 2137 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2138 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2139 | { |
anthony | dcf3a91 | 2012-03-22 14:33:17 +0000 | [diff] [blame] | 2140 | /* DEPRECIATED: The -/+level provides far more controlled form */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2141 | (void) ContrastImage(_image,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2142 | break; |
| 2143 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2144 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2145 | { |
| 2146 | double |
| 2147 | black_point, |
| 2148 | white_point; |
| 2149 | |
| 2150 | MagickStatusType |
| 2151 | flags; |
| 2152 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2153 | if (IsGeometry(arg1) == MagickFalse) |
| 2154 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2155 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2156 | black_point=geometry_info.rho; |
| 2157 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2158 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2159 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2160 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2161 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2162 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2163 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2164 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2165 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2166 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2167 | break; |
| 2168 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2169 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2170 | { |
| 2171 | KernelInfo |
| 2172 | *kernel_info; |
| 2173 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2174 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2175 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2176 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2177 | kernel_info->bias=_image->bias; |
| 2178 | new_image=ConvolveImage(_image,kernel_info,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2179 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2180 | break; |
| 2181 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2182 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2183 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2184 | /* WARNING: This can generate multiple images! */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2185 | if (IsGeometry(arg1) == MagickFalse) |
| 2186 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2187 | new_image=CropImageToTiles(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2188 | break; |
| 2189 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2190 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2191 | { |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2192 | if (IsGeometry(arg1) == MagickFalse) |
| 2193 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2194 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2195 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2196 | break; |
| 2197 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2198 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2199 | } |
| 2200 | case 'd': |
| 2201 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2202 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2203 | { |
| 2204 | StringInfo |
| 2205 | *passkey; |
| 2206 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2207 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2208 | if (passkey == (StringInfo *) NULL) |
| 2209 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2210 | |
| 2211 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2212 | passkey=DestroyStringInfo(passkey); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2213 | break; |
| 2214 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2215 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2216 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2217 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2218 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2219 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2220 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2221 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2222 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2223 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2224 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2225 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2226 | break; |
| 2227 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2228 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2229 | { |
| 2230 | double |
| 2231 | threshold; |
| 2232 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2233 | if (IfNormalOp) { |
| 2234 | if (IsGeometry(arg1) == MagickFalse) |
| 2235 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2236 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2237 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2238 | else |
| 2239 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2240 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2241 | break; |
| 2242 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2243 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2244 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2245 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2246 | break; |
| 2247 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2248 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2249 | { |
| 2250 | char |
| 2251 | *args, |
| 2252 | token[MaxTextExtent]; |
| 2253 | |
| 2254 | const char |
| 2255 | *p; |
| 2256 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2257 | double |
| 2258 | *arguments; |
| 2259 | |
| 2260 | register ssize_t |
| 2261 | x; |
| 2262 | |
| 2263 | size_t |
| 2264 | number_arguments; |
| 2265 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2266 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2267 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2268 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2269 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2270 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2271 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2272 | double |
| 2273 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2274 | /* Special Case - Argument is actually a resize geometry! |
| 2275 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2276 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2277 | Roll into a resize special operator */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2278 | if (IsGeometry(arg2) == MagickFalse) |
| 2279 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2280 | option,arg2); |
| 2281 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2282 | resize_args[0]=(double) geometry.width; |
| 2283 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2284 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2285 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2286 | break; |
| 2287 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2288 | /* handle percent arguments */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2289 | args=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2290 | if (args == (char *) NULL) |
| 2291 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2292 | /* convert arguments into an array of doubles |
| 2293 | FUTURE: make this a separate function. |
| 2294 | Also make use of new 'sentinal' feature to avoid need for |
| 2295 | tokenization. |
| 2296 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2297 | p=(char *) args; |
| 2298 | for (x=0; *p != '\0'; x++) |
| 2299 | { |
| 2300 | GetMagickToken(p,&p,token); |
| 2301 | if (*token == ',') |
| 2302 | GetMagickToken(p,&p,token); |
| 2303 | } |
| 2304 | number_arguments=(size_t) x; |
| 2305 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 2306 | sizeof(*arguments)); |
| 2307 | if (arguments == (double *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2308 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 2309 | "MemoryAllocationFailed",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2310 | (void) ResetMagickMemory(arguments,0,number_arguments* |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2311 | sizeof(*arguments)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2312 | p=(char *) args; |
| 2313 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 2314 | { |
| 2315 | GetMagickToken(p,&p,token); |
| 2316 | if (*token == ',') |
| 2317 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2318 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2319 | } |
| 2320 | args=DestroyString(args); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2321 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2322 | number_arguments,arguments,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2323 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 2324 | break; |
| 2325 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2326 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2327 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2328 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2329 | (void) DrawImage(_image,_draw_info,_exception); |
| 2330 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2331 | break; |
| 2332 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2333 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2334 | } |
| 2335 | case 'e': |
| 2336 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2337 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2338 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2339 | if (IsGeometry(arg1) == MagickFalse) |
| 2340 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2341 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2342 | if ((flags & SigmaValue) == 0) |
| 2343 | geometry_info.sigma=1.0; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2344 | new_image=EdgeImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2345 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2346 | break; |
| 2347 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2348 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2349 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2350 | if (IsGeometry(arg1) == MagickFalse) |
| 2351 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2352 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2353 | if ((flags & SigmaValue) == 0) |
| 2354 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2355 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2356 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2357 | break; |
| 2358 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2359 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2360 | { |
| 2361 | StringInfo |
| 2362 | *passkey; |
| 2363 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2364 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2365 | if (passkey != (StringInfo *) NULL) |
| 2366 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2367 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2368 | passkey=DestroyStringInfo(passkey); |
| 2369 | } |
| 2370 | break; |
| 2371 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2372 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2373 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2374 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2375 | break; |
| 2376 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2377 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2378 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2379 | (void) EqualizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2380 | break; |
| 2381 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2382 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2383 | { |
| 2384 | double |
| 2385 | constant; |
| 2386 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2387 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2388 | if ( parse < 0 ) |
| 2389 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2390 | option,arg1); |
| 2391 | if (IsGeometry(arg2) == MagickFalse) |
| 2392 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2393 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2394 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2395 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2396 | break; |
| 2397 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2398 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2399 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2400 | if (IsGeometry(arg1) == MagickFalse) |
| 2401 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2402 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2403 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2404 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2405 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2406 | geometry.height=_image->rows; |
| 2407 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2408 | break; |
| 2409 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2410 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2411 | } |
| 2412 | case 'f': |
| 2413 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2414 | if (LocaleCompare("features",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2415 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2416 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2417 | if (IfPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2418 | (void) DeleteImageArtifact(_image,"identify:features"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2419 | break; |
| 2420 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2421 | (void) SetImageArtifact(_image,"identify:features","true"); |
| 2422 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2423 | break; |
| 2424 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2425 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2426 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2427 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2428 | break; |
| 2429 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2430 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2431 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2432 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2433 | break; |
| 2434 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2435 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2436 | { |
| 2437 | PixelInfo |
| 2438 | target; |
| 2439 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2440 | if (IsGeometry(arg1) == MagickFalse) |
| 2441 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2442 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2443 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2444 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
| 2445 | geometry.y,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2446 | break; |
| 2447 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2448 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2449 | { |
| 2450 | FrameInfo |
| 2451 | frame_info; |
| 2452 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2453 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2454 | compose; |
| 2455 | |
| 2456 | const char* |
| 2457 | value; |
| 2458 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2459 | value=GetImageOption(_image_info,"compose"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2460 | if (value != (const char *) NULL) |
| 2461 | compose=(CompositeOperator) ParseCommandOption( |
| 2462 | MagickComposeOptions,MagickFalse,value); |
| 2463 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2464 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2465 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2466 | if (IsGeometry(arg1) == MagickFalse) |
| 2467 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2468 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2469 | frame_info.width=geometry.width; |
| 2470 | frame_info.height=geometry.height; |
| 2471 | if ((flags & HeightValue) == 0) |
| 2472 | frame_info.height=geometry.width; |
| 2473 | frame_info.outer_bevel=geometry.x; |
| 2474 | frame_info.inner_bevel=geometry.y; |
| 2475 | frame_info.x=(ssize_t) frame_info.width; |
| 2476 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2477 | frame_info.width=_image->columns+2*frame_info.width; |
| 2478 | frame_info.height=_image->rows+2*frame_info.height; |
| 2479 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2480 | break; |
| 2481 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2482 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2483 | { |
| 2484 | char |
| 2485 | *arguments, |
| 2486 | token[MaxTextExtent]; |
| 2487 | |
| 2488 | const char |
| 2489 | *p; |
| 2490 | |
| 2491 | double |
| 2492 | *parameters; |
| 2493 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2494 | register ssize_t |
| 2495 | x; |
| 2496 | |
| 2497 | size_t |
| 2498 | number_parameters; |
| 2499 | |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2500 | /* |
| 2501 | Function Modify Image Values |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2502 | FUTURE: code should be almost a duplicate of that is "distort" |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2503 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2504 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2505 | if ( parse < 0 ) |
| 2506 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2507 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2508 | arguments=InterpretImageProperties(_image_info,_image,arg2, |
| 2509 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2510 | if (arguments == (char *) NULL) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2511 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2512 | p=(char *) arguments; |
| 2513 | for (x=0; *p != '\0'; x++) |
| 2514 | { |
| 2515 | GetMagickToken(p,&p,token); |
| 2516 | if (*token == ',') |
| 2517 | GetMagickToken(p,&p,token); |
| 2518 | } |
| 2519 | number_parameters=(size_t) x; |
| 2520 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 2521 | sizeof(*parameters)); |
| 2522 | if (parameters == (double *) NULL) |
| 2523 | ThrowWandFatalException(ResourceLimitFatalError, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2524 | "MemoryAllocationFailed",_image->filename); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2525 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 2526 | sizeof(*parameters)); |
| 2527 | p=(char *) arguments; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2528 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2529 | GetMagickToken(p,&p,token); |
| 2530 | if (*token == ',') |
| 2531 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2532 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2533 | } |
| 2534 | arguments=DestroyString(arguments); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2535 | (void) FunctionImage(_image,(MagickFunction)parse,number_parameters, |
| 2536 | parameters,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2537 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 2538 | break; |
| 2539 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2540 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2541 | } |
| 2542 | case 'g': |
| 2543 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2544 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2545 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2546 | if (IsGeometry(arg1) == MagickFalse) |
| 2547 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2548 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2549 | (void) GammaImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2550 | _exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2551 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2552 | _image->gamma=StringToDouble(arg1,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2553 | break; |
| 2554 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2555 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 2556 | (LocaleCompare("gaussian",option+1) == 0)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2557 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2558 | if (IsGeometry(arg1) == MagickFalse) |
| 2559 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2560 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2561 | if ((flags & SigmaValue) == 0) |
| 2562 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2563 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2564 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2565 | break; |
| 2566 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2567 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2568 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2569 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2570 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2571 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2572 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2573 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2574 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2575 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2576 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2577 | if (_image->geometry != (char *) NULL) |
| 2578 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2579 | break; |
| 2580 | } |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2581 | if (IsGeometry(arg1) == MagickFalse) |
| 2582 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2583 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2584 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2585 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2586 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2587 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
| 2588 | _image->filter,_image->blur,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2589 | break; |
| 2590 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2591 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2592 | } |
| 2593 | case 'h': |
| 2594 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2595 | if (LocaleCompare("highlight-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2596 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2597 | (void) SetImageArtifact(_image,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2598 | break; |
| 2599 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2600 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2601 | } |
| 2602 | case 'i': |
| 2603 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2604 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2605 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2606 | const char |
| 2607 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2608 | *text; |
| 2609 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2610 | format=GetImageOption(_image_info,"format"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2611 | if (format == (char *) NULL) |
| 2612 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2613 | (void) IdentifyImage(_image,stdout,_image_info->verbose, |
| 2614 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2615 | break; |
| 2616 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2617 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2618 | if (text == (char *) NULL) |
| 2619 | break; |
| 2620 | (void) fputs(text,stdout); |
| 2621 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2622 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2623 | break; |
| 2624 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2625 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2626 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2627 | if (IsGeometry(arg1) == MagickFalse) |
| 2628 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2629 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2630 | new_image=ImplodeImage(_image,geometry_info.rho, |
| 2631 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2632 | break; |
| 2633 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2634 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2635 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2636 | /* FUTURE: New to IMv7 |
| 2637 | Roll into a resize special operator */ |
| 2638 | if (IsGeometry(arg1) == MagickFalse) |
| 2639 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2640 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2641 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2642 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2643 | break; |
| 2644 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2645 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2646 | } |
| 2647 | case 'l': |
| 2648 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2649 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2650 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2651 | if (IsGeometry(arg1) == MagickFalse) |
| 2652 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2653 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2654 | if ((flags & PercentValue) != 0) |
| 2655 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2656 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2657 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2658 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2659 | break; |
| 2660 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2661 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2662 | { |
| 2663 | MagickRealType |
| 2664 | black_point, |
| 2665 | gamma, |
| 2666 | white_point; |
| 2667 | |
| 2668 | MagickStatusType |
| 2669 | flags; |
| 2670 | |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2671 | if (IsGeometry(arg1) == MagickFalse) |
| 2672 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2673 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2674 | black_point=geometry_info.rho; |
| 2675 | white_point=(MagickRealType) QuantumRange; |
| 2676 | if ((flags & SigmaValue) != 0) |
| 2677 | white_point=geometry_info.sigma; |
| 2678 | gamma=1.0; |
| 2679 | if ((flags & XiValue) != 0) |
| 2680 | gamma=geometry_info.xi; |
| 2681 | if ((flags & PercentValue) != 0) |
| 2682 | { |
| 2683 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2684 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2685 | } |
| 2686 | if ((flags & SigmaValue) == 0) |
| 2687 | white_point=(MagickRealType) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2688 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2689 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2690 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2691 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2692 | break; |
| 2693 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2694 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2695 | { |
| 2696 | char |
| 2697 | token[MaxTextExtent]; |
| 2698 | |
| 2699 | const char |
| 2700 | *p; |
| 2701 | |
| 2702 | PixelInfo |
| 2703 | black_point, |
| 2704 | white_point; |
| 2705 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2706 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2707 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2708 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2709 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2710 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2711 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2712 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2713 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2714 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2715 | GetMagickToken(p,&p,token); |
| 2716 | if (*token == '\0') |
| 2717 | white_point=black_point; /* set everything to that color */ |
| 2718 | else |
| 2719 | { |
| 2720 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2721 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2722 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2723 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2724 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2725 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2726 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2727 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2728 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2729 | (void) LevelImageColors(_image,&black_point,&white_point, |
| 2730 | plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2731 | break; |
| 2732 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2733 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2734 | { |
| 2735 | double |
| 2736 | black_point, |
| 2737 | white_point; |
| 2738 | |
| 2739 | MagickStatusType |
| 2740 | flags; |
| 2741 | |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2742 | if (IsGeometry(arg1) == MagickFalse) |
| 2743 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2744 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2745 | black_point=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2746 | white_point=(MagickRealType) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2747 | if ((flags & SigmaValue) != 0) |
| 2748 | white_point=geometry_info.sigma; |
| 2749 | if ((flags & PercentValue) != 0) |
| 2750 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2751 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2752 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2753 | } |
| 2754 | if ((flags & SigmaValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2755 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2756 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2757 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2758 | break; |
| 2759 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2760 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2761 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2762 | /* FUTURE: Roll into a resize special operator */ |
| 2763 | if (IsGeometry(arg1) == MagickFalse) |
| 2764 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2765 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2766 | if ((flags & XValue) == 0) |
| 2767 | geometry.x=1; |
| 2768 | if ((flags & YValue) == 0) |
| 2769 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2770 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2771 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2772 | break; |
| 2773 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2774 | if (LocaleCompare("lowlight-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2775 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2776 | (void) SetImageArtifact(_image,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2777 | break; |
| 2778 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2779 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2780 | } |
| 2781 | case 'm': |
| 2782 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2783 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2784 | { |
| 2785 | Image |
| 2786 | *remap_image; |
| 2787 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2788 | /* DEPRECIATED use -remap */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2789 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2790 | if (remap_image == (Image *) NULL) |
| 2791 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2792 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2793 | remap_image=DestroyImage(remap_image); |
| 2794 | break; |
| 2795 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2796 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2797 | { |
| 2798 | Image |
| 2799 | *mask; |
| 2800 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2801 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2802 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2803 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2804 | break; |
| 2805 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2806 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2807 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2808 | if (mask == (Image *) NULL) |
| 2809 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2810 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2811 | mask=DestroyImage(mask); |
| 2812 | break; |
| 2813 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2814 | if (LocaleCompare("matte",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2815 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2816 | /* DEPRECIATED */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2817 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2818 | DeactivateAlphaChannel, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2819 | break; |
| 2820 | } |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2821 | if (LocaleCompare("median",option+1) == 0) |
| 2822 | { |
| 2823 | /* DEPRECIATED - use -statistic Median */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2824 | if (IsGeometry(arg1) == MagickFalse) |
| 2825 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2826 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2827 | break; |
| 2828 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2829 | if (LocaleCompare("mode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2830 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2831 | if (IsGeometry(arg1) == MagickFalse) |
| 2832 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2833 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2834 | if ((flags & SigmaValue) == 0) |
| 2835 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2836 | new_image=StatisticImage(_image,ModeStatistic,(size_t) |
| 2837 | geometry_info.rho,(size_t) geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2838 | break; |
| 2839 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2840 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2841 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2842 | if (IsGeometry(arg1) == MagickFalse) |
| 2843 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2844 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2845 | break; |
| 2846 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2847 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2848 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2849 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2850 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2851 | break; |
| 2852 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2853 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2854 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2855 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2856 | break; |
| 2857 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2858 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2859 | { |
| 2860 | char |
| 2861 | token[MaxTextExtent]; |
| 2862 | |
| 2863 | const char |
| 2864 | *p; |
| 2865 | |
| 2866 | KernelInfo |
| 2867 | *kernel; |
| 2868 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2869 | ssize_t |
| 2870 | iterations; |
| 2871 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2872 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2873 | GetMagickToken(p,&p,token); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2874 | parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
| 2875 | if ( parse < 0 ) |
| 2876 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2877 | option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2878 | iterations=1L; |
| 2879 | GetMagickToken(p,&p,token); |
| 2880 | if ((*p == ':') || (*p == ',')) |
| 2881 | GetMagickToken(p,&p,token); |
| 2882 | if ((*p != '\0')) |
| 2883 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2884 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2885 | if (kernel == (KernelInfo *) NULL) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2886 | CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel", |
| 2887 | option,arg2); |
| 2888 | new_image=MorphologyImage(_image,(MorphologyMethod)parse, |
| 2889 | iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2890 | kernel=DestroyKernelInfo(kernel); |
| 2891 | break; |
| 2892 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2893 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2894 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2895 | if (IsGeometry(arg1) == MagickFalse) |
| 2896 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2897 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2898 | if ((flags & SigmaValue) == 0) |
| 2899 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2900 | new_image=MotionBlurImage(_image,geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2901 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2902 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2903 | break; |
| 2904 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2905 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2906 | } |
| 2907 | case 'n': |
| 2908 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2909 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2910 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2911 | (void) NegateImage(_image, plus_alt_op, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2912 | break; |
| 2913 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2914 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2915 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2916 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2917 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2918 | if (IsGeometry(arg1) == MagickFalse) |
| 2919 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2920 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2921 | if ((flags & SigmaValue) == 0) |
| 2922 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2923 | new_image=StatisticImage(_image,NonpeakStatistic,(size_t) |
| 2924 | geometry_info.rho,(size_t) geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2925 | } |
| 2926 | else |
| 2927 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2928 | double |
| 2929 | attenuate; |
| 2930 | |
| 2931 | const char* |
| 2932 | value; |
| 2933 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2934 | parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1); |
| 2935 | if ( parse < 0 ) |
| 2936 | CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType", |
| 2937 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2938 | value=GetImageOption(_image_info,"attenuate"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2939 | if (value != (const char *) NULL) |
| 2940 | attenuate=StringToDouble(value,(char **) NULL); |
| 2941 | else |
| 2942 | attenuate=1.0; |
| 2943 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2944 | new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate, |
| 2945 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2946 | } |
| 2947 | break; |
| 2948 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2949 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2950 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2951 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2952 | break; |
| 2953 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2954 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2955 | } |
| 2956 | case 'o': |
| 2957 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2958 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2959 | { |
| 2960 | PixelInfo |
| 2961 | target; |
| 2962 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2963 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 2964 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,plus_alt_op, |
| 2965 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2966 | break; |
| 2967 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2968 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2969 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2970 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2971 | break; |
| 2972 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2973 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2974 | } |
| 2975 | case 'p': |
| 2976 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2977 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2978 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2979 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2980 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2981 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2982 | break; |
| 2983 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2984 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2985 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2986 | const char |
| 2987 | *caption; |
| 2988 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2989 | double |
| 2990 | angle; |
| 2991 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 2992 | if (IfPlusOp) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2993 | RandomInfo |
| 2994 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2995 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2996 | random_info=AcquireRandomInfo(); |
| 2997 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2998 | random_info=DestroyRandomInfo(random_info); |
| 2999 | } |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 3000 | else { |
| 3001 | if (IsGeometry(arg1) == MagickFalse) |
| 3002 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option |
| 3003 | ,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3004 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3005 | angle=geometry_info.rho; |
| 3006 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3007 | caption=GetImageProperty(_image,"caption",_exception); |
| 3008 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 3009 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3010 | break; |
| 3011 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3012 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3013 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 3014 | if (IsGeometry(arg1) == MagickFalse) |
| 3015 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3016 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3017 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
| 3018 | _quantize_info->dither,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3019 | break; |
| 3020 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3021 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3022 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3023 | /* FUTURE: should be a 'Genesis' option? |
| 3024 | Option however is also in WandSettingOptionInfo() |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 3025 | Why??? |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 3026 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 3027 | parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1); |
| 3028 | if ( parse < 0 ) |
| 3029 | CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType", |
| 3030 | option,arg1); |
| 3031 | new_image=PreviewImage(_image,(PreviewType)parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3032 | break; |
| 3033 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3034 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3035 | { |
| 3036 | const char |
| 3037 | *name; |
| 3038 | |
| 3039 | const StringInfo |
| 3040 | *profile; |
| 3041 | |
| 3042 | Image |
| 3043 | *profile_image; |
| 3044 | |
| 3045 | ImageInfo |
| 3046 | *profile_info; |
| 3047 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3048 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3049 | { /* Remove a profile from the _image. */ |
| 3050 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 3051 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3052 | break; |
| 3053 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3054 | /* Associate a profile with the _image. */ |
| 3055 | profile_info=CloneImageInfo(_image_info); |
| 3056 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3057 | if (profile != (StringInfo *) NULL) |
| 3058 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3059 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3060 | profile_info=DestroyImageInfo(profile_info); |
| 3061 | if (profile_image == (Image *) NULL) |
| 3062 | { |
| 3063 | StringInfo |
| 3064 | *profile; |
| 3065 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3066 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3067 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3068 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3069 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3070 | if (profile != (StringInfo *) NULL) |
| 3071 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3072 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3073 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3074 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3075 | profile=DestroyStringInfo(profile); |
| 3076 | } |
| 3077 | profile_info=DestroyImageInfo(profile_info); |
| 3078 | break; |
| 3079 | } |
| 3080 | ResetImageProfileIterator(profile_image); |
| 3081 | name=GetNextImageProfile(profile_image); |
| 3082 | while (name != (const char *) NULL) |
| 3083 | { |
| 3084 | profile=GetImageProfile(profile_image,name); |
| 3085 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3086 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 3087 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3088 | name=GetNextImageProfile(profile_image); |
| 3089 | } |
| 3090 | profile_image=DestroyImage(profile_image); |
| 3091 | break; |
| 3092 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3093 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3094 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3095 | case 'r': |
| 3096 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3097 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3098 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3099 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3100 | new_image=RadialBlurImage(_image,geometry_info.rho, |
| 3101 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3102 | break; |
| 3103 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3104 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3105 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3106 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3107 | if ((flags & SigmaValue) == 0) |
| 3108 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3109 | (void) RaiseImage(_image,&geometry,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3110 | break; |
| 3111 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3112 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3113 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3114 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3115 | break; |
| 3116 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3117 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3118 | { |
| 3119 | Image |
| 3120 | *remap_image; |
| 3121 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3122 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3123 | if (remap_image == (Image *) NULL) |
| 3124 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3125 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3126 | remap_image=DestroyImage(remap_image); |
| 3127 | break; |
| 3128 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3129 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3130 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3131 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3132 | (void) ResetImagePage(_image,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3133 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3134 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3135 | break; |
| 3136 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3137 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3138 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3139 | /* FUTURE: remove blur arguemnt - no longer used */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3140 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3141 | if ((flags & SigmaValue) == 0) |
| 3142 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3143 | new_image=ResampleImage(_image,geometry_info.rho, |
| 3144 | geometry_info.sigma,_image->filter,_image->blur,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3145 | break; |
| 3146 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3147 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3148 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 3149 | /* FUTURE: remove blur argument - no longer used */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3150 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3151 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
| 3152 | _image->filter,_image->blur,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3153 | break; |
| 3154 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3155 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3156 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3157 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3158 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3159 | break; |
| 3160 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3161 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3162 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3163 | if (strchr(arg1,'>') != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3164 | if (_image->columns <= _image->rows) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3165 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3166 | if (strchr(arg1,'<') != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3167 | if (_image->columns >= _image->rows) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3168 | break; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 3169 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3170 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3171 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3172 | break; |
| 3173 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3174 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3175 | } |
| 3176 | case 's': |
| 3177 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3178 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3179 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3180 | /* FUTURE: Roll into a resize special operator */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3181 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3182 | new_image=SampleImage(_image,geometry.width,geometry.height, |
| 3183 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3184 | break; |
| 3185 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3186 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3187 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3188 | /* FUTURE: Roll into a resize special operator */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3189 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3190 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3191 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3192 | break; |
| 3193 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3194 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3195 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3196 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3197 | if ((flags & PercentValue) != 0) |
| 3198 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3199 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
| 3200 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3201 | break; |
| 3202 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3203 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3204 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3205 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3206 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3207 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3208 | break; |
| 3209 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3210 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3211 | { |
| 3212 | double |
| 3213 | threshold; |
| 3214 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3215 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3216 | new_image=SepiaToneImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3217 | break; |
| 3218 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3219 | if (LocaleCompare("segment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3220 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3221 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3222 | if ((flags & SigmaValue) == 0) |
| 3223 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3224 | (void) SegmentImage(_image,_image->colorspace, |
| 3225 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3226 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3227 | break; |
| 3228 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3229 | if (LocaleCompare("set",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3230 | { |
| 3231 | char |
| 3232 | *value; |
| 3233 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3234 | if (IfPlusOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3235 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3236 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3237 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3238 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3239 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3240 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3241 | (void) DeleteImageOption(_image_info,arg1+7); |
| 3242 | (void) DeleteImageArtifact(_image,arg1+7); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3243 | } |
| 3244 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3245 | (void) DeleteImageProperty(_image,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3246 | break; |
| 3247 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3248 | value=InterpretImageProperties(_image_info,_image,arg2, |
| 3249 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3250 | if (value == (char *) NULL) |
| 3251 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3252 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3253 | (void) SetImageRegistry(StringRegistryType,arg1+9,value, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3254 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3255 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3256 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3257 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3258 | (void) SetImageOption(_image_info,arg1+7,value); |
| 3259 | (void) SetImageArtifact(_image,arg1+7,value); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3260 | } |
| 3261 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3262 | (void) SetImageProperty(_image,arg1,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3263 | value=DestroyString(value); |
| 3264 | break; |
| 3265 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3266 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3267 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3268 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3269 | if ((flags & SigmaValue) == 0) |
| 3270 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3271 | new_image=ShadeImage(_image,normal_op,geometry_info.rho, |
| 3272 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3273 | break; |
| 3274 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3275 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3276 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3277 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3278 | if ((flags & SigmaValue) == 0) |
| 3279 | geometry_info.sigma=1.0; |
| 3280 | if ((flags & XiValue) == 0) |
| 3281 | geometry_info.xi=4.0; |
| 3282 | if ((flags & PsiValue) == 0) |
| 3283 | geometry_info.psi=4.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3284 | new_image=ShadowImage(_image,geometry_info.rho, |
| 3285 | geometry_info.sigma,_image->bias,(ssize_t) |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 3286 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3287 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3288 | break; |
| 3289 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3290 | if (LocaleCompare("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3291 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3292 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3293 | if ((flags & SigmaValue) == 0) |
| 3294 | geometry_info.sigma=1.0; |
| 3295 | if ((flags & XiValue) == 0) |
| 3296 | geometry_info.xi=0.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3297 | new_image=SharpenImage(_image,geometry_info.rho, |
| 3298 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3299 | break; |
| 3300 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3301 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3302 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3303 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3304 | new_image=ShaveImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3305 | break; |
| 3306 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3307 | if (LocaleCompare("shear",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3308 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3309 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3310 | if ((flags & SigmaValue) == 0) |
| 3311 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3312 | new_image=ShearImage(_image,geometry_info.rho, |
| 3313 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3314 | break; |
| 3315 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3316 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3317 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3318 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3319 | if ((flags & SigmaValue) == 0) |
| 3320 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3321 | if ((flags & PercentValue) != 0) |
| 3322 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3323 | 100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3324 | (void) SigmoidalContrastImage(_image,normal_op,geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3325 | geometry_info.sigma, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3326 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3327 | break; |
| 3328 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3329 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3330 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3331 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3332 | if ((flags & SigmaValue) == 0) |
| 3333 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3334 | new_image=SketchImage(_image,geometry_info.rho, |
| 3335 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3336 | break; |
| 3337 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3338 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3339 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3340 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3341 | QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3342 | break; |
| 3343 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3344 | if (LocaleCompare("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3345 | { |
| 3346 | SparseColorMethod |
| 3347 | method; |
| 3348 | |
| 3349 | char |
| 3350 | *arguments; |
| 3351 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3352 | method=(SparseColorMethod) ParseCommandOption( |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3353 | MagickSparseColorOptions,MagickFalse,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3354 | arguments=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3355 | if (arguments == (char *) NULL) |
| 3356 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3357 | new_image=SparseColorOption(_image,method,arguments,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3358 | arguments=DestroyString(arguments); |
| 3359 | break; |
| 3360 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3361 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3362 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3363 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 3364 | new_image=SpliceImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3365 | break; |
| 3366 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3367 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3368 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3369 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3370 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3371 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3372 | break; |
| 3373 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3374 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3375 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 3376 | parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1); |
| 3377 | if ( parse < 0 ) |
| 3378 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 3379 | option,arg1); |
| 3380 | if (IsGeometry(arg2) == MagickFalse) |
| 3381 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3382 | (void) ParseGeometry(arg2,&geometry_info); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 3383 | new_image=StatisticImage(_image,(StatisticType)parse, |
| 3384 | (size_t) geometry_info.rho,(size_t) geometry_info.sigma, |
| 3385 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3386 | break; |
| 3387 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3388 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3389 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3390 | (void) StripImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3391 | break; |
| 3392 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3393 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3394 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3395 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3396 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3397 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3398 | break; |
| 3399 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3400 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3401 | } |
| 3402 | case 't': |
| 3403 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3404 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3405 | { |
| 3406 | double |
| 3407 | threshold; |
| 3408 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3409 | if (!normal_op) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3410 | threshold=(double) QuantumRange/2; |
| 3411 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3412 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3413 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3414 | break; |
| 3415 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3416 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3417 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3418 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3419 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3420 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3421 | break; |
| 3422 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3423 | if (LocaleCompare("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3424 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3425 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3426 | break; |
| 3427 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3428 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3429 | { |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 3430 | /* DEPRECIATED -- should really use Distort AffineProjection */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3431 | new_image=AffineTransformImage(_image,&_draw_info->affine, |
| 3432 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3433 | break; |
| 3434 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3435 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3436 | { |
| 3437 | PixelInfo |
| 3438 | target; |
| 3439 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3440 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3441 | (void) TransparentPaintImage(_image,&target,(Quantum) |
| 3442 | TransparentAlpha,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3443 | break; |
| 3444 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3445 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3446 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3447 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3448 | break; |
| 3449 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3450 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3451 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3452 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3453 | break; |
| 3454 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3455 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3456 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3457 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3458 | break; |
| 3459 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3460 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3461 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3462 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3463 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3464 | break; |
| 3465 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3466 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3467 | } |
| 3468 | case 'u': |
| 3469 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3470 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3471 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3472 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 3473 | /* FUTURE: This option is not documented!!!!! */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3474 | if (!normal_op) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3475 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3476 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3477 | break; |
| 3478 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3479 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3480 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3481 | break; |
| 3482 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3483 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3484 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3485 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3486 | break; |
| 3487 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3488 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3489 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3490 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3491 | if ((flags & SigmaValue) == 0) |
| 3492 | geometry_info.sigma=1.0; |
| 3493 | if ((flags & XiValue) == 0) |
| 3494 | geometry_info.xi=1.0; |
| 3495 | if ((flags & PsiValue) == 0) |
| 3496 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3497 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
| 3498 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3499 | break; |
| 3500 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3501 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3502 | } |
| 3503 | case 'v': |
| 3504 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3505 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3506 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3507 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3508 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3509 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3510 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3511 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3512 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3513 | break; |
| 3514 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3515 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3516 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3517 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3518 | if ((flags & SigmaValue) == 0) |
| 3519 | geometry_info.sigma=1.0; |
| 3520 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3521 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3522 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3523 | geometry_info.psi=0.1*_image->rows; |
| 3524 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3525 | _image->bias,(ssize_t) ceil(geometry_info.xi-0.5), |
| 3526 | (ssize_t) ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3527 | break; |
| 3528 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3529 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3530 | } |
| 3531 | case 'w': |
| 3532 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3533 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3534 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3535 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3536 | if ((flags & SigmaValue) == 0) |
| 3537 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3538 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3539 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3540 | break; |
| 3541 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3542 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3543 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3544 | (void) WhiteThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3545 | break; |
| 3546 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3547 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3548 | } |
| 3549 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3550 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3551 | } |
| 3552 | /* |
| 3553 | Replace current image with any image that was generated |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3554 | and set image point to last image (so image->next is correct) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3555 | */ |
| 3556 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3557 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3558 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3559 | return; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3560 | #undef _image_info |
| 3561 | #undef _draw_info |
| 3562 | #undef _quantize_info |
| 3563 | #undef _image |
| 3564 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3565 | #undef IfNormalOp |
| 3566 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3567 | #undef normal_op |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3568 | #undef plus_alt_op |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3569 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3570 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3571 | WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3572 | const char *option, const char *arg1, const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3573 | { |
| 3574 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3575 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3576 | i; |
| 3577 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3578 | assert(cli_wand != (MagickCLI *) NULL); |
| 3579 | assert(cli_wand->signature == WandSignature); |
| 3580 | assert(cli_wand->wand.signature == WandSignature); |
| 3581 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
| 3582 | if (cli_wand->wand.debug != MagickFalse) |
| 3583 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3584 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3585 | #if !USE_WAND_METHODS |
| 3586 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3587 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3588 | n=GetImageListLength(cli_wand->wand.images); |
| 3589 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3590 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3591 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3592 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3593 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3594 | break; |
| 3595 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3596 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3597 | assert( i == n ); |
| 3598 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3599 | #else |
| 3600 | MagickResetIterator(&cli_wand->wand); |
| 3601 | while ( MagickNextImage(&cli_wand->wand) != MagickFalse ) |
| 3602 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3603 | MagickResetIterator(&cli_wand->wand); |
| 3604 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3605 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3606 | } |
| 3607 | |
| 3608 | /* |
| 3609 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3610 | % % |
| 3611 | % % |
| 3612 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3613 | + C L I L i s t O p e r a t o r I m a g e s % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3614 | % % |
| 3615 | % % |
| 3616 | % % |
| 3617 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3618 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3619 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3620 | % entire image list as a whole. The result is often a complete replacment |
| 3621 | % of the image list with a completely new list, or just a single image. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3622 | % |
| 3623 | % The format of the MogrifyImage method is: |
| 3624 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3625 | % void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3626 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3627 | % |
| 3628 | % A description of each parameter follows: |
| 3629 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3630 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3631 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3632 | % o option: The option string for the operation |
| 3633 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3634 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3635 | % |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3636 | % NOTE: only "limit" uses two arguments. |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3637 | % |
| 3638 | % Example usage... |
| 3639 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3640 | % CLIListOperatorImages(cli_wand,MagickFalse,"-duplicate", "3", NULL); |
| 3641 | % CLIListOperatorImages(cli_wand,MagickTrue, "+append", NULL, NULL); |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3642 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 3643 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3644 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3645 | % cli_wand |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3646 | % argc,argv |
| 3647 | % i=index in argv |
| 3648 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 3649 | % option_info = GetCommandOptionInfo(argv[i]); |
| 3650 | % count=option_info->type; |
| 3651 | % option_type=option_info->flags; |
| 3652 | % |
| 3653 | % if ( (option_type & ListOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3654 | % CLIListOperatorImages(cli_wand,argv[i], |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3655 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 3656 | % count>=2 ? argv[i+2] : (char *)NULL ); |
| 3657 | % i += count+1; |
| 3658 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3659 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3660 | WandExport void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3661 | const char *option,const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3662 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3663 | ssize_t |
| 3664 | parse; |
| 3665 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3666 | Image |
| 3667 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3668 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3669 | #define _image_info (cli_wand->wand.image_info) |
| 3670 | #define _images (cli_wand->wand.images) |
| 3671 | #define _exception (cli_wand->wand.exception) |
| 3672 | #define _draw_info (cli_wand->draw_info) |
| 3673 | #define _quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3674 | #define IfNormalOp (*option=='-') |
| 3675 | #define IfPlusOp (*option!='-') |
| 3676 | #define normal_op (IfNormalOp?MagickTrue:MagickFalse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3677 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3678 | assert(cli_wand != (MagickCLI *) NULL); |
| 3679 | assert(cli_wand->signature == WandSignature); |
| 3680 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3681 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3682 | if (cli_wand->wand.debug != MagickFalse) |
| 3683 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3684 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3685 | (void) SyncImagesSettings(_image_info,_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3686 | |
| 3687 | new_images=NewImageList(); |
| 3688 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3689 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3690 | { |
| 3691 | case 'a': |
| 3692 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3693 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3694 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3695 | new_images=AppendImages(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3696 | break; |
| 3697 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3698 | if (LocaleCompare("average",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3699 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3700 | /* DEPRECIATED - use -evaluate-sequence Mean */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3701 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3702 | break; |
| 3703 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3704 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3705 | } |
| 3706 | case 'c': |
| 3707 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3708 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3709 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3710 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3711 | break; |
| 3712 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3713 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3714 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3715 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3716 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3717 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3718 | /* FUTURE - make this a compose option, and thus can be used |
| 3719 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3720 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3721 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3722 | new_images=RemoveFirstImageFromList(&_images); |
| 3723 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3724 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3725 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3726 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3727 | (void) ClutImage(new_images,clut_image,_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3728 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3729 | break; |
| 3730 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3731 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3732 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3733 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3734 | break; |
| 3735 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3736 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3737 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3738 | /* FUTURE - this may be replaced by a 'channel' method */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3739 | new_images=CombineImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3740 | break; |
| 3741 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3742 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3743 | { |
| 3744 | Image |
| 3745 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3746 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3747 | |
| 3748 | RectangleInfo |
| 3749 | geometry; |
| 3750 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3751 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3752 | compose; |
| 3753 | |
| 3754 | const char* |
| 3755 | value; |
| 3756 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3757 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3758 | if (value != (const char *) NULL) |
| 3759 | compose=(CompositeOperator) ParseCommandOption( |
| 3760 | MagickComposeOptions,MagickFalse,value); |
| 3761 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3762 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3763 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3764 | new_images=RemoveFirstImageFromList(&_images); |
| 3765 | source_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3766 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3767 | if (source_image == (Image *) NULL) |
| 3768 | break; |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3769 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3770 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3771 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3772 | source_image->geometry,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3773 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3774 | SetGeometry(source_image,&geometry); |
| 3775 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3776 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
| 3777 | new_images->gravity, &geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3778 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3779 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3780 | if (mask_image != (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3781 | { /* handle a third write mask image */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3782 | if ((compose == DisplaceCompositeOp) || |
| 3783 | (compose == DistortCompositeOp)) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3784 | { /* Merge Y displacement into X displace/distort map. */ |
| 3785 | (void) CompositeImage(source_image,CopyGreenCompositeOp, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3786 | mask_image,0,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3787 | mask_image=DestroyImage(mask_image); |
| 3788 | } |
| 3789 | else |
| 3790 | { |
| 3791 | /* |
| 3792 | Set a blending mask for the composition. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3793 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3794 | (void) NegateImage(mask_image,MagickFalse,_exception); |
| 3795 | (void) SetImageMask(new_images,mask_image,_exception); |
cristy | 1539afd | 2012-01-30 01:32:59 +0000 | [diff] [blame] | 3796 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3797 | } |
| 3798 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3799 | (void) CompositeImage(new_images,compose,source_image,geometry.x, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3800 | geometry.y,_exception); |
| 3801 | (void) SetImageMask(new_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3802 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3803 | break; |
| 3804 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3805 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3806 | } |
| 3807 | case 'd': |
| 3808 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3809 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3810 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3811 | /* DEPRECIATED - use -layers CompareAny */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3812 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3813 | break; |
| 3814 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3815 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3816 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3817 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3818 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3819 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3820 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3821 | break; |
| 3822 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3823 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3824 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3825 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3826 | { |
| 3827 | const char |
| 3828 | *p; |
| 3829 | |
| 3830 | size_t |
| 3831 | number_duplicates; |
| 3832 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3833 | if (IsGeometry(arg1) == MagickFalse) |
| 3834 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3835 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3836 | number_duplicates=(size_t) StringToLong(arg1); |
| 3837 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3838 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3839 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3840 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3841 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3842 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3843 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3844 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3845 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3846 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3847 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3848 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3849 | break; |
| 3850 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3851 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3852 | } |
| 3853 | case 'e': |
| 3854 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3855 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3856 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3857 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3858 | if ( parse < 0 ) |
| 3859 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3860 | option,arg1); |
| 3861 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
| 3862 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3863 | break; |
| 3864 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3865 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3866 | } |
| 3867 | case 'f': |
| 3868 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3869 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3870 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3871 | new_images=ForwardFourierTransformImage(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3872 | break; |
| 3873 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3874 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3875 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3876 | /* REDIRECTED to use -layers flatten instead */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3877 | CLIListOperatorImages(cli_wand,"-layer",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3878 | break; |
| 3879 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3880 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3881 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3882 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3883 | break; |
| 3884 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3885 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3886 | } |
| 3887 | case 'h': |
| 3888 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3889 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3890 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3891 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3892 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3893 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3894 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3895 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3896 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3897 | new_images=RemoveFirstImageFromList(&_images); |
| 3898 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3899 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3900 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3901 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3902 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3903 | break; |
| 3904 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3905 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3906 | } |
| 3907 | case 'i': |
| 3908 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3909 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3910 | { |
| 3911 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3912 | *magnitude_image, |
| 3913 | *phase_image; |
| 3914 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3915 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3916 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3917 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3918 | if (phase_image == (Image *) NULL) |
| 3919 | break; |
| 3920 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3921 | normal_op,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3922 | magnitude_image=DestroyImage(magnitude_image); |
| 3923 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3924 | break; |
| 3925 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3926 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3927 | { |
| 3928 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3929 | *insert_image, |
| 3930 | *index_image; |
| 3931 | |
| 3932 | ssize_t |
| 3933 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3934 | |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3935 | if (IfNormalOp && IsGeometry(arg1) == MagickFalse) |
| 3936 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3937 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3938 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3939 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3940 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3941 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3942 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3943 | PrependImageToList(&_images,insert_image); |
| 3944 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3945 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3946 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3947 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3948 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3949 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3950 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3951 | InsertImageInList(&index_image,insert_image); |
| 3952 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3953 | _images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3954 | break; |
| 3955 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3956 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3957 | } |
| 3958 | case 'l': |
| 3959 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3960 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3961 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3962 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3963 | if ( parse < 0 ) |
| 3964 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3965 | option,arg1); |
| 3966 | switch ((ImageLayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3967 | { |
| 3968 | case CoalesceLayer: |
| 3969 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3970 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3971 | break; |
| 3972 | } |
| 3973 | case CompareAnyLayer: |
| 3974 | case CompareClearLayer: |
| 3975 | case CompareOverlayLayer: |
| 3976 | default: |
| 3977 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3978 | new_images=CompareImagesLayers(_images,(ImageLayerMethod) parse, |
| 3979 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3980 | break; |
| 3981 | } |
| 3982 | case MergeLayer: |
| 3983 | case FlattenLayer: |
| 3984 | case MosaicLayer: |
| 3985 | case TrimBoundsLayer: |
| 3986 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3987 | new_images=MergeImageLayers(_images,(ImageLayerMethod) parse, |
| 3988 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3989 | break; |
| 3990 | } |
| 3991 | case DisposeLayer: |
| 3992 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3993 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3994 | break; |
| 3995 | } |
| 3996 | case OptimizeImageLayer: |
| 3997 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3998 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3999 | break; |
| 4000 | } |
| 4001 | case OptimizePlusLayer: |
| 4002 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4003 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4004 | break; |
| 4005 | } |
| 4006 | case OptimizeTransLayer: |
| 4007 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4008 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4009 | break; |
| 4010 | } |
| 4011 | case RemoveDupsLayer: |
| 4012 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4013 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4014 | break; |
| 4015 | } |
| 4016 | case RemoveZeroLayer: |
| 4017 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4018 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4019 | break; |
| 4020 | } |
| 4021 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4022 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4023 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4024 | if (new_images == (Image *) NULL) |
| 4025 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4026 | _images=DestroyImageList(_images); |
| 4027 | _images=OptimizeImageLayers(new_images,_exception); |
| 4028 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4029 | break; |
| 4030 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4031 | OptimizeImageTransparency(_images,_exception); |
| 4032 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 4033 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4034 | break; |
| 4035 | } |
| 4036 | case CompositeLayer: |
| 4037 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4038 | Image |
| 4039 | *source; |
| 4040 | |
| 4041 | RectangleInfo |
| 4042 | geometry; |
| 4043 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4044 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4045 | compose; |
| 4046 | |
| 4047 | const char* |
| 4048 | value; |
| 4049 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4050 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4051 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4052 | if (value != (const char *) NULL) |
| 4053 | compose=(CompositeOperator) ParseCommandOption( |
| 4054 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4055 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4056 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4057 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4058 | while (source != (Image *) NULL) |
| 4059 | { |
| 4060 | source=GetNextImageInList(source); |
| 4061 | if ((source != (Image *) NULL) && |
| 4062 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 4063 | break; |
| 4064 | } |
| 4065 | if (source != (Image *) NULL) |
| 4066 | { |
| 4067 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 4068 | (GetNextImageInList(source) == (Image *) NULL)) |
| 4069 | source=(Image *) NULL; |
| 4070 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4071 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4072 | source=SplitImageList(source->previous); |
| 4073 | DeleteImageFromList(&source); |
| 4074 | } |
| 4075 | } |
| 4076 | if (source == (Image *) NULL) |
| 4077 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4078 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4079 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4080 | break; |
| 4081 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4082 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4083 | SetGeometry(_images,&geometry); |
| 4084 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4085 | geometry.width=source->page.width != 0 ? |
| 4086 | source->page.width : source->columns; |
| 4087 | geometry.height=source->page.height != 0 ? |
| 4088 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4089 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 4090 | _images->page.width : _images->columns, |
| 4091 | _images->page.height != 0 ? _images->page.height : |
| 4092 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4093 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4094 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4095 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 4096 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4097 | source=DestroyImageList(source); |
| 4098 | break; |
| 4099 | } |
| 4100 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4101 | break; |
| 4102 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4103 | if (LocaleCompare("limit",option+1) == 0) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 4104 | { |
| 4105 | MagickSizeType |
| 4106 | limit; |
| 4107 | |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 4108 | limit=MagickResourceInfinity; |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 4109 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 4110 | if ( parse < 0 ) |
| 4111 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 4112 | option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4113 | if (LocaleCompare("unlimited",arg2) != 0) |
| 4114 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 4115 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 4116 | break; |
| 4117 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4118 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4119 | } |
| 4120 | case 'm': |
| 4121 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4122 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4123 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4124 | /* DEPRECIATED use +remap */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4125 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4126 | break; |
| 4127 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4128 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4129 | { |
| 4130 | Image |
| 4131 | *morph_image; |
| 4132 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame^] | 4133 | if (IsGeometry(arg1) == MagickFalse) |
| 4134 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4135 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4136 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4137 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4138 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4139 | _images=DestroyImageList(_images); |
| 4140 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4141 | break; |
| 4142 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4143 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4144 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4145 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4146 | CLIListOperatorImages(cli_wand,"-layer",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4147 | break; |
| 4148 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4149 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4150 | } |
| 4151 | case 'p': |
| 4152 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4153 | if (LocaleCompare("print",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4154 | { |
| 4155 | char |
| 4156 | *string; |
| 4157 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4158 | string=InterpretImageProperties(_image_info,_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4159 | if (string == (char *) NULL) |
| 4160 | break; |
| 4161 | (void) FormatLocaleFile(stdout,"%s",string); |
| 4162 | string=DestroyString(string); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4163 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4164 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4165 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4166 | { |
| 4167 | char |
| 4168 | **arguments; |
| 4169 | |
| 4170 | int |
| 4171 | j, |
| 4172 | number_arguments; |
| 4173 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4174 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4175 | if (arguments == (char **) NULL) |
| 4176 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4177 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4178 | { |
| 4179 | char |
| 4180 | breaker, |
| 4181 | quote, |
| 4182 | *token; |
| 4183 | |
| 4184 | const char |
| 4185 | *arguments; |
| 4186 | |
| 4187 | int |
| 4188 | next, |
| 4189 | status; |
| 4190 | |
| 4191 | size_t |
| 4192 | length; |
| 4193 | |
| 4194 | TokenInfo |
| 4195 | *token_info; |
| 4196 | |
| 4197 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4198 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4199 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4200 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4201 | token=(char *) NULL; |
| 4202 | if (~length >= (MaxTextExtent-1)) |
| 4203 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4204 | sizeof(*token)); |
| 4205 | if (token == (char *) NULL) |
| 4206 | break; |
| 4207 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4208 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4209 | token_info=AcquireTokenInfo(); |
| 4210 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4211 | "\"",'\0',&breaker,&next,"e); |
| 4212 | token_info=DestroyTokenInfo(token_info); |
| 4213 | if (status == 0) |
| 4214 | { |
| 4215 | const char |
| 4216 | *argv; |
| 4217 | |
| 4218 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4219 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4220 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4221 | } |
| 4222 | token=DestroyString(token); |
| 4223 | break; |
| 4224 | } |
| 4225 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4226 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4227 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4228 | for (j=0; j < number_arguments; j++) |
| 4229 | arguments[j]=DestroyString(arguments[j]); |
| 4230 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4231 | break; |
| 4232 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4233 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4234 | } |
| 4235 | case 'r': |
| 4236 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4237 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4238 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4239 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
| 4240 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4241 | break; |
| 4242 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4243 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4244 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4245 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4246 | break; |
| 4247 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4248 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4249 | } |
| 4250 | case 's': |
| 4251 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4252 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4253 | { |
| 4254 | Image |
| 4255 | *smush_image; |
| 4256 | |
| 4257 | ssize_t |
| 4258 | offset; |
| 4259 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4260 | offset=(ssize_t) StringToLong(arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4261 | smush_image=SmushImages(_images,normal_op,offset,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4262 | if (smush_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4263 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4264 | _images=DestroyImageList(_images); |
| 4265 | _images=smush_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4266 | break; |
| 4267 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4268 | if (LocaleCompare("swap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4269 | { |
| 4270 | Image |
| 4271 | *p, |
| 4272 | *q, |
| 4273 | *swap; |
| 4274 | |
| 4275 | ssize_t |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4276 | index, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4277 | swap_index; |
| 4278 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4279 | index=-1; |
| 4280 | swap_index=-2; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4281 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4282 | { |
| 4283 | GeometryInfo |
| 4284 | geometry_info; |
| 4285 | |
| 4286 | MagickStatusType |
| 4287 | flags; |
| 4288 | |
| 4289 | swap_index=(-1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4290 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4291 | index=(ssize_t) geometry_info.rho; |
| 4292 | if ((flags & SigmaValue) != 0) |
| 4293 | swap_index=(ssize_t) geometry_info.sigma; |
| 4294 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4295 | p=GetImageFromList(_images,index); |
| 4296 | q=GetImageFromList(_images,swap_index); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4297 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 4298 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4299 | (void) ThrowMagickException(_exception,GetMagickModule(), |
| 4300 | OptionError,"NoSuchImage","'%s'",_images->filename); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4301 | break; |
| 4302 | } |
| 4303 | if (p == q) |
| 4304 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4305 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4306 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4307 | ReplaceImageInList(&q,swap); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4308 | _images=GetFirstImageInList(q); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4309 | break; |
| 4310 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4311 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4312 | } |
| 4313 | case 'w': |
| 4314 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4315 | if (LocaleCompare("write",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4316 | { |
| 4317 | char |
| 4318 | key[MaxTextExtent]; |
| 4319 | |
| 4320 | Image |
| 4321 | *write_images; |
| 4322 | |
| 4323 | ImageInfo |
| 4324 | *write_info; |
| 4325 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4326 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4327 | (void) DeleteImageRegistry(key); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4328 | write_images=_images; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4329 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4330 | write_images=CloneImageList(_images,_exception); |
| 4331 | write_info=CloneImageInfo(_image_info); |
| 4332 | (void) WriteImages(write_info,write_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4333 | write_info=DestroyImageInfo(write_info); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4334 | if (IfPlusOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4335 | write_images=DestroyImageList(write_images); |
| 4336 | break; |
| 4337 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4338 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4339 | } |
| 4340 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4341 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4342 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4343 | if (new_images == (Image *) NULL) |
| 4344 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4345 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4346 | if (_images != (Image *) NULL) |
| 4347 | _images=DestroyImageList(_images); |
| 4348 | _images=GetFirstImageInList(new_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4349 | return; |
| 4350 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4351 | #undef _image_info |
| 4352 | #undef _images |
| 4353 | #undef _exception |
| 4354 | #undef _draw_info |
| 4355 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4356 | #undef IfNormalOp |
| 4357 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4358 | #undef normal_op |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4359 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4360 | |
| 4361 | /* |
| 4362 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4363 | % % |
| 4364 | % % |
| 4365 | % % |
| 4366 | + C L I S p e c i a l O p e r a t i o n s % |
| 4367 | % % |
| 4368 | % % |
| 4369 | % % |
| 4370 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4371 | % |
| 4372 | % CLISpecialOption() Applies operations that may involve empty image lists |
| 4373 | % and or stacks of image lists or image_info settings. |
| 4374 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4375 | % The classic operators of this type is -read, and image stack operators, |
| 4376 | % which can be applied to empty image lists. |
| 4377 | % |
| 4378 | % Note: unlike other Operators, these may involve other special 'option' |
| 4379 | % character prefixes, other than simply '-' or '+'. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4380 | % |
| 4381 | % The format of the CLISpecialOption method is: |
| 4382 | % |
| 4383 | % void CLISpecialOption(MagickCLI *cli_wand,const char *option, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4384 | % const char *arg1) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4385 | % |
| 4386 | % A description of each parameter follows: |
| 4387 | % |
| 4388 | % o cli_wand: the main CLI Wand to use. |
| 4389 | % |
| 4390 | % o option: The special option (with any switch char) to process |
| 4391 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4392 | % o arg1: Argument for option, if required |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4393 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4394 | % Example Usage... |
| 4395 | % |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4396 | % CLISpecialOperator(cli_wand,"-read","rose:"); |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4397 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4398 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4399 | % |
| 4400 | % cli_wand |
| 4401 | % argc,argv |
| 4402 | % i=index in argv |
| 4403 | % |
| 4404 | % option_info = GetCommandOptionInfo(argv[i]); |
| 4405 | % count=option_info->type; |
| 4406 | % option_type=option_info->flags; |
| 4407 | % |
| 4408 | % if ( (option_type & SpecialOptionFlag) != 0 ) |
| 4409 | % CLISpecialOperator(cli_wand,argv[i], |
| 4410 | % count>=1 ? argv[i+1] : (char *)NULL); |
| 4411 | % i += count+1; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4412 | % |
| 4413 | */ |
| 4414 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4415 | WandExport void CLISpecialOperator(MagickCLI *cli_wand, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4416 | const char *option, const char *arg1) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4417 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4418 | #define _exception (cli_wand->wand.exception) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4419 | |
| 4420 | assert(cli_wand != (MagickCLI *) NULL); |
| 4421 | assert(cli_wand->signature == WandSignature); |
| 4422 | assert(cli_wand->wand.signature == WandSignature); |
| 4423 | if (cli_wand->wand.debug != MagickFalse) |
| 4424 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4425 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4426 | if(cli_wand->wand.images != (Image *)NULL) |
| 4427 | (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4428 | _exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4429 | |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4430 | if (LocaleCompare("respect-parenthesis",option+1) == 0) { |
| 4431 | /* image-setting stack linkage */ |
| 4432 | (void) SetImageOption(cli_wand->wand.image_info,option+1, |
| 4433 | *option == '-' ? "true" : (char *) NULL); |
| 4434 | return; |
| 4435 | } |
| 4436 | if (LocaleCompare("(",option) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4437 | /* stack 'push' images */ |
| 4438 | Stack |
| 4439 | *node; |
| 4440 | |
| 4441 | size_t |
| 4442 | size; |
| 4443 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4444 | size=0; |
| 4445 | node=cli_wand->image_list_stack; |
| 4446 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4447 | size++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4448 | if ( size >= MAX_STACK_DEPTH ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4449 | CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4450 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4451 | if (node == (Stack *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4452 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4453 | "MemoryAllocationFailed",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4454 | node->data = (void *)cli_wand->wand.images; |
| 4455 | cli_wand->wand.images = NewImageList(); |
| 4456 | node->next = cli_wand->image_list_stack; |
| 4457 | cli_wand->image_list_stack = node; |
| 4458 | |
| 4459 | /* handle respect-parenthesis */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4460 | if ( IsMagickTrue(GetImageOption(cli_wand->wand.image_info, |
| 4461 | "respect-parenthesis")) != MagickFalse ) |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4462 | option="{"; /* push image settings too */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4463 | else |
| 4464 | return; |
| 4465 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4466 | if (LocaleCompare("{",option) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4467 | /* stack 'push' of image_info settings */ |
| 4468 | Stack |
| 4469 | *node; |
| 4470 | |
| 4471 | size_t |
| 4472 | size; |
| 4473 | |
| 4474 | size=0; |
| 4475 | node=cli_wand->image_info_stack; |
| 4476 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4477 | size++; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4478 | if ( size >= MAX_STACK_DEPTH ) |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4479 | CLIWandExceptionReturn(OptionError,"CurlyBracesNestedTooDeeply",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4480 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4481 | if (node == (Stack *) NULL) |
| 4482 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4483 | "MemoryAllocationFailed",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4484 | |
| 4485 | node->data = (void *)cli_wand->wand.image_info; |
| 4486 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4487 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4488 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4489 | option); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4490 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4491 | node = (Stack *)RelinquishMagickMemory(node); |
| 4492 | return; |
| 4493 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4494 | |
| 4495 | node->next = cli_wand->image_info_stack; |
| 4496 | cli_wand->image_info_stack = node; |
| 4497 | |
| 4498 | return; |
| 4499 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4500 | if (LocaleCompare(")",option) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4501 | /* pop images from stack */ |
| 4502 | Stack |
| 4503 | *node; |
| 4504 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4505 | node = (void *)cli_wand->image_list_stack; |
| 4506 | if ( node == (Stack *)NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4507 | CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4508 | cli_wand->image_list_stack = node->next; |
| 4509 | |
| 4510 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4511 | cli_wand->wand.images= (Image *)node->data; |
| 4512 | node = (Stack *)RelinquishMagickMemory(node); |
| 4513 | |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4514 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4515 | node = cli_wand->image_info_stack; |
| 4516 | if ( node != (Stack *)NULL) |
| 4517 | { |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4518 | if (IsMagickTrue(GetImageOption((ImageInfo *)node->data, |
| 4519 | "respect-parenthesis")) != MagickFalse ) |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4520 | option="}"; /* pop image settings too */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4521 | else |
| 4522 | return; |
| 4523 | } |
| 4524 | else |
| 4525 | return; |
| 4526 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4527 | if (LocaleCompare("}",option) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4528 | /* pop image_info settings from stack */ |
| 4529 | Stack |
| 4530 | *node; |
| 4531 | |
| 4532 | node = (void *)cli_wand->image_info_stack; |
| 4533 | if ( node == (Stack *)NULL) |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4534 | CLIWandExceptionReturn(OptionError,"UnbalancedCurlyBraces",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4535 | cli_wand->image_info_stack = node->next; |
| 4536 | |
| 4537 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
| 4538 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4539 | node = (Stack *)RelinquishMagickMemory(node); |
| 4540 | |
| 4541 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4542 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4543 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4544 | |
| 4545 | return; |
| 4546 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4547 | if (LocaleCompare("clone",option+1) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4548 | Image |
| 4549 | *new_images; |
| 4550 | |
| 4551 | if (*option == '+') |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4552 | arg1="-1"; |
| 4553 | if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4554 | CLIWandExceptionReturn(OptionError,"InvalidArgument",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4555 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4556 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4557 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4558 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4559 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
| 4560 | new_images=CloneImages(new_images,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4561 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4562 | CLIWandExceptionReturn(OptionError,"NoSuchImage",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4563 | AppendImageToList(&cli_wand->wand.images,new_images); |
| 4564 | return; |
| 4565 | } |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4566 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4567 | ( LocaleCompare("--",option) == 0 ) ) { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4568 | #if !USE_WAND_METHODS |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4569 | Image * |
| 4570 | new_images; |
| 4571 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4572 | if (cli_wand->wand.image_info->ping != MagickFalse) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4573 | new_images=PingImages(cli_wand->wand.image_info,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4574 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4575 | new_images=ReadImages(cli_wand->wand.image_info,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4576 | AppendImageToList(&cli_wand->wand.images, new_images); |
| 4577 | #else |
| 4578 | /* read images using MagickWand method - no ping */ |
| 4579 | /* This is not working! - it locks up in a CPU loop! */ |
| 4580 | MagickSetLastIterator(&cli_wand->wand); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4581 | MagickReadImage(&cli_wand->wand,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4582 | MagickSetFirstIterator(&cli_wand->wand); |
| 4583 | #endif |
| 4584 | return; |
| 4585 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4586 | /* No-op options */ |
| 4587 | if (LocaleCompare("noop",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4588 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4589 | if (LocaleCompare("sans",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4590 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4591 | if (LocaleCompare("sans0",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4592 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4593 | if (LocaleCompare("sans2",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4594 | return; |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4595 | if (LocaleCompare("list",option+1) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4596 | /* FUTURE: This should really be built into the MagickCore |
| 4597 | It does not actually require any wand or images at all! |
| 4598 | */ |
| 4599 | ssize_t |
| 4600 | list; |
| 4601 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4602 | list=ParseCommandOption(MagickListOptions,MagickFalse, arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 4603 | if ( list < 0 ) { |
| 4604 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
| 4605 | return; |
| 4606 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4607 | switch (list) |
| 4608 | { |
| 4609 | case MagickCoderOptions: |
| 4610 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4611 | (void) ListCoderInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4612 | break; |
| 4613 | } |
| 4614 | case MagickColorOptions: |
| 4615 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4616 | (void) ListColorInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4617 | break; |
| 4618 | } |
| 4619 | case MagickConfigureOptions: |
| 4620 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4621 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4622 | break; |
| 4623 | } |
| 4624 | case MagickDelegateOptions: |
| 4625 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4626 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4627 | break; |
| 4628 | } |
| 4629 | case MagickFontOptions: |
| 4630 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4631 | (void) ListTypeInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4632 | break; |
| 4633 | } |
| 4634 | case MagickFormatOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4635 | (void) ListMagickInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4636 | break; |
| 4637 | case MagickLocaleOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4638 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4639 | break; |
| 4640 | case MagickLogOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4641 | (void) ListLogInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4642 | break; |
| 4643 | case MagickMagicOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4644 | (void) ListMagicInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4645 | break; |
| 4646 | case MagickMimeOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4647 | (void) ListMimeInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4648 | break; |
| 4649 | case MagickModuleOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4650 | (void) ListModuleInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4651 | break; |
| 4652 | case MagickPolicyOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4653 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4654 | break; |
| 4655 | case MagickResourceOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4656 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4657 | break; |
| 4658 | case MagickThresholdOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4659 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4660 | break; |
| 4661 | default: |
| 4662 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4663 | _exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4664 | break; |
| 4665 | } |
| 4666 | return; |
| 4667 | } |
| 4668 | |
| 4669 | #if 0 |
| 4670 | // adjust stack handling |
| 4671 | // Other 'special' options this should handle |
| 4672 | // "region" "list" "version" |
| 4673 | // It does not do "exit" however as due to its side-effect requirements |
| 4674 | #endif |
| 4675 | #if 0 |
| 4676 | if ( ( process_flags & ProcessUnknownOptionError ) != 0 ) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4677 | #endif |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4678 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4679 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4680 | #undef _exception |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4681 | } |