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 | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1235 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1236 | _image_info->orientation=(InterlaceType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1237 | MagickOrientationOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1238 | break; |
| 1239 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1240 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1241 | } |
| 1242 | case 'p': |
| 1243 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1244 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1245 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1246 | /* Only used for new images and image generators |
| 1247 | SyncImageSettings() used to set per-image attribute. ????? |
| 1248 | That last is WRONG!!!! |
| 1249 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1250 | char |
| 1251 | *canonical_page, |
| 1252 | page[MaxTextExtent]; |
| 1253 | |
| 1254 | const char |
| 1255 | *image_option; |
| 1256 | |
| 1257 | MagickStatusType |
| 1258 | flags; |
| 1259 | |
| 1260 | RectangleInfo |
| 1261 | geometry; |
| 1262 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1263 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1264 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1265 | (void) DeleteImageOption(_image_info,option+1); |
| 1266 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1267 | break; |
| 1268 | } |
| 1269 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1270 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1271 | if (image_option != (const char *) NULL) |
| 1272 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1273 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1274 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1275 | canonical_page=DestroyString(canonical_page); |
| 1276 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1277 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1278 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1279 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1280 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1281 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1282 | (void) SetImageOption(_image_info,option+1,page); |
| 1283 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1284 | break; |
| 1285 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1286 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1287 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1288 | _image_info->ping = ArgBoolean; |
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("pointsize",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->pointsize=_draw_info->pointsize= |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1294 | StringToDouble(ArgOption("12"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1295 | break; |
| 1296 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1297 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1298 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1299 | (void) SetMagickPrecision(StringToInteger(ArgOption("-1"))); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1300 | break; |
| 1301 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1302 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1303 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1304 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1305 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1306 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1307 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1308 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1309 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1310 | break; |
| 1311 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1312 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1313 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1314 | } |
| 1315 | case 'q': |
| 1316 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1317 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1318 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1319 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1320 | _image_info->quality=UNDEFINED_COMPRESSION_QUALITY; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1321 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1322 | _image_info->quality=StringToUnsignedLong(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1323 | break; |
| 1324 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1325 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1326 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1327 | /* Just a set direct in _quantize_info */ |
| 1328 | _quantize_info->colorspace=UndefinedColorspace; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1329 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1330 | _quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1331 | MagickColorspaceOptions,MagickFalse,arg1); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1332 | break; |
| 1333 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1334 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1335 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1336 | /* FUTURE: if two -quiet is performed you can not do +quiet! */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1337 | static WarningHandler |
| 1338 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1339 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1340 | WarningHandler |
| 1341 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1342 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1343 | if ( tmp != (WarningHandler) NULL) |
| 1344 | warning_handler = tmp; /* remember the old handler */ |
| 1345 | if (!IfSetOption) /* set the old handler */ |
| 1346 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1347 | break; |
| 1348 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1349 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1350 | } |
| 1351 | case 'r': |
| 1352 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1353 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1354 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1355 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1356 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1357 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1358 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 1359 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) |
| 1360 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1361 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1362 | break; |
| 1363 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1364 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1365 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1366 | /* _draw_info only setting */ |
| 1367 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1368 | break; |
| 1369 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1370 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1371 | } |
| 1372 | case 's': |
| 1373 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1374 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1375 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1376 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1377 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1378 | break; |
| 1379 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1380 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1381 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1382 | /* SyncImageSettings() used to set per-image attribute. |
| 1383 | What ??? Why ???? |
| 1384 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1385 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1386 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1387 | break; |
| 1388 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1389 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1390 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1391 | SeedPseudoRandomGenerator( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1392 | IfSetOption ? (size_t) StringToUnsignedLong(arg1) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1393 | : (size_t) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1394 | break; |
| 1395 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1396 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1397 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1398 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1399 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1400 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1401 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1402 | break; |
| 1403 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1404 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1405 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1406 | _draw_info->stretch=(StretchType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1407 | MagickStretchOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1408 | break; |
| 1409 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1410 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1411 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1412 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1413 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1414 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1415 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1416 | MagickBooleanType |
| 1417 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1418 | |
| 1419 | ExceptionInfo |
| 1420 | *sans; |
| 1421 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1422 | PixelInfo |
| 1423 | color; |
| 1424 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1425 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1426 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1427 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1428 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1429 | |
| 1430 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1431 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1432 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1433 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1434 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1435 | if (status == MagickFalse) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1436 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1437 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1438 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1439 | break; |
| 1440 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1441 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1442 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1443 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1444 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1445 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1446 | break; |
| 1447 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1448 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1449 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1450 | _draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1451 | MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1452 | break; |
| 1453 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1454 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1455 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1456 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1457 | break; |
| 1458 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1459 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1460 | } |
| 1461 | case 't': |
| 1462 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1463 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1464 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1465 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1466 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1467 | break; |
| 1468 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1469 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1470 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1471 | /* FUTURE: move _image_info string to option splay-tree */ |
| 1472 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1473 | break; |
| 1474 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1475 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1476 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1477 | _draw_info->fill_pattern=IfSetOption |
| 1478 | ?GetImageCache(_image_info,arg1,_exception) |
| 1479 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1480 | break; |
| 1481 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1482 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1483 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1484 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1485 | (void) SetImageOption(_image_info,option+1,ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1486 | break; |
| 1487 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1488 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1489 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1490 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1491 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1492 | SyncImageSettings() used to set per-image attribute. |
| 1493 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1494 | Note that +transparent-color, means fall-back to image |
| 1495 | attribute so ImageOption is deleted, not set to a default. |
| 1496 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1497 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1498 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1499 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1500 | break; |
| 1501 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1502 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1503 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1504 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1505 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1506 | break; |
| 1507 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1508 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1509 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1510 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1511 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1512 | _image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1513 | MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1514 | break; |
| 1515 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1516 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1517 | } |
| 1518 | case 'u': |
| 1519 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1520 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1521 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1522 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1523 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1524 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1525 | break; |
| 1526 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1527 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1528 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1529 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1530 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1531 | FUTURE: this probably should be part of the density setting |
| 1532 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1533 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1534 | _image_info->units=(ResolutionType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1535 | MagickResolutionOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1536 | break; |
| 1537 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1538 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1539 | } |
| 1540 | case 'v': |
| 1541 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1542 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1543 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1544 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1545 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1546 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1547 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1548 | _image_info->verbose= ArgBoolean; |
| 1549 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1550 | break; |
| 1551 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1552 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1553 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1554 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1555 | Only used by coder FPX |
| 1556 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1557 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1558 | break; |
| 1559 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1560 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1561 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1562 | /* SyncImageSettings() used to set per-image attribute. |
| 1563 | This is VERY deep in the image caching structure. |
| 1564 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1565 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1566 | break; |
| 1567 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1568 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1569 | } |
| 1570 | case 'w': |
| 1571 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1572 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1573 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1574 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1575 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1576 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1577 | if (!IfSetOption) |
| 1578 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1579 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1580 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1581 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1582 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1583 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1584 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1585 | if (_draw_info->weight <= 800) |
| 1586 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1587 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1588 | if (_draw_info->weight >= 100) |
| 1589 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1590 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1591 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1592 | break; |
| 1593 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1594 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1595 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1596 | /* Used as a image chromaticity setting |
| 1597 | SyncImageSettings() used to set per-image attribute. |
| 1598 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1599 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1600 | break; |
| 1601 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1602 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1603 | } |
| 1604 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1605 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1606 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1607 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1608 | #undef _image_info |
| 1609 | #undef _exception |
| 1610 | #undef _draw_info |
| 1611 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1612 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1613 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1614 | #undef ArgBooleanNot |
| 1615 | #undef ArgBooleanString |
| 1616 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1617 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1618 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1619 | } |
| 1620 | |
| 1621 | /* |
| 1622 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1623 | % % |
| 1624 | % % |
| 1625 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1626 | + 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] | 1627 | % % |
| 1628 | % % |
| 1629 | % % |
| 1630 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1631 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1632 | % WandSimpleOperatorImages() applys one simple image operation given to all |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1633 | % the images in the CLI wand, with the settings that was previously saved in |
| 1634 | % the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1635 | % |
| 1636 | % 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] | 1637 | % extra settings that were already saved in the wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1638 | % |
anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1639 | % The format of the WandSimpleOperatorImage method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1640 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1641 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1642 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1643 | % |
| 1644 | % A description of each parameter follows: |
| 1645 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1646 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1647 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1648 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1649 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1650 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1651 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1652 | % Any problems will be added to the 'exception' entry of the given wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1653 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1654 | % Example usage... |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1655 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1656 | % CLISimpleOperatorImages(cli_wand, "-crop","100x100+20+30",NULL); |
| 1657 | % CLISimpleOperatorImages(cli_wand, "+repage",NULL,NULL); |
| 1658 | % CLISimpleOperatorImages(cli_wand, "+distort","SRT","45"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1659 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1660 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1661 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1662 | % cli_wand |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1663 | % argc,argv |
| 1664 | % i=index in argv |
| 1665 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 1666 | % option_info = GetCommandOptionInfo(argv[i]); |
| 1667 | % count=option_info->type; |
| 1668 | % option_type=option_info->flags; |
| 1669 | % |
| 1670 | % if ( (option_type & SimpleOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1671 | % CLISimpleOperatorImages(cli_wand, argv[i], |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1672 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 1673 | % count>=2 ? argv[i+2] : (char *)NULL ); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1674 | % i += count+1; |
| 1675 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1676 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1677 | |
| 1678 | /* |
| 1679 | Internal subrountine to apply one simple image operation to the current |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1680 | image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1681 | |
| 1682 | The image in the list may be modified in three different ways... |
| 1683 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1684 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1685 | * one image replace by a list of images (-separate and -crop only!) |
| 1686 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1687 | In each case the result replaces the single original image in the list, as |
| 1688 | well as the pointer to the modified image (last image added if replaced by a |
| 1689 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1690 | |
| 1691 | As the image pointed to may be replaced, the first image in the list may |
| 1692 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1693 | return the Image pointer to the first image in list. |
| 1694 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1695 | static void CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1696 | const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1697 | { |
| 1698 | Image * |
| 1699 | new_image; |
| 1700 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1701 | GeometryInfo |
| 1702 | geometry_info; |
| 1703 | |
| 1704 | RectangleInfo |
| 1705 | geometry; |
| 1706 | |
| 1707 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1708 | flags; |
| 1709 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1710 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1711 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1712 | |
| 1713 | #define _image_info (cli_wand->wand.image_info) |
| 1714 | #define _image (cli_wand->wand.images) |
| 1715 | #define _exception (cli_wand->wand.exception) |
| 1716 | #define _draw_info (cli_wand->draw_info) |
| 1717 | #define _quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1718 | #define IfNormalOp (*option=='-') |
| 1719 | #define IfPlusOp (*option!='-') |
| 1720 | #define normal_op (IfNormalOp?MagickTrue:MagickFalse) |
| 1721 | #define plus_alt_op (IfNormalOp?MagickFalse:MagickTrue) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1722 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1723 | assert(cli_wand != (MagickCLI *) NULL); |
| 1724 | assert(cli_wand->signature == WandSignature); |
| 1725 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1726 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1727 | if (cli_wand->wand.debug != MagickFalse) |
| 1728 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1729 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1730 | (void) SyncImageSettings(_image_info,_image,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1731 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1732 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1733 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1734 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1735 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1736 | /* FUTURE: We may need somthing a little more optimized than this! |
| 1737 | Perhaps, do the 'sync' if 'settings tainted' before next operator. |
| 1738 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1739 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1740 | { |
| 1741 | case 'a': |
| 1742 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1743 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1744 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1745 | if (IsGeometry(arg1) == MagickFalse) |
| 1746 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1747 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1748 | if ((flags & SigmaValue) == 0) |
| 1749 | geometry_info.sigma=1.0; |
| 1750 | if ((flags & XiValue) == 0) |
| 1751 | geometry_info.xi=0.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1752 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
| 1753 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1754 | break; |
| 1755 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1756 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1757 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 1758 | /* FUTURE: Roll into a resize special operator */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1759 | if (IsGeometry(arg1) == MagickFalse) |
| 1760 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1761 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1762 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
| 1763 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1764 | break; |
| 1765 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1766 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1767 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1768 | if (IsGeometry(arg1) == MagickFalse) |
| 1769 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1770 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1771 | if ((flags & SigmaValue) == 0) |
| 1772 | geometry_info.sigma=1.0; |
| 1773 | if ((flags & XiValue) == 0) |
| 1774 | geometry_info.xi=0.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1775 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
| 1776 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1777 | break; |
| 1778 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1779 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1780 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1781 | parse=ParseCommandOption(MagickAlphaOptions,MagickFalse,arg1); |
| 1782 | if (parse < 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1783 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelType", |
| 1784 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1785 | (void) SetImageAlphaChannel(_image,(AlphaChannelType)parse, |
| 1786 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1787 | break; |
| 1788 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1789 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1790 | { |
| 1791 | char |
| 1792 | *text, |
| 1793 | geometry[MaxTextExtent]; |
| 1794 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1795 | if (IsGeometry(arg1) == MagickFalse) |
| 1796 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1797 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1798 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1799 | if ((flags & SigmaValue) == 0) |
| 1800 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1801 | text=InterpretImageProperties(_image_info,_image,arg2, |
| 1802 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1803 | if (text == (char *) NULL) |
| 1804 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1805 | (void) CloneString(&_draw_info->text,text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1806 | text=DestroyString(text); |
| 1807 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1808 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1809 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1810 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1811 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1812 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1813 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1814 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1815 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1816 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1817 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1818 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1819 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1820 | break; |
| 1821 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1822 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1823 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1824 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1825 | break; |
| 1826 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1827 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1828 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1829 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1830 | break; |
| 1831 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1832 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1833 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1834 | /* This should probably be a MagickCore function */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1835 | switch (_image->orientation) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1836 | { |
| 1837 | case TopRightOrientation: |
| 1838 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1839 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1840 | break; |
| 1841 | } |
| 1842 | case BottomRightOrientation: |
| 1843 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1844 | new_image=RotateImage(_image,180.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1845 | break; |
| 1846 | } |
| 1847 | case BottomLeftOrientation: |
| 1848 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1849 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1850 | break; |
| 1851 | } |
| 1852 | case LeftTopOrientation: |
| 1853 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1854 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1855 | break; |
| 1856 | } |
| 1857 | case RightTopOrientation: |
| 1858 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1859 | new_image=RotateImage(_image,90.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1860 | break; |
| 1861 | } |
| 1862 | case RightBottomOrientation: |
| 1863 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1864 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1865 | break; |
| 1866 | } |
| 1867 | case LeftBottomOrientation: |
| 1868 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1869 | new_image=RotateImage(_image,270.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1870 | break; |
| 1871 | } |
| 1872 | default: |
| 1873 | break; |
| 1874 | } |
| 1875 | if (new_image != (Image *) NULL) |
| 1876 | new_image->orientation=TopLeftOrientation; |
| 1877 | break; |
| 1878 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1879 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1880 | } |
| 1881 | case 'b': |
| 1882 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1883 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1884 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1885 | if (IsGeometry(arg1) == MagickFalse) |
| 1886 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1887 | (void) BlackThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1888 | break; |
| 1889 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1890 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1891 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1892 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1893 | if (IfNormalOp) { |
| 1894 | if (IsGeometry(arg1) == MagickFalse) |
| 1895 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1896 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1897 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1898 | new_image=BlueShiftImage(_image,geometry_info.rho,_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("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1902 | { |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1903 | /* FUTURE: use of "bias" in a blur is non-sensible */ |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1904 | if (IsGeometry(arg1) == MagickFalse) |
| 1905 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1906 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1907 | if ((flags & SigmaValue) == 0) |
| 1908 | geometry_info.sigma=1.0; |
| 1909 | if ((flags & XiValue) == 0) |
| 1910 | geometry_info.xi=0.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1911 | new_image=BlurImage(_image,geometry_info.rho, |
| 1912 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1913 | break; |
| 1914 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1915 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1916 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1917 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1918 | compose; |
| 1919 | |
| 1920 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1921 | value; |
| 1922 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1923 | if (IsGeometry(arg1) == MagickFalse) |
| 1924 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1925 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1926 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1927 | if (value != (const char *) NULL) |
| 1928 | compose=(CompositeOperator) ParseCommandOption( |
| 1929 | MagickComposeOptions,MagickFalse,value); |
| 1930 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1931 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1932 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1933 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1934 | if ((flags & SigmaValue) == 0) |
| 1935 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1936 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1937 | break; |
| 1938 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1939 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1940 | { |
| 1941 | double |
| 1942 | brightness, |
| 1943 | contrast; |
| 1944 | |
| 1945 | GeometryInfo |
| 1946 | geometry_info; |
| 1947 | |
| 1948 | MagickStatusType |
| 1949 | flags; |
| 1950 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1951 | if (IsGeometry(arg1) == MagickFalse) |
| 1952 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1953 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1954 | brightness=geometry_info.rho; |
| 1955 | contrast=0.0; |
| 1956 | if ((flags & SigmaValue) != 0) |
| 1957 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1958 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1959 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1960 | break; |
| 1961 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1962 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1963 | } |
| 1964 | case 'c': |
| 1965 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1966 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1967 | { |
| 1968 | char |
| 1969 | *color_correction_collection; |
| 1970 | |
| 1971 | /* |
| 1972 | Color correct with a color decision list. |
| 1973 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1974 | color_correction_collection=FileToString(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1975 | if (color_correction_collection == (char *) NULL) |
| 1976 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1977 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 1978 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1979 | break; |
| 1980 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1981 | if (LocaleCompare("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1982 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1983 | if (IsGeometry(arg1) == MagickFalse) |
| 1984 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1985 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1986 | if ((flags & SigmaValue) == 0) |
| 1987 | geometry_info.sigma=1.0; |
| 1988 | if ((flags & XiValue) == 0) |
| 1989 | geometry_info.xi=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1990 | new_image=CharcoalImage(_image,geometry_info.rho, |
| 1991 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1992 | break; |
| 1993 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1994 | if (LocaleCompare("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1995 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1996 | if (IsGeometry(arg1) == MagickFalse) |
| 1997 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1998 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 1999 | new_image=ChopImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2000 | break; |
| 2001 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2002 | if (LocaleCompare("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2003 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2004 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2005 | break; |
| 2006 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2007 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2008 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2009 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2010 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 2011 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2012 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2013 | break; |
| 2014 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2015 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2016 | { |
| 2017 | CacheView |
| 2018 | *mask_view; |
| 2019 | |
| 2020 | Image |
| 2021 | *mask_image; |
| 2022 | |
| 2023 | register Quantum |
| 2024 | *restrict q; |
| 2025 | |
| 2026 | register ssize_t |
| 2027 | x; |
| 2028 | |
| 2029 | ssize_t |
| 2030 | y; |
| 2031 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2032 | if (IfPlusOp) { |
| 2033 | /* "+clip-mask" Remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2034 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2035 | break; |
| 2036 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2037 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2038 | if (mask_image == (Image *) NULL) |
| 2039 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2040 | if (SetImageStorageClass(mask_image,DirectClass,_exception) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2041 | == MagickFalse) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2042 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2043 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2044 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2045 | mask_view=AcquireCacheView(mask_image); |
| 2046 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 2047 | { |
| 2048 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2049 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2050 | if (q == (Quantum *) NULL) |
| 2051 | break; |
| 2052 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 2053 | { |
| 2054 | if (mask_image->matte == MagickFalse) |
| 2055 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 2056 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2057 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2058 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2059 | q+=GetPixelChannels(mask_image); |
| 2060 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2061 | if (SyncCacheViewAuthenticPixels(mask_view,_exception) == MagickFalse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2062 | break; |
| 2063 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2064 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2065 | mask_view=DestroyCacheView(mask_view); |
| 2066 | mask_image->matte=MagickTrue; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2067 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2068 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2069 | break; |
| 2070 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2071 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2072 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2073 | (void) ClipImagePath(_image,arg1,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2074 | break; |
| 2075 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2076 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2077 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2078 | if (IsGeometry(arg1) == MagickFalse) |
| 2079 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2080 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2081 | break; |
| 2082 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2083 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2084 | { |
| 2085 | KernelInfo |
| 2086 | *kernel; |
| 2087 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2088 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2089 | if (kernel == (KernelInfo *) NULL) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2090 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2091 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2092 | kernel=DestroyKernelInfo(kernel); |
| 2093 | break; |
| 2094 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2095 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2096 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2097 | /* Reduce the number of colors in the image. |
| 2098 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2099 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2100 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2101 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2102 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2103 | if ((_image->storage_class == DirectClass) || |
| 2104 | _image->colors > _quantize_info->number_colors) |
| 2105 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2106 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2107 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2108 | break; |
| 2109 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2110 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2111 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2112 | /* WARNING: this is both a image_info setting (already done) |
| 2113 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2114 | |
| 2115 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2116 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2117 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2118 | Note that +colorspace sets "undefined" or no effect on |
| 2119 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2120 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2121 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2122 | (void) TransformImageColorspace(_image, |
| 2123 | IfNormalOp ? _image_info->colorspace : RGBColorspace, |
| 2124 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2125 | break; |
| 2126 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2127 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2128 | { |
anthony | dcf3a91 | 2012-03-22 14:33:17 +0000 | [diff] [blame] | 2129 | /* DEPRECIATED: The -/+level provides far more controlled form */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2130 | (void) ContrastImage(_image,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2131 | break; |
| 2132 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2133 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2134 | { |
| 2135 | double |
| 2136 | black_point, |
| 2137 | white_point; |
| 2138 | |
| 2139 | MagickStatusType |
| 2140 | flags; |
| 2141 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2142 | if (IsGeometry(arg1) == MagickFalse) |
| 2143 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2144 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2145 | black_point=geometry_info.rho; |
| 2146 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2147 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2148 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2149 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2150 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2151 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2152 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2153 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2154 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2155 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2156 | break; |
| 2157 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2158 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2159 | { |
| 2160 | KernelInfo |
| 2161 | *kernel_info; |
| 2162 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2163 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2164 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2165 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2166 | kernel_info->bias=_image->bias; |
| 2167 | new_image=ConvolveImage(_image,kernel_info,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2168 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2169 | break; |
| 2170 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2171 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2172 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2173 | /* WARNING: This can generate multiple images! */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2174 | if (IsGeometry(arg1) == MagickFalse) |
| 2175 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2176 | new_image=CropImageToTiles(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2177 | break; |
| 2178 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2179 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2180 | { |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2181 | if (IsGeometry(arg1) == MagickFalse) |
| 2182 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2183 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2184 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2185 | break; |
| 2186 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2187 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2188 | } |
| 2189 | case 'd': |
| 2190 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2191 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2192 | { |
| 2193 | StringInfo |
| 2194 | *passkey; |
| 2195 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2196 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2197 | if (passkey == (StringInfo *) NULL) |
| 2198 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2199 | |
| 2200 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2201 | passkey=DestroyStringInfo(passkey); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2202 | break; |
| 2203 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2204 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2205 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2206 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2207 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2208 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2209 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2210 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2211 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2212 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2213 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2214 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2215 | break; |
| 2216 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2217 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2218 | { |
| 2219 | double |
| 2220 | threshold; |
| 2221 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2222 | if (IfNormalOp) { |
| 2223 | if (IsGeometry(arg1) == MagickFalse) |
| 2224 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2225 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2226 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2227 | else |
| 2228 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2229 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2230 | break; |
| 2231 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2232 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2233 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2234 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2235 | break; |
| 2236 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2237 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2238 | { |
| 2239 | char |
| 2240 | *args, |
| 2241 | token[MaxTextExtent]; |
| 2242 | |
| 2243 | const char |
| 2244 | *p; |
| 2245 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2246 | double |
| 2247 | *arguments; |
| 2248 | |
| 2249 | register ssize_t |
| 2250 | x; |
| 2251 | |
| 2252 | size_t |
| 2253 | number_arguments; |
| 2254 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2255 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2256 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2257 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2258 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2259 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2260 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2261 | double |
| 2262 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2263 | /* Special Case - Argument is actually a resize geometry! |
| 2264 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2265 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2266 | Roll into a resize special operator */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2267 | if (IsGeometry(arg2) == MagickFalse) |
| 2268 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2269 | option,arg2); |
| 2270 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2271 | resize_args[0]=(double) geometry.width; |
| 2272 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2273 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2274 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2275 | break; |
| 2276 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2277 | /* handle percent arguments */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2278 | args=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2279 | if (args == (char *) NULL) |
| 2280 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2281 | /* convert arguments into an array of doubles |
| 2282 | FUTURE: make this a separate function. |
| 2283 | Also make use of new 'sentinal' feature to avoid need for |
| 2284 | tokenization. |
| 2285 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2286 | p=(char *) args; |
| 2287 | for (x=0; *p != '\0'; x++) |
| 2288 | { |
| 2289 | GetMagickToken(p,&p,token); |
| 2290 | if (*token == ',') |
| 2291 | GetMagickToken(p,&p,token); |
| 2292 | } |
| 2293 | number_arguments=(size_t) x; |
| 2294 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 2295 | sizeof(*arguments)); |
| 2296 | if (arguments == (double *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2297 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 2298 | "MemoryAllocationFailed",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2299 | (void) ResetMagickMemory(arguments,0,number_arguments* |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2300 | sizeof(*arguments)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2301 | p=(char *) args; |
| 2302 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 2303 | { |
| 2304 | GetMagickToken(p,&p,token); |
| 2305 | if (*token == ',') |
| 2306 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2307 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2308 | } |
| 2309 | args=DestroyString(args); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2310 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2311 | number_arguments,arguments,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2312 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 2313 | break; |
| 2314 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2315 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2316 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2317 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2318 | (void) DrawImage(_image,_draw_info,_exception); |
| 2319 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2320 | break; |
| 2321 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2322 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2323 | } |
| 2324 | case 'e': |
| 2325 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2326 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2327 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2328 | if (IsGeometry(arg1) == MagickFalse) |
| 2329 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2330 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2331 | if ((flags & SigmaValue) == 0) |
| 2332 | geometry_info.sigma=1.0; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2333 | new_image=EdgeImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2334 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2335 | break; |
| 2336 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2337 | if (LocaleCompare("emboss",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 | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2344 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2345 | geometry_info.sigma,_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("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2349 | { |
| 2350 | StringInfo |
| 2351 | *passkey; |
| 2352 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2353 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2354 | if (passkey != (StringInfo *) NULL) |
| 2355 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2356 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2357 | passkey=DestroyStringInfo(passkey); |
| 2358 | } |
| 2359 | break; |
| 2360 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2361 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2362 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2363 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2364 | break; |
| 2365 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2366 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2367 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2368 | (void) EqualizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2369 | break; |
| 2370 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2371 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2372 | { |
| 2373 | double |
| 2374 | constant; |
| 2375 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2376 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2377 | if ( parse < 0 ) |
| 2378 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2379 | option,arg1); |
| 2380 | if (IsGeometry(arg2) == MagickFalse) |
| 2381 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2382 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2383 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2384 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2385 | break; |
| 2386 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2387 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2388 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2389 | if (IsGeometry(arg1) == MagickFalse) |
| 2390 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2391 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2392 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2393 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2394 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2395 | geometry.height=_image->rows; |
| 2396 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2397 | break; |
| 2398 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2399 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2400 | } |
| 2401 | case 'f': |
| 2402 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2403 | if (LocaleCompare("features",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2404 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2405 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2406 | if (IfPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2407 | (void) DeleteImageArtifact(_image,"identify:features"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2408 | break; |
| 2409 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2410 | (void) SetImageArtifact(_image,"identify:features","true"); |
| 2411 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2412 | break; |
| 2413 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2414 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2415 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2416 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2417 | break; |
| 2418 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2419 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2420 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2421 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2422 | break; |
| 2423 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2424 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2425 | { |
| 2426 | PixelInfo |
| 2427 | target; |
| 2428 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2429 | if (IsGeometry(arg1) == MagickFalse) |
| 2430 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2431 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2432 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2433 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
| 2434 | geometry.y,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2435 | break; |
| 2436 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2437 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2438 | { |
| 2439 | FrameInfo |
| 2440 | frame_info; |
| 2441 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2442 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2443 | compose; |
| 2444 | |
| 2445 | const char* |
| 2446 | value; |
| 2447 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2448 | value=GetImageOption(_image_info,"compose"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2449 | if (value != (const char *) NULL) |
| 2450 | compose=(CompositeOperator) ParseCommandOption( |
| 2451 | MagickComposeOptions,MagickFalse,value); |
| 2452 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2453 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2454 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2455 | if (IsGeometry(arg1) == MagickFalse) |
| 2456 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2457 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2458 | frame_info.width=geometry.width; |
| 2459 | frame_info.height=geometry.height; |
| 2460 | if ((flags & HeightValue) == 0) |
| 2461 | frame_info.height=geometry.width; |
| 2462 | frame_info.outer_bevel=geometry.x; |
| 2463 | frame_info.inner_bevel=geometry.y; |
| 2464 | frame_info.x=(ssize_t) frame_info.width; |
| 2465 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2466 | frame_info.width=_image->columns+2*frame_info.width; |
| 2467 | frame_info.height=_image->rows+2*frame_info.height; |
| 2468 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2469 | break; |
| 2470 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2471 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2472 | { |
| 2473 | char |
| 2474 | *arguments, |
| 2475 | token[MaxTextExtent]; |
| 2476 | |
| 2477 | const char |
| 2478 | *p; |
| 2479 | |
| 2480 | double |
| 2481 | *parameters; |
| 2482 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2483 | register ssize_t |
| 2484 | x; |
| 2485 | |
| 2486 | size_t |
| 2487 | number_parameters; |
| 2488 | |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2489 | /* |
| 2490 | Function Modify Image Values |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2491 | FUTURE: code should be almost a duplicate of that is "distort" |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2492 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2493 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2494 | if ( parse < 0 ) |
| 2495 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2496 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2497 | arguments=InterpretImageProperties(_image_info,_image,arg2, |
| 2498 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2499 | if (arguments == (char *) NULL) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2500 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2501 | p=(char *) arguments; |
| 2502 | for (x=0; *p != '\0'; x++) |
| 2503 | { |
| 2504 | GetMagickToken(p,&p,token); |
| 2505 | if (*token == ',') |
| 2506 | GetMagickToken(p,&p,token); |
| 2507 | } |
| 2508 | number_parameters=(size_t) x; |
| 2509 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 2510 | sizeof(*parameters)); |
| 2511 | if (parameters == (double *) NULL) |
| 2512 | ThrowWandFatalException(ResourceLimitFatalError, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2513 | "MemoryAllocationFailed",_image->filename); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2514 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 2515 | sizeof(*parameters)); |
| 2516 | p=(char *) arguments; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2517 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2518 | GetMagickToken(p,&p,token); |
| 2519 | if (*token == ',') |
| 2520 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2521 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2522 | } |
| 2523 | arguments=DestroyString(arguments); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2524 | (void) FunctionImage(_image,(MagickFunction)parse,number_parameters, |
| 2525 | parameters,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2526 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 2527 | break; |
| 2528 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2529 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2530 | } |
| 2531 | case 'g': |
| 2532 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2533 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2534 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2535 | if (IsGeometry(arg1) == MagickFalse) |
| 2536 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2537 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2538 | (void) GammaImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2539 | _exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2540 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2541 | _image->gamma=StringToDouble(arg1,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2542 | break; |
| 2543 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2544 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 2545 | (LocaleCompare("gaussian",option+1) == 0)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2546 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2547 | if (IsGeometry(arg1) == MagickFalse) |
| 2548 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2549 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2550 | if ((flags & SigmaValue) == 0) |
| 2551 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2552 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2553 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2554 | break; |
| 2555 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2556 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2557 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2558 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2559 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2560 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2561 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2562 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2563 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2564 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2565 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2566 | if (_image->geometry != (char *) NULL) |
| 2567 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2568 | break; |
| 2569 | } |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2570 | if (IsGeometry(arg1) == MagickFalse) |
| 2571 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2572 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2573 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2574 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2575 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2576 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
| 2577 | _image->filter,_image->blur,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2578 | break; |
| 2579 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2580 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2581 | } |
| 2582 | case 'h': |
| 2583 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2584 | if (LocaleCompare("highlight-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2585 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2586 | (void) SetImageArtifact(_image,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2587 | break; |
| 2588 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2589 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2590 | } |
| 2591 | case 'i': |
| 2592 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2593 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2594 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2595 | const char |
| 2596 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2597 | *text; |
| 2598 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2599 | format=GetImageOption(_image_info,"format"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2600 | if (format == (char *) NULL) |
| 2601 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2602 | (void) IdentifyImage(_image,stdout,_image_info->verbose, |
| 2603 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2604 | break; |
| 2605 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2606 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2607 | if (text == (char *) NULL) |
| 2608 | break; |
| 2609 | (void) fputs(text,stdout); |
| 2610 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2611 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2612 | break; |
| 2613 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2614 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2615 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2616 | if (IsGeometry(arg1) == MagickFalse) |
| 2617 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2618 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2619 | new_image=ImplodeImage(_image,geometry_info.rho, |
| 2620 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2621 | break; |
| 2622 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2623 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2624 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2625 | /* FUTURE: New to IMv7 |
| 2626 | Roll into a resize special operator */ |
| 2627 | if (IsGeometry(arg1) == MagickFalse) |
| 2628 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2629 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2630 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2631 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2632 | break; |
| 2633 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2634 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2635 | } |
| 2636 | case 'l': |
| 2637 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2638 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2639 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2640 | if (IsGeometry(arg1) == MagickFalse) |
| 2641 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2642 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2643 | if ((flags & PercentValue) != 0) |
| 2644 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2645 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2646 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2647 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2648 | break; |
| 2649 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2650 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2651 | { |
| 2652 | MagickRealType |
| 2653 | black_point, |
| 2654 | gamma, |
| 2655 | white_point; |
| 2656 | |
| 2657 | MagickStatusType |
| 2658 | flags; |
| 2659 | |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2660 | if (IsGeometry(arg1) == MagickFalse) |
| 2661 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2662 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2663 | black_point=geometry_info.rho; |
| 2664 | white_point=(MagickRealType) QuantumRange; |
| 2665 | if ((flags & SigmaValue) != 0) |
| 2666 | white_point=geometry_info.sigma; |
| 2667 | gamma=1.0; |
| 2668 | if ((flags & XiValue) != 0) |
| 2669 | gamma=geometry_info.xi; |
| 2670 | if ((flags & PercentValue) != 0) |
| 2671 | { |
| 2672 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2673 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2674 | } |
| 2675 | if ((flags & SigmaValue) == 0) |
| 2676 | white_point=(MagickRealType) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2677 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2678 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2679 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2680 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2681 | break; |
| 2682 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2683 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2684 | { |
| 2685 | char |
| 2686 | token[MaxTextExtent]; |
| 2687 | |
| 2688 | const char |
| 2689 | *p; |
| 2690 | |
| 2691 | PixelInfo |
| 2692 | black_point, |
| 2693 | white_point; |
| 2694 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2695 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2696 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2697 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2698 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2699 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2700 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2701 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2702 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2703 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2704 | GetMagickToken(p,&p,token); |
| 2705 | if (*token == '\0') |
| 2706 | white_point=black_point; /* set everything to that color */ |
| 2707 | else |
| 2708 | { |
| 2709 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2710 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2711 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2712 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2713 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2714 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2715 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2716 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2717 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2718 | (void) LevelImageColors(_image,&black_point,&white_point, |
| 2719 | plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2720 | break; |
| 2721 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2722 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2723 | { |
| 2724 | double |
| 2725 | black_point, |
| 2726 | white_point; |
| 2727 | |
| 2728 | MagickStatusType |
| 2729 | flags; |
| 2730 | |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2731 | if (IsGeometry(arg1) == MagickFalse) |
| 2732 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2733 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2734 | black_point=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2735 | white_point=(MagickRealType) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2736 | if ((flags & SigmaValue) != 0) |
| 2737 | white_point=geometry_info.sigma; |
| 2738 | if ((flags & PercentValue) != 0) |
| 2739 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2740 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2741 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2742 | } |
| 2743 | if ((flags & SigmaValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2744 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2745 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2746 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2747 | break; |
| 2748 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2749 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2750 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 2751 | /* FUTURE: Roll into a resize special operator */ |
| 2752 | if (IsGeometry(arg1) == MagickFalse) |
| 2753 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2754 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2755 | if ((flags & XValue) == 0) |
| 2756 | geometry.x=1; |
| 2757 | if ((flags & YValue) == 0) |
| 2758 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2759 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2760 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2761 | break; |
| 2762 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2763 | if (LocaleCompare("lowlight-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2764 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2765 | (void) SetImageArtifact(_image,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2766 | break; |
| 2767 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2768 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2769 | } |
| 2770 | case 'm': |
| 2771 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2772 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2773 | { |
| 2774 | Image |
| 2775 | *remap_image; |
| 2776 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2777 | /* DEPRECIATED use -remap */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2778 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2779 | if (remap_image == (Image *) NULL) |
| 2780 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2781 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2782 | remap_image=DestroyImage(remap_image); |
| 2783 | break; |
| 2784 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2785 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2786 | { |
| 2787 | Image |
| 2788 | *mask; |
| 2789 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2790 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2791 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2792 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2793 | break; |
| 2794 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2795 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2796 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2797 | if (mask == (Image *) NULL) |
| 2798 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2799 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2800 | mask=DestroyImage(mask); |
| 2801 | break; |
| 2802 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2803 | if (LocaleCompare("matte",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2804 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2805 | /* DEPRECIATED */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2806 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2807 | DeactivateAlphaChannel, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2808 | break; |
| 2809 | } |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2810 | if (LocaleCompare("median",option+1) == 0) |
| 2811 | { |
| 2812 | /* DEPRECIATED - use -statistic Median */ |
| 2813 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2814 | break; |
| 2815 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2816 | if (LocaleCompare("mode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2817 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2818 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2819 | if ((flags & SigmaValue) == 0) |
| 2820 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2821 | new_image=StatisticImage(_image,ModeStatistic,(size_t) |
| 2822 | geometry_info.rho,(size_t) geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2823 | break; |
| 2824 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2825 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2826 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2827 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2828 | break; |
| 2829 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2830 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2831 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2832 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2833 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2834 | break; |
| 2835 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2836 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2837 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2838 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2839 | break; |
| 2840 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2841 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2842 | { |
| 2843 | char |
| 2844 | token[MaxTextExtent]; |
| 2845 | |
| 2846 | const char |
| 2847 | *p; |
| 2848 | |
| 2849 | KernelInfo |
| 2850 | *kernel; |
| 2851 | |
| 2852 | MorphologyMethod |
| 2853 | method; |
| 2854 | |
| 2855 | ssize_t |
| 2856 | iterations; |
| 2857 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2858 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2859 | GetMagickToken(p,&p,token); |
| 2860 | method=(MorphologyMethod) ParseCommandOption( |
| 2861 | MagickMorphologyOptions,MagickFalse,token); |
| 2862 | iterations=1L; |
| 2863 | GetMagickToken(p,&p,token); |
| 2864 | if ((*p == ':') || (*p == ',')) |
| 2865 | GetMagickToken(p,&p,token); |
| 2866 | if ((*p != '\0')) |
| 2867 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2868 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2869 | if (kernel == (KernelInfo *) NULL) |
| 2870 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2871 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2872 | OptionError,"UnabletoParseKernel","morphology"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2873 | break; |
| 2874 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2875 | new_image=MorphologyImage(_image,method,iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2876 | kernel=DestroyKernelInfo(kernel); |
| 2877 | break; |
| 2878 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2879 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2880 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2881 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2882 | if ((flags & SigmaValue) == 0) |
| 2883 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2884 | new_image=MotionBlurImage(_image,geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2885 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2886 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2887 | break; |
| 2888 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2889 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2890 | } |
| 2891 | case 'n': |
| 2892 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2893 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2894 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2895 | (void) NegateImage(_image, plus_alt_op, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2896 | break; |
| 2897 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2898 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2899 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2900 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2901 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2902 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2903 | if ((flags & SigmaValue) == 0) |
| 2904 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2905 | new_image=StatisticImage(_image,NonpeakStatistic,(size_t) |
| 2906 | geometry_info.rho,(size_t) geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2907 | } |
| 2908 | else |
| 2909 | { |
| 2910 | NoiseType |
| 2911 | noise; |
| 2912 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2913 | double |
| 2914 | attenuate; |
| 2915 | |
| 2916 | const char* |
| 2917 | value; |
| 2918 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2919 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2920 | MagickFalse,arg1), |
| 2921 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2922 | value=GetImageOption(_image_info,"attenuate"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2923 | if (value != (const char *) NULL) |
| 2924 | attenuate=StringToDouble(value,(char **) NULL); |
| 2925 | else |
| 2926 | attenuate=1.0; |
| 2927 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2928 | new_image=AddNoiseImage(_image,noise,attenuate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2929 | } |
| 2930 | break; |
| 2931 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2932 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2933 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2934 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2935 | break; |
| 2936 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2937 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2938 | } |
| 2939 | case 'o': |
| 2940 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2941 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2942 | { |
| 2943 | PixelInfo |
| 2944 | target; |
| 2945 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2946 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 2947 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,plus_alt_op, |
| 2948 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2949 | break; |
| 2950 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2951 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2952 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2953 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2954 | break; |
| 2955 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2956 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2957 | } |
| 2958 | case 'p': |
| 2959 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2960 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2961 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2962 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2963 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2964 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2965 | break; |
| 2966 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2967 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2968 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2969 | const char |
| 2970 | *caption; |
| 2971 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2972 | double |
| 2973 | angle; |
| 2974 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2975 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2976 | { |
| 2977 | RandomInfo |
| 2978 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2979 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2980 | random_info=AcquireRandomInfo(); |
| 2981 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2982 | random_info=DestroyRandomInfo(random_info); |
| 2983 | } |
| 2984 | else |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2985 | { |
| 2986 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2987 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2988 | angle=geometry_info.rho; |
| 2989 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2990 | caption=GetImageProperty(_image,"caption",_exception); |
| 2991 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 2992 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2993 | break; |
| 2994 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2995 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2996 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2997 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2998 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
| 2999 | _quantize_info->dither,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3000 | break; |
| 3001 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3002 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3003 | { |
| 3004 | PreviewType |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 3005 | preview_type; |
anthony | 170fce9 | 2011-10-20 11:50:23 +0000 | [diff] [blame] | 3006 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3007 | /* FUTURE: should be a 'Genesis' option? |
| 3008 | Option however is also in WandSettingOptionInfo() |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 3009 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3010 | preview_type=UndefinedPreview; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3011 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3012 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 3013 | MagickFalse,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3014 | new_image=PreviewImage(_image,preview_type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3015 | break; |
| 3016 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3017 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3018 | { |
| 3019 | const char |
| 3020 | *name; |
| 3021 | |
| 3022 | const StringInfo |
| 3023 | *profile; |
| 3024 | |
| 3025 | Image |
| 3026 | *profile_image; |
| 3027 | |
| 3028 | ImageInfo |
| 3029 | *profile_info; |
| 3030 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3031 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3032 | { /* Remove a profile from the _image. */ |
| 3033 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 3034 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3035 | break; |
| 3036 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3037 | /* Associate a profile with the _image. */ |
| 3038 | profile_info=CloneImageInfo(_image_info); |
| 3039 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3040 | if (profile != (StringInfo *) NULL) |
| 3041 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3042 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3043 | profile_info=DestroyImageInfo(profile_info); |
| 3044 | if (profile_image == (Image *) NULL) |
| 3045 | { |
| 3046 | StringInfo |
| 3047 | *profile; |
| 3048 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3049 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3050 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3051 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3052 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3053 | if (profile != (StringInfo *) NULL) |
| 3054 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3055 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3056 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3057 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3058 | profile=DestroyStringInfo(profile); |
| 3059 | } |
| 3060 | profile_info=DestroyImageInfo(profile_info); |
| 3061 | break; |
| 3062 | } |
| 3063 | ResetImageProfileIterator(profile_image); |
| 3064 | name=GetNextImageProfile(profile_image); |
| 3065 | while (name != (const char *) NULL) |
| 3066 | { |
| 3067 | profile=GetImageProfile(profile_image,name); |
| 3068 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3069 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 3070 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3071 | name=GetNextImageProfile(profile_image); |
| 3072 | } |
| 3073 | profile_image=DestroyImage(profile_image); |
| 3074 | break; |
| 3075 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3076 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3077 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3078 | case 'r': |
| 3079 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3080 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3081 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3082 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3083 | new_image=RadialBlurImage(_image,geometry_info.rho, |
| 3084 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3085 | break; |
| 3086 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3087 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3088 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3089 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3090 | if ((flags & SigmaValue) == 0) |
| 3091 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3092 | (void) RaiseImage(_image,&geometry,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3093 | break; |
| 3094 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3095 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3096 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3097 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3098 | break; |
| 3099 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3100 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3101 | { |
| 3102 | Image |
| 3103 | *remap_image; |
| 3104 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3105 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3106 | if (remap_image == (Image *) NULL) |
| 3107 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3108 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3109 | remap_image=DestroyImage(remap_image); |
| 3110 | break; |
| 3111 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3112 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3113 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3114 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3115 | (void) ResetImagePage(_image,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3116 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3117 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3118 | break; |
| 3119 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3120 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3121 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3122 | /* FUTURE: remove blur arguemnt - no longer used */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3123 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3124 | if ((flags & SigmaValue) == 0) |
| 3125 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3126 | new_image=ResampleImage(_image,geometry_info.rho, |
| 3127 | geometry_info.sigma,_image->filter,_image->blur,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3128 | break; |
| 3129 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3130 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3131 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 3132 | /* FUTURE: remove blur argument - no longer used */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3133 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3134 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
| 3135 | _image->filter,_image->blur,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3136 | break; |
| 3137 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3138 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3139 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3140 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3141 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3142 | break; |
| 3143 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3144 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3145 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3146 | if (strchr(arg1,'>') != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3147 | if (_image->columns <= _image->rows) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3148 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3149 | if (strchr(arg1,'<') != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3150 | if (_image->columns >= _image->rows) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3151 | break; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 3152 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3153 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3154 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3155 | break; |
| 3156 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3157 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3158 | } |
| 3159 | case 's': |
| 3160 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3161 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3162 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 3163 | /* FUTURE: Roll into a resize special operator */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3164 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3165 | new_image=SampleImage(_image,geometry.width,geometry.height, |
| 3166 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3167 | break; |
| 3168 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3169 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3170 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 3171 | /* FUTURE: Roll into a resize special operator */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3172 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3173 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3174 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3175 | break; |
| 3176 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3177 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3178 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3179 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3180 | if ((flags & PercentValue) != 0) |
| 3181 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3182 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
| 3183 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_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("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3187 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3188 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3189 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3190 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3191 | break; |
| 3192 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3193 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3194 | { |
| 3195 | double |
| 3196 | threshold; |
| 3197 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3198 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3199 | new_image=SepiaToneImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3200 | break; |
| 3201 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3202 | if (LocaleCompare("segment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3203 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3204 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3205 | if ((flags & SigmaValue) == 0) |
| 3206 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3207 | (void) SegmentImage(_image,_image->colorspace, |
| 3208 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3209 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3210 | break; |
| 3211 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3212 | if (LocaleCompare("set",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3213 | { |
| 3214 | char |
| 3215 | *value; |
| 3216 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3217 | if (IfPlusOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3218 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3219 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3220 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3221 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3222 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3223 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3224 | (void) DeleteImageOption(_image_info,arg1+7); |
| 3225 | (void) DeleteImageArtifact(_image,arg1+7); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3226 | } |
| 3227 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3228 | (void) DeleteImageProperty(_image,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3229 | break; |
| 3230 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3231 | value=InterpretImageProperties(_image_info,_image,arg2, |
| 3232 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3233 | if (value == (char *) NULL) |
| 3234 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3235 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3236 | (void) SetImageRegistry(StringRegistryType,arg1+9,value, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3237 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3238 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +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) SetImageOption(_image_info,arg1+7,value); |
| 3242 | (void) SetImageArtifact(_image,arg1+7,value); |
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) SetImageProperty(_image,arg1,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3246 | value=DestroyString(value); |
| 3247 | break; |
| 3248 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3249 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3250 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3251 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3252 | if ((flags & SigmaValue) == 0) |
| 3253 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3254 | new_image=ShadeImage(_image,normal_op,geometry_info.rho, |
| 3255 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3256 | break; |
| 3257 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3258 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3259 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3260 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3261 | if ((flags & SigmaValue) == 0) |
| 3262 | geometry_info.sigma=1.0; |
| 3263 | if ((flags & XiValue) == 0) |
| 3264 | geometry_info.xi=4.0; |
| 3265 | if ((flags & PsiValue) == 0) |
| 3266 | geometry_info.psi=4.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3267 | new_image=ShadowImage(_image,geometry_info.rho, |
| 3268 | geometry_info.sigma,_image->bias,(ssize_t) |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 3269 | 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] | 3270 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3271 | break; |
| 3272 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3273 | if (LocaleCompare("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3274 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3275 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3276 | if ((flags & SigmaValue) == 0) |
| 3277 | geometry_info.sigma=1.0; |
| 3278 | if ((flags & XiValue) == 0) |
| 3279 | geometry_info.xi=0.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3280 | new_image=SharpenImage(_image,geometry_info.rho, |
| 3281 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3282 | break; |
| 3283 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3284 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3285 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3286 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3287 | new_image=ShaveImage(_image,&geometry,_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("shear",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=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3295 | new_image=ShearImage(_image,geometry_info.rho, |
| 3296 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3297 | break; |
| 3298 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3299 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3300 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3301 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3302 | if ((flags & SigmaValue) == 0) |
| 3303 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3304 | if ((flags & PercentValue) != 0) |
| 3305 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3306 | 100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3307 | (void) SigmoidalContrastImage(_image,normal_op,geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3308 | geometry_info.sigma, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3309 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3310 | break; |
| 3311 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3312 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3313 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3314 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3315 | if ((flags & SigmaValue) == 0) |
| 3316 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3317 | new_image=SketchImage(_image,geometry_info.rho, |
| 3318 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3319 | break; |
| 3320 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3321 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3322 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3323 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3324 | QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3325 | break; |
| 3326 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3327 | if (LocaleCompare("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3328 | { |
| 3329 | SparseColorMethod |
| 3330 | method; |
| 3331 | |
| 3332 | char |
| 3333 | *arguments; |
| 3334 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3335 | method=(SparseColorMethod) ParseCommandOption( |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3336 | MagickSparseColorOptions,MagickFalse,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3337 | arguments=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3338 | if (arguments == (char *) NULL) |
| 3339 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3340 | new_image=SparseColorOption(_image,method,arguments,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3341 | arguments=DestroyString(arguments); |
| 3342 | break; |
| 3343 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3344 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3345 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3346 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 3347 | new_image=SpliceImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3348 | break; |
| 3349 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3350 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3351 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3352 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3353 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3354 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3355 | break; |
| 3356 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3357 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3358 | { |
| 3359 | StatisticType |
| 3360 | type; |
| 3361 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3362 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3363 | MagickFalse,arg1); |
| 3364 | (void) ParseGeometry(arg2,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3365 | new_image=StatisticImage(_image,type,(size_t) geometry_info.rho, |
| 3366 | (size_t) geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3367 | break; |
| 3368 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3369 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3370 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3371 | (void) StripImage(_image,_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("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3375 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3376 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3377 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3378 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3379 | break; |
| 3380 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3381 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3382 | } |
| 3383 | case 't': |
| 3384 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3385 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3386 | { |
| 3387 | double |
| 3388 | threshold; |
| 3389 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3390 | if (!normal_op) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3391 | threshold=(double) QuantumRange/2; |
| 3392 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3393 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3394 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3395 | break; |
| 3396 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3397 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3398 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3399 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3400 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3401 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3402 | break; |
| 3403 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3404 | if (LocaleCompare("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3405 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3406 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3407 | break; |
| 3408 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3409 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3410 | { |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 3411 | /* DEPRECIATED -- should really use Distort AffineProjection */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3412 | new_image=AffineTransformImage(_image,&_draw_info->affine, |
| 3413 | _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("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3417 | { |
| 3418 | PixelInfo |
| 3419 | target; |
| 3420 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3421 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3422 | (void) TransparentPaintImage(_image,&target,(Quantum) |
| 3423 | TransparentAlpha,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3424 | break; |
| 3425 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3426 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3427 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3428 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3429 | break; |
| 3430 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3431 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3432 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3433 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3434 | break; |
| 3435 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3436 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3437 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3438 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3439 | break; |
| 3440 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3441 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3442 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3443 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3444 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3445 | break; |
| 3446 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3447 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3448 | } |
| 3449 | case 'u': |
| 3450 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3451 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3452 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3453 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 3454 | /* FUTURE: This option is not documented!!!!! */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3455 | if (!normal_op) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3456 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3457 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3458 | break; |
| 3459 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3460 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3461 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3462 | break; |
| 3463 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3464 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3465 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3466 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3467 | break; |
| 3468 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3469 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3470 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3471 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3472 | if ((flags & SigmaValue) == 0) |
| 3473 | geometry_info.sigma=1.0; |
| 3474 | if ((flags & XiValue) == 0) |
| 3475 | geometry_info.xi=1.0; |
| 3476 | if ((flags & PsiValue) == 0) |
| 3477 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3478 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
| 3479 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3480 | break; |
| 3481 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3482 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3483 | } |
| 3484 | case 'v': |
| 3485 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3486 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3487 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3488 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3489 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3490 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3491 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3492 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3493 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3494 | break; |
| 3495 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3496 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3497 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3498 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3499 | if ((flags & SigmaValue) == 0) |
| 3500 | geometry_info.sigma=1.0; |
| 3501 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3502 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3503 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3504 | geometry_info.psi=0.1*_image->rows; |
| 3505 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3506 | _image->bias,(ssize_t) ceil(geometry_info.xi-0.5), |
| 3507 | (ssize_t) ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3508 | break; |
| 3509 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3510 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3511 | } |
| 3512 | case 'w': |
| 3513 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3514 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3515 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3516 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3517 | if ((flags & SigmaValue) == 0) |
| 3518 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3519 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3520 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3521 | break; |
| 3522 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3523 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3524 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3525 | (void) WhiteThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3526 | break; |
| 3527 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3528 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3529 | } |
| 3530 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3531 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3532 | } |
| 3533 | /* |
| 3534 | Replace current image with any image that was generated |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3535 | and set image point to last image (so image->next is correct) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3536 | */ |
| 3537 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3538 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3539 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3540 | return; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3541 | #undef _image_info |
| 3542 | #undef _draw_info |
| 3543 | #undef _quantize_info |
| 3544 | #undef _image |
| 3545 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3546 | #undef IfNormalOp |
| 3547 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3548 | #undef normal_op |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3549 | #undef plus_alt_op |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3550 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3551 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3552 | WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3553 | const char *option, const char *arg1, const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3554 | { |
| 3555 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3556 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3557 | i; |
| 3558 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3559 | assert(cli_wand != (MagickCLI *) NULL); |
| 3560 | assert(cli_wand->signature == WandSignature); |
| 3561 | assert(cli_wand->wand.signature == WandSignature); |
| 3562 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
| 3563 | if (cli_wand->wand.debug != MagickFalse) |
| 3564 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3565 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3566 | #if !USE_WAND_METHODS |
| 3567 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3568 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3569 | n=GetImageListLength(cli_wand->wand.images); |
| 3570 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3571 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3572 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3573 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3574 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3575 | break; |
| 3576 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3577 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3578 | assert( i == n ); |
| 3579 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3580 | #else |
| 3581 | MagickResetIterator(&cli_wand->wand); |
| 3582 | while ( MagickNextImage(&cli_wand->wand) != MagickFalse ) |
| 3583 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3584 | MagickResetIterator(&cli_wand->wand); |
| 3585 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3586 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3587 | } |
| 3588 | |
| 3589 | /* |
| 3590 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3591 | % % |
| 3592 | % % |
| 3593 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3594 | + 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] | 3595 | % % |
| 3596 | % % |
| 3597 | % % |
| 3598 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3599 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3600 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3601 | % entire image list as a whole. The result is often a complete replacment |
| 3602 | % 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] | 3603 | % |
| 3604 | % The format of the MogrifyImage method is: |
| 3605 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3606 | % void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3607 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3608 | % |
| 3609 | % A description of each parameter follows: |
| 3610 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3611 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3612 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3613 | % o option: The option string for the operation |
| 3614 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3615 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3616 | % |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 3617 | % NOTE: only "limit" uses two arguments. |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3618 | % |
| 3619 | % Example usage... |
| 3620 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3621 | % CLIListOperatorImages(cli_wand,MagickFalse,"-duplicate", "3", NULL); |
| 3622 | % CLIListOperatorImages(cli_wand,MagickTrue, "+append", NULL, NULL); |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3623 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 3624 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3625 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3626 | % cli_wand |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3627 | % argc,argv |
| 3628 | % i=index in argv |
| 3629 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 3630 | % option_info = GetCommandOptionInfo(argv[i]); |
| 3631 | % count=option_info->type; |
| 3632 | % option_type=option_info->flags; |
| 3633 | % |
| 3634 | % if ( (option_type & ListOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3635 | % CLIListOperatorImages(cli_wand,argv[i], |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3636 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 3637 | % count>=2 ? argv[i+2] : (char *)NULL ); |
| 3638 | % i += count+1; |
| 3639 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3640 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3641 | WandExport void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3642 | const char *option,const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3643 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3644 | ssize_t |
| 3645 | parse; |
| 3646 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3647 | Image |
| 3648 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3649 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3650 | #define _image_info (cli_wand->wand.image_info) |
| 3651 | #define _images (cli_wand->wand.images) |
| 3652 | #define _exception (cli_wand->wand.exception) |
| 3653 | #define _draw_info (cli_wand->draw_info) |
| 3654 | #define _quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3655 | #define IfNormalOp (*option=='-') |
| 3656 | #define IfPlusOp (*option!='-') |
| 3657 | #define normal_op (IfNormalOp?MagickTrue:MagickFalse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3658 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3659 | assert(cli_wand != (MagickCLI *) NULL); |
| 3660 | assert(cli_wand->signature == WandSignature); |
| 3661 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3662 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3663 | if (cli_wand->wand.debug != MagickFalse) |
| 3664 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3665 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3666 | (void) SyncImagesSettings(_image_info,_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3667 | |
| 3668 | new_images=NewImageList(); |
| 3669 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3670 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3671 | { |
| 3672 | case 'a': |
| 3673 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3674 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3675 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3676 | new_images=AppendImages(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3677 | break; |
| 3678 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3679 | if (LocaleCompare("average",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3680 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3681 | /* DEPRECIATED - use -evaluate-sequence Mean */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3682 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3683 | break; |
| 3684 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3685 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3686 | } |
| 3687 | case 'c': |
| 3688 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3689 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3690 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3691 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3692 | break; |
| 3693 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3694 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3695 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3696 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3697 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3698 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3699 | /* FUTURE - make this a compose option, and thus can be used |
| 3700 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3701 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3702 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3703 | new_images=RemoveFirstImageFromList(&_images); |
| 3704 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3705 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3706 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3707 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3708 | (void) ClutImage(new_images,clut_image,_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3709 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3710 | break; |
| 3711 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3712 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3713 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3714 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3715 | break; |
| 3716 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3717 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3718 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3719 | /* FUTURE - this may be replaced by a 'channel' method */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3720 | new_images=CombineImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3721 | break; |
| 3722 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3723 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3724 | { |
| 3725 | Image |
| 3726 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3727 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3728 | |
| 3729 | RectangleInfo |
| 3730 | geometry; |
| 3731 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3732 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3733 | compose; |
| 3734 | |
| 3735 | const char* |
| 3736 | value; |
| 3737 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3738 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3739 | if (value != (const char *) NULL) |
| 3740 | compose=(CompositeOperator) ParseCommandOption( |
| 3741 | MagickComposeOptions,MagickFalse,value); |
| 3742 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3743 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3744 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3745 | new_images=RemoveFirstImageFromList(&_images); |
| 3746 | source_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3747 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3748 | if (source_image == (Image *) NULL) |
| 3749 | break; |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3750 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3751 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3752 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3753 | source_image->geometry,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3754 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3755 | SetGeometry(source_image,&geometry); |
| 3756 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3757 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
| 3758 | new_images->gravity, &geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3759 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3760 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3761 | if (mask_image != (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3762 | { /* handle a third write mask image */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3763 | if ((compose == DisplaceCompositeOp) || |
| 3764 | (compose == DistortCompositeOp)) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3765 | { /* Merge Y displacement into X displace/distort map. */ |
| 3766 | (void) CompositeImage(source_image,CopyGreenCompositeOp, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3767 | mask_image,0,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3768 | mask_image=DestroyImage(mask_image); |
| 3769 | } |
| 3770 | else |
| 3771 | { |
| 3772 | /* |
| 3773 | Set a blending mask for the composition. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3774 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3775 | (void) NegateImage(mask_image,MagickFalse,_exception); |
| 3776 | (void) SetImageMask(new_images,mask_image,_exception); |
cristy | 1539afd | 2012-01-30 01:32:59 +0000 | [diff] [blame] | 3777 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3778 | } |
| 3779 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3780 | (void) CompositeImage(new_images,compose,source_image,geometry.x, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3781 | geometry.y,_exception); |
| 3782 | (void) SetImageMask(new_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3783 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3784 | break; |
| 3785 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3786 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3787 | } |
| 3788 | case 'd': |
| 3789 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3790 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3791 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3792 | /* DEPRECIATED - use -layers CompareAny */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3793 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3794 | break; |
| 3795 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3796 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3797 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3798 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3799 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3800 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3801 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3802 | break; |
| 3803 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3804 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3805 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3806 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3807 | { |
| 3808 | const char |
| 3809 | *p; |
| 3810 | |
| 3811 | size_t |
| 3812 | number_duplicates; |
| 3813 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3814 | if (IsGeometry(arg1) == MagickFalse) |
| 3815 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3816 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3817 | number_duplicates=(size_t) StringToLong(arg1); |
| 3818 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3819 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3820 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3821 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3822 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3823 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3824 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3825 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3826 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3827 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3828 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3829 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3830 | break; |
| 3831 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3832 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3833 | } |
| 3834 | case 'e': |
| 3835 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3836 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3837 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3838 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3839 | if ( parse < 0 ) |
| 3840 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3841 | option,arg1); |
| 3842 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
| 3843 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3844 | break; |
| 3845 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3846 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3847 | } |
| 3848 | case 'f': |
| 3849 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3850 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3851 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3852 | new_images=ForwardFourierTransformImage(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3853 | break; |
| 3854 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3855 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3856 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3857 | /* REDIRECTED to use -layers flatten instead */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3858 | CLIListOperatorImages(cli_wand,"-layer",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3859 | break; |
| 3860 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3861 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3862 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3863 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3864 | break; |
| 3865 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3866 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3867 | } |
| 3868 | case 'h': |
| 3869 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3870 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3871 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3872 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3873 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3874 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3875 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3876 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3877 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3878 | new_images=RemoveFirstImageFromList(&_images); |
| 3879 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3880 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3881 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3882 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3883 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3884 | break; |
| 3885 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3886 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3887 | } |
| 3888 | case 'i': |
| 3889 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3890 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3891 | { |
| 3892 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3893 | *magnitude_image, |
| 3894 | *phase_image; |
| 3895 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3896 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3897 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3898 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3899 | if (phase_image == (Image *) NULL) |
| 3900 | break; |
| 3901 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3902 | normal_op,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3903 | magnitude_image=DestroyImage(magnitude_image); |
| 3904 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3905 | break; |
| 3906 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3907 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3908 | { |
| 3909 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3910 | *insert_image, |
| 3911 | *index_image; |
| 3912 | |
| 3913 | ssize_t |
| 3914 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3915 | |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 3916 | if (IfNormalOp && IsGeometry(arg1) == MagickFalse) |
| 3917 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3918 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3919 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3920 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3921 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3922 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3923 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3924 | PrependImageToList(&_images,insert_image); |
| 3925 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3926 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3927 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3928 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3929 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3930 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 3931 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3932 | InsertImageInList(&index_image,insert_image); |
| 3933 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3934 | _images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3935 | break; |
| 3936 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3937 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3938 | } |
| 3939 | case 'l': |
| 3940 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3941 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3942 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 3943 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3944 | if ( parse < 0 ) |
| 3945 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3946 | option,arg1); |
| 3947 | switch ((ImageLayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3948 | { |
| 3949 | case CoalesceLayer: |
| 3950 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3951 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3952 | break; |
| 3953 | } |
| 3954 | case CompareAnyLayer: |
| 3955 | case CompareClearLayer: |
| 3956 | case CompareOverlayLayer: |
| 3957 | default: |
| 3958 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 3959 | new_images=CompareImagesLayers(_images,(ImageLayerMethod) parse, |
| 3960 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3961 | break; |
| 3962 | } |
| 3963 | case MergeLayer: |
| 3964 | case FlattenLayer: |
| 3965 | case MosaicLayer: |
| 3966 | case TrimBoundsLayer: |
| 3967 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 3968 | new_images=MergeImageLayers(_images,(ImageLayerMethod) parse, |
| 3969 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3970 | break; |
| 3971 | } |
| 3972 | case DisposeLayer: |
| 3973 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3974 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3975 | break; |
| 3976 | } |
| 3977 | case OptimizeImageLayer: |
| 3978 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3979 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3980 | break; |
| 3981 | } |
| 3982 | case OptimizePlusLayer: |
| 3983 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3984 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3985 | break; |
| 3986 | } |
| 3987 | case OptimizeTransLayer: |
| 3988 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3989 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3990 | break; |
| 3991 | } |
| 3992 | case RemoveDupsLayer: |
| 3993 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3994 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3995 | break; |
| 3996 | } |
| 3997 | case RemoveZeroLayer: |
| 3998 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3999 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4000 | break; |
| 4001 | } |
| 4002 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4003 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4004 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4005 | if (new_images == (Image *) NULL) |
| 4006 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4007 | _images=DestroyImageList(_images); |
| 4008 | _images=OptimizeImageLayers(new_images,_exception); |
| 4009 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4010 | break; |
| 4011 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4012 | OptimizeImageTransparency(_images,_exception); |
| 4013 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 4014 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4015 | break; |
| 4016 | } |
| 4017 | case CompositeLayer: |
| 4018 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4019 | Image |
| 4020 | *source; |
| 4021 | |
| 4022 | RectangleInfo |
| 4023 | geometry; |
| 4024 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4025 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4026 | compose; |
| 4027 | |
| 4028 | const char* |
| 4029 | value; |
| 4030 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4031 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4032 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4033 | if (value != (const char *) NULL) |
| 4034 | compose=(CompositeOperator) ParseCommandOption( |
| 4035 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4036 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4037 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4038 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4039 | while (source != (Image *) NULL) |
| 4040 | { |
| 4041 | source=GetNextImageInList(source); |
| 4042 | if ((source != (Image *) NULL) && |
| 4043 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 4044 | break; |
| 4045 | } |
| 4046 | if (source != (Image *) NULL) |
| 4047 | { |
| 4048 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 4049 | (GetNextImageInList(source) == (Image *) NULL)) |
| 4050 | source=(Image *) NULL; |
| 4051 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4052 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4053 | source=SplitImageList(source->previous); |
| 4054 | DeleteImageFromList(&source); |
| 4055 | } |
| 4056 | } |
| 4057 | if (source == (Image *) NULL) |
| 4058 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4059 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4060 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4061 | break; |
| 4062 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4063 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4064 | SetGeometry(_images,&geometry); |
| 4065 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4066 | geometry.width=source->page.width != 0 ? |
| 4067 | source->page.width : source->columns; |
| 4068 | geometry.height=source->page.height != 0 ? |
| 4069 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4070 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 4071 | _images->page.width : _images->columns, |
| 4072 | _images->page.height != 0 ? _images->page.height : |
| 4073 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4074 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4075 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4076 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 4077 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4078 | source=DestroyImageList(source); |
| 4079 | break; |
| 4080 | } |
| 4081 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4082 | break; |
| 4083 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4084 | if (LocaleCompare("limit",option+1) == 0) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 4085 | { |
| 4086 | MagickSizeType |
| 4087 | limit; |
| 4088 | |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 4089 | limit=MagickResourceInfinity; |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 4090 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 4091 | if ( parse < 0 ) |
| 4092 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 4093 | option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4094 | if (LocaleCompare("unlimited",arg2) != 0) |
| 4095 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 4096 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 4097 | break; |
| 4098 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4099 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4100 | } |
| 4101 | case 'm': |
| 4102 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4103 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4104 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4105 | /* DEPRECIATED use +remap */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4106 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4107 | break; |
| 4108 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4109 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4110 | { |
| 4111 | Image |
| 4112 | *morph_image; |
| 4113 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4114 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4115 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4116 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4117 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4118 | _images=DestroyImageList(_images); |
| 4119 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4120 | break; |
| 4121 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4122 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4123 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4124 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4125 | CLIListOperatorImages(cli_wand,"-layer",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4126 | break; |
| 4127 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4128 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4129 | } |
| 4130 | case 'p': |
| 4131 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4132 | if (LocaleCompare("print",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4133 | { |
| 4134 | char |
| 4135 | *string; |
| 4136 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4137 | string=InterpretImageProperties(_image_info,_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4138 | if (string == (char *) NULL) |
| 4139 | break; |
| 4140 | (void) FormatLocaleFile(stdout,"%s",string); |
| 4141 | string=DestroyString(string); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4142 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4143 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4144 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4145 | { |
| 4146 | char |
| 4147 | **arguments; |
| 4148 | |
| 4149 | int |
| 4150 | j, |
| 4151 | number_arguments; |
| 4152 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4153 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4154 | if (arguments == (char **) NULL) |
| 4155 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4156 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4157 | { |
| 4158 | char |
| 4159 | breaker, |
| 4160 | quote, |
| 4161 | *token; |
| 4162 | |
| 4163 | const char |
| 4164 | *arguments; |
| 4165 | |
| 4166 | int |
| 4167 | next, |
| 4168 | status; |
| 4169 | |
| 4170 | size_t |
| 4171 | length; |
| 4172 | |
| 4173 | TokenInfo |
| 4174 | *token_info; |
| 4175 | |
| 4176 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4177 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4178 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4179 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4180 | token=(char *) NULL; |
| 4181 | if (~length >= (MaxTextExtent-1)) |
| 4182 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4183 | sizeof(*token)); |
| 4184 | if (token == (char *) NULL) |
| 4185 | break; |
| 4186 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4187 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4188 | token_info=AcquireTokenInfo(); |
| 4189 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4190 | "\"",'\0',&breaker,&next,"e); |
| 4191 | token_info=DestroyTokenInfo(token_info); |
| 4192 | if (status == 0) |
| 4193 | { |
| 4194 | const char |
| 4195 | *argv; |
| 4196 | |
| 4197 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4198 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4199 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4200 | } |
| 4201 | token=DestroyString(token); |
| 4202 | break; |
| 4203 | } |
| 4204 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4205 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4206 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4207 | for (j=0; j < number_arguments; j++) |
| 4208 | arguments[j]=DestroyString(arguments[j]); |
| 4209 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4210 | break; |
| 4211 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4212 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4213 | } |
| 4214 | case 'r': |
| 4215 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4216 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4217 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4218 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
| 4219 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4220 | break; |
| 4221 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4222 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4223 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4224 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4225 | break; |
| 4226 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4227 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4228 | } |
| 4229 | case 's': |
| 4230 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4231 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4232 | { |
| 4233 | Image |
| 4234 | *smush_image; |
| 4235 | |
| 4236 | ssize_t |
| 4237 | offset; |
| 4238 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4239 | offset=(ssize_t) StringToLong(arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4240 | smush_image=SmushImages(_images,normal_op,offset,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4241 | if (smush_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4242 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4243 | _images=DestroyImageList(_images); |
| 4244 | _images=smush_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4245 | break; |
| 4246 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4247 | if (LocaleCompare("swap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4248 | { |
| 4249 | Image |
| 4250 | *p, |
| 4251 | *q, |
| 4252 | *swap; |
| 4253 | |
| 4254 | ssize_t |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4255 | index, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4256 | swap_index; |
| 4257 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4258 | index=-1; |
| 4259 | swap_index=-2; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4260 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4261 | { |
| 4262 | GeometryInfo |
| 4263 | geometry_info; |
| 4264 | |
| 4265 | MagickStatusType |
| 4266 | flags; |
| 4267 | |
| 4268 | swap_index=(-1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4269 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4270 | index=(ssize_t) geometry_info.rho; |
| 4271 | if ((flags & SigmaValue) != 0) |
| 4272 | swap_index=(ssize_t) geometry_info.sigma; |
| 4273 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4274 | p=GetImageFromList(_images,index); |
| 4275 | q=GetImageFromList(_images,swap_index); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4276 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 4277 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4278 | (void) ThrowMagickException(_exception,GetMagickModule(), |
| 4279 | OptionError,"NoSuchImage","'%s'",_images->filename); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4280 | break; |
| 4281 | } |
| 4282 | if (p == q) |
| 4283 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4284 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4285 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4286 | ReplaceImageInList(&q,swap); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4287 | _images=GetFirstImageInList(q); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4288 | break; |
| 4289 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4290 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4291 | } |
| 4292 | case 'w': |
| 4293 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4294 | if (LocaleCompare("write",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4295 | { |
| 4296 | char |
| 4297 | key[MaxTextExtent]; |
| 4298 | |
| 4299 | Image |
| 4300 | *write_images; |
| 4301 | |
| 4302 | ImageInfo |
| 4303 | *write_info; |
| 4304 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4305 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4306 | (void) DeleteImageRegistry(key); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4307 | write_images=_images; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4308 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4309 | write_images=CloneImageList(_images,_exception); |
| 4310 | write_info=CloneImageInfo(_image_info); |
| 4311 | (void) WriteImages(write_info,write_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4312 | write_info=DestroyImageInfo(write_info); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4313 | if (IfPlusOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4314 | write_images=DestroyImageList(write_images); |
| 4315 | break; |
| 4316 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4317 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4318 | } |
| 4319 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4320 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4321 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4322 | if (new_images == (Image *) NULL) |
| 4323 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4324 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4325 | if (_images != (Image *) NULL) |
| 4326 | _images=DestroyImageList(_images); |
| 4327 | _images=GetFirstImageInList(new_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4328 | return; |
| 4329 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4330 | #undef _image_info |
| 4331 | #undef _images |
| 4332 | #undef _exception |
| 4333 | #undef _draw_info |
| 4334 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4335 | #undef IfNormalOp |
| 4336 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4337 | #undef normal_op |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4338 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4339 | |
| 4340 | /* |
| 4341 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4342 | % % |
| 4343 | % % |
| 4344 | % % |
| 4345 | + C L I S p e c i a l O p e r a t i o n s % |
| 4346 | % % |
| 4347 | % % |
| 4348 | % % |
| 4349 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4350 | % |
| 4351 | % CLISpecialOption() Applies operations that may involve empty image lists |
| 4352 | % and or stacks of image lists or image_info settings. |
| 4353 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4354 | % The classic operators of this type is -read, and image stack operators, |
| 4355 | % which can be applied to empty image lists. |
| 4356 | % |
| 4357 | % Note: unlike other Operators, these may involve other special 'option' |
| 4358 | % character prefixes, other than simply '-' or '+'. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4359 | % |
| 4360 | % The format of the CLISpecialOption method is: |
| 4361 | % |
| 4362 | % void CLISpecialOption(MagickCLI *cli_wand,const char *option, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4363 | % const char *arg1) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4364 | % |
| 4365 | % A description of each parameter follows: |
| 4366 | % |
| 4367 | % o cli_wand: the main CLI Wand to use. |
| 4368 | % |
| 4369 | % o option: The special option (with any switch char) to process |
| 4370 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4371 | % o arg1: Argument for option, if required |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4372 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4373 | % Example Usage... |
| 4374 | % |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4375 | % CLISpecialOperator(cli_wand,"-read","rose:"); |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4376 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4377 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4378 | % |
| 4379 | % cli_wand |
| 4380 | % argc,argv |
| 4381 | % i=index in argv |
| 4382 | % |
| 4383 | % option_info = GetCommandOptionInfo(argv[i]); |
| 4384 | % count=option_info->type; |
| 4385 | % option_type=option_info->flags; |
| 4386 | % |
| 4387 | % if ( (option_type & SpecialOptionFlag) != 0 ) |
| 4388 | % CLISpecialOperator(cli_wand,argv[i], |
| 4389 | % count>=1 ? argv[i+1] : (char *)NULL); |
| 4390 | % i += count+1; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4391 | % |
| 4392 | */ |
| 4393 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4394 | WandExport void CLISpecialOperator(MagickCLI *cli_wand, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4395 | const char *option, const char *arg1) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4396 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4397 | #define _exception (cli_wand->wand.exception) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4398 | |
| 4399 | assert(cli_wand != (MagickCLI *) NULL); |
| 4400 | assert(cli_wand->signature == WandSignature); |
| 4401 | assert(cli_wand->wand.signature == WandSignature); |
| 4402 | if (cli_wand->wand.debug != MagickFalse) |
| 4403 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4404 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4405 | if(cli_wand->wand.images != (Image *)NULL) |
| 4406 | (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4407 | _exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4408 | |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4409 | if (LocaleCompare("respect-parenthesis",option+1) == 0) { |
| 4410 | /* image-setting stack linkage */ |
| 4411 | (void) SetImageOption(cli_wand->wand.image_info,option+1, |
| 4412 | *option == '-' ? "true" : (char *) NULL); |
| 4413 | return; |
| 4414 | } |
| 4415 | if (LocaleCompare("(",option) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4416 | /* stack 'push' images */ |
| 4417 | Stack |
| 4418 | *node; |
| 4419 | |
| 4420 | size_t |
| 4421 | size; |
| 4422 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4423 | size=0; |
| 4424 | node=cli_wand->image_list_stack; |
| 4425 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4426 | size++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4427 | if ( size >= MAX_STACK_DEPTH ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4428 | CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4429 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4430 | if (node == (Stack *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4431 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4432 | "MemoryAllocationFailed",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4433 | node->data = (void *)cli_wand->wand.images; |
| 4434 | cli_wand->wand.images = NewImageList(); |
| 4435 | node->next = cli_wand->image_list_stack; |
| 4436 | cli_wand->image_list_stack = node; |
| 4437 | |
| 4438 | /* handle respect-parenthesis */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4439 | if ( IsMagickTrue(GetImageOption(cli_wand->wand.image_info, |
| 4440 | "respect-parenthesis")) != MagickFalse ) |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4441 | option="{"; /* push image settings too */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4442 | else |
| 4443 | return; |
| 4444 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4445 | if (LocaleCompare("{",option) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4446 | /* stack 'push' of image_info settings */ |
| 4447 | Stack |
| 4448 | *node; |
| 4449 | |
| 4450 | size_t |
| 4451 | size; |
| 4452 | |
| 4453 | size=0; |
| 4454 | node=cli_wand->image_info_stack; |
| 4455 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4456 | size++; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4457 | if ( size >= MAX_STACK_DEPTH ) |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4458 | CLIWandExceptionReturn(OptionError,"CurlyBracesNestedTooDeeply",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4459 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4460 | if (node == (Stack *) NULL) |
| 4461 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4462 | "MemoryAllocationFailed",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4463 | |
| 4464 | node->data = (void *)cli_wand->wand.image_info; |
| 4465 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4466 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4467 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4468 | option); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4469 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4470 | node = (Stack *)RelinquishMagickMemory(node); |
| 4471 | return; |
| 4472 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4473 | |
| 4474 | node->next = cli_wand->image_info_stack; |
| 4475 | cli_wand->image_info_stack = node; |
| 4476 | |
| 4477 | return; |
| 4478 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4479 | if (LocaleCompare(")",option) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4480 | /* pop images from stack */ |
| 4481 | Stack |
| 4482 | *node; |
| 4483 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4484 | node = (void *)cli_wand->image_list_stack; |
| 4485 | if ( node == (Stack *)NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4486 | CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4487 | cli_wand->image_list_stack = node->next; |
| 4488 | |
| 4489 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4490 | cli_wand->wand.images= (Image *)node->data; |
| 4491 | node = (Stack *)RelinquishMagickMemory(node); |
| 4492 | |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4493 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4494 | node = cli_wand->image_info_stack; |
| 4495 | if ( node != (Stack *)NULL) |
| 4496 | { |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4497 | if (IsMagickTrue(GetImageOption((ImageInfo *)node->data, |
| 4498 | "respect-parenthesis")) != MagickFalse ) |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4499 | option="}"; /* pop image settings too */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4500 | else |
| 4501 | return; |
| 4502 | } |
| 4503 | else |
| 4504 | return; |
| 4505 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4506 | if (LocaleCompare("}",option) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4507 | /* pop image_info settings from stack */ |
| 4508 | Stack |
| 4509 | *node; |
| 4510 | |
| 4511 | node = (void *)cli_wand->image_info_stack; |
| 4512 | if ( node == (Stack *)NULL) |
anthony | 4d4f2c7 | 2012-03-22 03:22:03 +0000 | [diff] [blame] | 4513 | CLIWandExceptionReturn(OptionError,"UnbalancedCurlyBraces",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4514 | cli_wand->image_info_stack = node->next; |
| 4515 | |
| 4516 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
| 4517 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4518 | node = (Stack *)RelinquishMagickMemory(node); |
| 4519 | |
| 4520 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4521 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4522 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4523 | |
| 4524 | return; |
| 4525 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4526 | if (LocaleCompare("clone",option+1) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4527 | Image |
| 4528 | *new_images; |
| 4529 | |
| 4530 | if (*option == '+') |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4531 | arg1="-1"; |
| 4532 | if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4533 | CLIWandExceptionReturn(OptionError,"InvalidArgument",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4534 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4535 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4536 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4537 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4538 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
| 4539 | new_images=CloneImages(new_images,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4540 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4541 | CLIWandExceptionReturn(OptionError,"NoSuchImage",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4542 | AppendImageToList(&cli_wand->wand.images,new_images); |
| 4543 | return; |
| 4544 | } |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4545 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4546 | ( LocaleCompare("--",option) == 0 ) ) { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4547 | #if !USE_WAND_METHODS |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4548 | Image * |
| 4549 | new_images; |
| 4550 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4551 | if (cli_wand->wand.image_info->ping != MagickFalse) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4552 | new_images=PingImages(cli_wand->wand.image_info,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4553 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4554 | new_images=ReadImages(cli_wand->wand.image_info,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4555 | AppendImageToList(&cli_wand->wand.images, new_images); |
| 4556 | #else |
| 4557 | /* read images using MagickWand method - no ping */ |
| 4558 | /* This is not working! - it locks up in a CPU loop! */ |
| 4559 | MagickSetLastIterator(&cli_wand->wand); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4560 | MagickReadImage(&cli_wand->wand,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4561 | MagickSetFirstIterator(&cli_wand->wand); |
| 4562 | #endif |
| 4563 | return; |
| 4564 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4565 | /* No-op options */ |
| 4566 | if (LocaleCompare("noop",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4567 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4568 | if (LocaleCompare("sans",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4569 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4570 | if (LocaleCompare("sans0",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4571 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4572 | if (LocaleCompare("sans2",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4573 | return; |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4574 | if (LocaleCompare("list",option+1) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4575 | /* FUTURE: This should really be built into the MagickCore |
| 4576 | It does not actually require any wand or images at all! |
| 4577 | */ |
| 4578 | ssize_t |
| 4579 | list; |
| 4580 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4581 | list=ParseCommandOption(MagickListOptions,MagickFalse, arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame^] | 4582 | if ( list < 0 ) { |
| 4583 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
| 4584 | return; |
| 4585 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4586 | switch (list) |
| 4587 | { |
| 4588 | case MagickCoderOptions: |
| 4589 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4590 | (void) ListCoderInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4591 | break; |
| 4592 | } |
| 4593 | case MagickColorOptions: |
| 4594 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4595 | (void) ListColorInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4596 | break; |
| 4597 | } |
| 4598 | case MagickConfigureOptions: |
| 4599 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4600 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4601 | break; |
| 4602 | } |
| 4603 | case MagickDelegateOptions: |
| 4604 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4605 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4606 | break; |
| 4607 | } |
| 4608 | case MagickFontOptions: |
| 4609 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4610 | (void) ListTypeInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4611 | break; |
| 4612 | } |
| 4613 | case MagickFormatOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4614 | (void) ListMagickInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4615 | break; |
| 4616 | case MagickLocaleOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4617 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4618 | break; |
| 4619 | case MagickLogOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4620 | (void) ListLogInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4621 | break; |
| 4622 | case MagickMagicOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4623 | (void) ListMagicInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4624 | break; |
| 4625 | case MagickMimeOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4626 | (void) ListMimeInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4627 | break; |
| 4628 | case MagickModuleOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4629 | (void) ListModuleInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4630 | break; |
| 4631 | case MagickPolicyOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4632 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4633 | break; |
| 4634 | case MagickResourceOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4635 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4636 | break; |
| 4637 | case MagickThresholdOptions: |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4638 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4639 | break; |
| 4640 | default: |
| 4641 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4642 | _exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4643 | break; |
| 4644 | } |
| 4645 | return; |
| 4646 | } |
| 4647 | |
| 4648 | #if 0 |
| 4649 | // adjust stack handling |
| 4650 | // Other 'special' options this should handle |
| 4651 | // "region" "list" "version" |
| 4652 | // It does not do "exit" however as due to its side-effect requirements |
| 4653 | #endif |
| 4654 | #if 0 |
| 4655 | if ( ( process_flags & ProcessUnknownOptionError ) != 0 ) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4656 | #endif |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4657 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4658 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4659 | #undef _exception |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4660 | } |