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 | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 53 | #include "MagickWand/wand.h" |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 54 | #include "MagickWand/wandcli.h" |
| 55 | #include "MagickWand/wandcli-private.h" |
| 56 | #include "MagickWand/operation.h" |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 57 | #include "MagickCore/monitor-private.h" |
| 58 | #include "MagickCore/thread-private.h" |
| 59 | #include "MagickCore/string-private.h" |
| 60 | |
| 61 | /* |
| 62 | Define declarations. |
| 63 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 64 | #define USE_WAND_METHODS 0 |
| 65 | #define MAX_STACK_DEPTH 32 |
| 66 | #define UNDEFINED_COMPRESSION_QUALITY 0UL |
| 67 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 68 | /* |
| 69 | Constant declaration. (temporary exports) |
| 70 | */ |
| 71 | static const char |
| 72 | BackgroundColor[] = "#fff", /* white */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 73 | BorderColor[] = "#dfdfdf", /* sRGB gray */ |
| 74 | MatteColor[] = "#bdbdbd"; /* slightly darker gray */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 75 | |
| 76 | /* |
| 77 | ** Function to report on the progress of image operations |
| 78 | */ |
| 79 | static MagickBooleanType MonitorProgress(const char *text, |
| 80 | const MagickOffsetType offset,const MagickSizeType extent, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 81 | void *wand_unused(cli_wandent_data)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 82 | { |
| 83 | char |
| 84 | message[MaxTextExtent], |
| 85 | tag[MaxTextExtent]; |
| 86 | |
| 87 | const char |
| 88 | *locale_message; |
| 89 | |
| 90 | register char |
| 91 | *p; |
| 92 | |
| 93 | if (extent < 2) |
| 94 | return(MagickTrue); |
| 95 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 96 | p=strrchr(tag,'/'); |
| 97 | if (p != (char *) NULL) |
| 98 | *p='\0'; |
| 99 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
| 100 | locale_message=GetLocaleMessage(message); |
| 101 | if (locale_message == message) |
| 102 | locale_message=tag; |
| 103 | if (p == (char *) NULL) |
| 104 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 105 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 106 | (100L*offset/(extent-1))); |
| 107 | else |
| 108 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
| 109 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 110 | (100L*offset/(extent-1))); |
| 111 | if (offset == (MagickOffsetType) (extent-1)) |
| 112 | (void) FormatLocaleFile(stderr,"\n"); |
| 113 | (void) fflush(stderr); |
| 114 | return(MagickTrue); |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | ** GetImageCache() will read an image into a image cache if not already |
| 119 | ** present then return the image that is in the cache under that filename. |
| 120 | */ |
| 121 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 122 | ExceptionInfo *exception) |
| 123 | { |
| 124 | char |
| 125 | key[MaxTextExtent]; |
| 126 | |
| 127 | ExceptionInfo |
| 128 | *sans_exception; |
| 129 | |
| 130 | Image |
| 131 | *image; |
| 132 | |
| 133 | ImageInfo |
| 134 | *read_info; |
| 135 | |
| 136 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
| 137 | sans_exception=AcquireExceptionInfo(); |
| 138 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 139 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 140 | if (image != (Image *) NULL) |
| 141 | return(image); |
| 142 | read_info=CloneImageInfo(image_info); |
| 143 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 144 | image=ReadImage(read_info,exception); |
| 145 | read_info=DestroyImageInfo(read_info); |
| 146 | if (image != (Image *) NULL) |
| 147 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 148 | return(image); |
| 149 | } |
| 150 | |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 151 | #if 0 |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 152 | /* |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 153 | FloatListOption() converts a string option of space or comma seperated |
| 154 | numbers into a list of floating point numbers, required by some operations. |
| 155 | */ |
| 156 | static MagickBooleanType FloatListOption(const char *option, |
| 157 | size_t *number_arguments, double **arguments, ExceptionInfo *exception) |
| 158 | { |
| 159 | char |
| 160 | token[MaxTextExtent]; |
| 161 | |
| 162 | const char |
| 163 | *p; |
| 164 | |
| 165 | MagickBooleanType |
| 166 | error; |
| 167 | |
| 168 | register size_t |
| 169 | x; |
| 170 | |
| 171 | } |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 172 | #endif |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 173 | |
| 174 | /* |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 175 | SparseColorOption() parse the complex -sparse-color argument into an |
| 176 | an array of floating point values than call SparseColorImage(). |
| 177 | Argument is a complex mix of floating-point pixel coodinates, and color |
| 178 | specifications (or direct floating point numbers). The number of floats |
| 179 | needed to represent a color varies depending on teh current channel |
| 180 | setting. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 181 | |
| 182 | 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] | 183 | */ |
| 184 | static Image *SparseColorOption(const Image *image, |
| 185 | const SparseColorMethod method,const char *arguments, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 186 | ExceptionInfo *exception) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 187 | { |
| 188 | char |
| 189 | token[MaxTextExtent]; |
| 190 | |
| 191 | const char |
| 192 | *p; |
| 193 | |
| 194 | double |
| 195 | *sparse_arguments; |
| 196 | |
| 197 | Image |
| 198 | *sparse_image; |
| 199 | |
| 200 | PixelInfo |
| 201 | color; |
| 202 | |
| 203 | MagickBooleanType |
| 204 | error; |
| 205 | |
| 206 | register size_t |
| 207 | x; |
| 208 | |
| 209 | size_t |
| 210 | number_arguments, |
| 211 | number_colors; |
| 212 | |
| 213 | assert(image != (Image *) NULL); |
| 214 | assert(image->signature == MagickSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 215 | if (IfMagickTrue(image->debug)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 216 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 217 | assert(exception != (ExceptionInfo *) NULL); |
| 218 | assert(exception->signature == MagickSignature); |
| 219 | /* |
| 220 | Limit channels according to image - and add up number of color channel. |
| 221 | */ |
| 222 | number_colors=0; |
| 223 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 224 | number_colors++; |
| 225 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 226 | number_colors++; |
| 227 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 228 | number_colors++; |
| 229 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 230 | (image->colorspace == CMYKColorspace)) |
| 231 | number_colors++; |
| 232 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 233 | IfMagickTrue(image->matte)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 234 | number_colors++; |
| 235 | |
| 236 | /* |
| 237 | Read string, to determine number of arguments needed, |
| 238 | */ |
| 239 | p=arguments; |
| 240 | x=0; |
| 241 | while( *p != '\0' ) |
| 242 | { |
| 243 | GetMagickToken(p,&p,token); |
| 244 | if ( token[0] == ',' ) continue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 245 | if ( isalpha((int) token[0]) || token[0] == '#' ) |
| 246 | x += number_colors; /* color argument found */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 247 | else |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 248 | x++; /* floating point argument */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 249 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 250 | /* control points and color values */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 251 | error = IsMagickTrue( x % (2+number_colors) ); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 252 | number_arguments=x; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 253 | if ( IfMagickTrue(error) ) { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 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 | "Invalid number of Arguments"); |
| 257 | return( (Image *)NULL); |
| 258 | } |
| 259 | |
| 260 | /* Allocate and fill in the floating point arguments */ |
| 261 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 262 | sizeof(*sparse_arguments)); |
| 263 | if (sparse_arguments == (double *) NULL) { |
| 264 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 265 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 266 | return( (Image *)NULL); |
| 267 | } |
| 268 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 269 | sizeof(*sparse_arguments)); |
| 270 | p=arguments; |
| 271 | x=0; |
| 272 | while( *p != '\0' && x < number_arguments ) { |
| 273 | /* X coordinate */ |
| 274 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 275 | if ( token[0] == '\0' ) break; |
| 276 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 277 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 278 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 279 | "Color found, instead of X-coord"); |
| 280 | error = MagickTrue; |
| 281 | break; |
| 282 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 283 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 284 | /* Y coordinate */ |
| 285 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 286 | if ( token[0] == '\0' ) break; |
| 287 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 288 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 289 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 290 | "Color found, instead of Y-coord"); |
| 291 | error = MagickTrue; |
| 292 | break; |
| 293 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 294 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 295 | /* color name or function given in string argument */ |
| 296 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 297 | if ( token[0] == '\0' ) break; |
| 298 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 299 | /* Color string given */ |
| 300 | (void) QueryColorCompliance(token,AllCompliance,&color, |
| 301 | exception); |
| 302 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 303 | sparse_arguments[x++] = QuantumScale*color.red; |
| 304 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 305 | sparse_arguments[x++] = QuantumScale*color.green; |
| 306 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 307 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 308 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 309 | (image->colorspace == CMYKColorspace)) |
| 310 | sparse_arguments[x++] = QuantumScale*color.black; |
| 311 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 312 | IfMagickTrue(image->matte)) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 313 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 314 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 315 | else { |
| 316 | /* Colors given as a set of floating point values - experimental */ |
| 317 | /* NB: token contains the first floating point value to use! */ |
| 318 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 319 | { |
| 320 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 321 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 322 | break; |
| 323 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 324 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 325 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 326 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 327 | { |
| 328 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 329 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 330 | break; |
| 331 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 332 | token[0] = ','; /* used this token - get another */ |
| 333 | } |
| 334 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 335 | { |
| 336 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 337 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 338 | break; |
| 339 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 340 | token[0] = ','; /* used this token - get another */ |
| 341 | } |
| 342 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 343 | (image->colorspace == CMYKColorspace)) |
| 344 | { |
| 345 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 346 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 347 | break; |
| 348 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 349 | token[0] = ','; /* used this token - get another */ |
| 350 | } |
| 351 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 352 | IfMagickTrue(image->matte)) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 353 | { |
| 354 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 355 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 356 | break; |
| 357 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 358 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 359 | } |
| 360 | } |
| 361 | } |
| 362 | if ( number_arguments != x && !error ) { |
| 363 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 364 | "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 365 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 366 | return( (Image *)NULL); |
| 367 | } |
| 368 | if ( error ) |
| 369 | return( (Image *)NULL); |
| 370 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 371 | /* Call the Sparse Color Interpolation function with the parsed arguments */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 372 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 373 | exception); |
| 374 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 375 | return( sparse_image ); |
| 376 | } |
| 377 | |
| 378 | /* |
| 379 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 380 | % % |
| 381 | % % |
| 382 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 383 | + C L I S e t t i n g O p t i o n I n f o % |
| 384 | % % |
| 385 | % % |
| 386 | % % |
| 387 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 388 | % |
| 389 | % CLISettingOptionInfo() applies a single settings option into a CLI wand |
| 390 | % holding the image_info, draw_info, quantize_info structures that will be |
| 391 | % used when processing the images. |
| 392 | % |
| 393 | % These options do no require images to be present in the CLI wand for them |
| 394 | % to be able to be set, in which case they will generally be applied to image |
| 395 | % that are read in later |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 396 | % |
| 397 | % Options handled by this function are listed in CommandOptions[] of |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 398 | % "option.c" that is one of "SettingOptionFlags" option flags. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 399 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 400 | % The format of the CLISettingOptionInfo method is: |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 401 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 402 | % void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 403 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 404 | % |
| 405 | % A description of each parameter follows: |
| 406 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 407 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 408 | % |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 409 | % o option: The option string to be set |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 410 | % |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 411 | % o arg1, arg2: optional argument strings to the operation |
| 412 | % arg2 is currently only used by "-limit" |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 413 | % |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 414 | % Example usage... |
| 415 | % |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 416 | % CLISettingOptionInfo(cli_wand, "-background", "Red", NULL); // set value |
| 417 | % CLISettingOptionInfo(cli_wand, "-adjoin", NULL, NULL); // set boolean |
| 418 | % CLISettingOptionInfo(cli_wand, "+adjoin", NULL, NULL); // unset |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 419 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 420 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 421 | % |
| 422 | % argc,argv |
| 423 | % i=index in argv |
| 424 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 425 | % option_info = GetCommandOptionInfo(argv[i]); |
| 426 | % count=option_info->type; |
| 427 | % option_type=option_info->flags; |
| 428 | % |
| 429 | % if ( (option_type & SettingOperatorOptionFlags) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 430 | % CLISettingOptionInfo(cli_wand, argv[i], |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 431 | % (count>=1) ? argv[i+1] : (char *)NULL, |
| 432 | % (count>=2) ? argv[i+2] : (char *)NULL); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 433 | % i += count+1; |
| 434 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 435 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 436 | WandExport void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 437 | const char *option,const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 438 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 439 | ssize_t |
| 440 | parse; /* option argument parsing (string to value table lookup) */ |
| 441 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 442 | assert(cli_wand != (MagickCLI *) NULL); |
| 443 | assert(cli_wand->signature == WandSignature); |
| 444 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 445 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 446 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 447 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 448 | #define _image_info (cli_wand->wand.image_info) |
| 449 | #define _exception (cli_wand->wand.exception) |
| 450 | #define _draw_info (cli_wand->draw_info) |
| 451 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 452 | #define IfSetOption (*option=='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 453 | #define ArgBoolean IsMagickTrue(IfSetOption) |
| 454 | #define ArgBooleanNot IsMagickFalse(IfSetOption) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 455 | #define ArgBooleanString (IfSetOption?"true":"false") |
| 456 | #define ArgOption(def) (IfSetOption?arg1:(const char *)(def)) |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 457 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 458 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 459 | { |
| 460 | case 'a': |
| 461 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 462 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 463 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 464 | _image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 465 | break; |
| 466 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 467 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 468 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 469 | CLIWandWarnDepreciated("-draw 'affine ...'"); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 470 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 471 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 472 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 473 | GetAffineMatrix(&_draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 474 | break; |
| 475 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 476 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 477 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 478 | _image_info->antialias = |
| 479 | _draw_info->stroke_antialias = |
| 480 | _draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 481 | break; |
| 482 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 483 | if (LocaleCompare("attenuate",option+1) == 0) |
| 484 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 485 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 486 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 487 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 488 | break; |
| 489 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 490 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 491 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 492 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 493 | break; |
| 494 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 495 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 496 | } |
| 497 | case 'b': |
| 498 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 499 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 500 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 501 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 502 | _image_info only used directly for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 503 | SyncImageSettings() used to set per-image attribute. |
| 504 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 505 | FUTURE: if _image_info->background_color is not set then |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 506 | we should fall back to per-image background_color |
| 507 | |
| 508 | At this time -background will 'wipe out' the per-image |
| 509 | background color! |
| 510 | |
| 511 | Better error handling of QueryColorCompliance() needed. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 512 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 513 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 514 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 515 | &_image_info->background_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 516 | break; |
| 517 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 518 | if (LocaleCompare("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 519 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 520 | /* FUTURE: bias OBSOLETED, replaced by Artifact "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 521 | as it is actually rarely used except in direct convolve operations |
| 522 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 523 | |
| 524 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 525 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 526 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 527 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 528 | (void) SetImageOption(_image_info,"convolve:bias",ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 529 | break; |
| 530 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 531 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 532 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 533 | /* Used as a image chromaticity setting |
| 534 | SyncImageSettings() used to set per-image attribute. |
| 535 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 536 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 537 | break; |
| 538 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 539 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 540 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 541 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 542 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 543 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 544 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 545 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 546 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 547 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 548 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 549 | break; |
| 550 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 551 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 552 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 553 | /* FUTURE: both _image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 554 | SyncImageSettings() used to set per-image attribute. |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 555 | Better error checking of QueryColorCompliance(). |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 556 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 557 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 558 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 559 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 560 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 561 | &_image_info->border_color,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 562 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 563 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 564 | break; |
| 565 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 566 | (void) DeleteImageOption(_image_info,option+1); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 567 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 568 | &_image_info->border_color,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 569 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 570 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 571 | break; |
| 572 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 573 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 574 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 575 | CLIWandWarnDepreciated("-undercolor"); |
| 576 | CLISettingOptionInfo(cli_wand,"-undercolor",arg1, arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 577 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 578 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 579 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 580 | } |
| 581 | case 'c': |
| 582 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 583 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 584 | { |
| 585 | MagickSizeType |
| 586 | limit; |
| 587 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 588 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 589 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 590 | limit=MagickResourceInfinity; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 591 | if (LocaleCompare("unlimited",arg1) != 0) |
| 592 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 593 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 594 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 595 | break; |
| 596 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 597 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 598 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 599 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 600 | break; |
| 601 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 602 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 603 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 604 | arg1=ArgOption("default"); |
| 605 | parse=ParseChannelOption(arg1); |
| 606 | if (parse < 0) |
| 607 | CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType", |
| 608 | option,arg1); |
| 609 | _image_info->channel=(ChannelType) parse; |
| 610 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 611 | break; |
| 612 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 613 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 614 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 615 | /* Setting used for new images via AquireImage() |
| 616 | But also used as a SimpleImageOperator |
| 617 | Undefined colorspace means don't modify images on |
| 618 | read or as a operation */ |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 619 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 620 | ArgOption("undefined")); |
| 621 | if (parse < 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 622 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 623 | option,arg1); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 624 | _image_info->colorspace=(ColorspaceType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 625 | break; |
| 626 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 627 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 628 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 629 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 630 | break; |
| 631 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 632 | if (LocaleCompare("compose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 633 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 634 | /* FUTURE: _image_info should be used, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 635 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 636 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 637 | This setting should NOT be used to set image 'compose' |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 638 | "-layer" operators shoud use _image_info if defined otherwise |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 639 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 640 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 641 | parse = ParseCommandOption(MagickComposeOptions,MagickFalse, |
| 642 | ArgOption("undefined")); |
| 643 | if (parse < 0) |
| 644 | CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", |
| 645 | option,arg1); |
| 646 | _image_info->compose=(CompositeOperator) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 647 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 648 | break; |
| 649 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 650 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 651 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 652 | /* FUTURE: What should be used? _image_info or ImageOption ??? |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 653 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 654 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 655 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 656 | The coders appears to use _image_info, not Image_Option |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 657 | however the image attribute (for save) is set from the |
| 658 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 659 | |
| 660 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 661 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 662 | parse = ParseCommandOption(MagickCompressOptions,MagickFalse, |
| 663 | ArgOption("undefined")); |
| 664 | if (parse < 0) |
| 665 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", |
| 666 | option,arg1); |
| 667 | _image_info->compression=(CompressionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 668 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 669 | break; |
| 670 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 671 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 672 | } |
| 673 | case 'd': |
| 674 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 675 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 676 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 677 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 678 | arg1=ArgOption("none"); |
| 679 | parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); |
| 680 | if (parse < 0) |
| 681 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", |
| 682 | option,arg1); |
| 683 | (void) SetLogEventMask(arg1); |
| 684 | _image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 685 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 686 | break; |
| 687 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 688 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 689 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 690 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 691 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 692 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 693 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 694 | else |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 695 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 696 | break; |
| 697 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 698 | /* DefineImageOption() equals SetImageOption() but with '=' */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 699 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 700 | (void) DefineImageOption(_image_info,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 701 | else if (IsMagickFalse(DeleteImageOption(_image_info,arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 702 | CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 703 | break; |
| 704 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 705 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 706 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 707 | /* Only used for new images via AcquireImage() |
| 708 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 709 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 710 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 711 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 712 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 713 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 714 | break; |
| 715 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 716 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 717 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 718 | /* FUTURE: strings used in _image_info attr and _draw_info! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 719 | Basically as density can be in a XxY form! |
| 720 | |
| 721 | SyncImageSettings() used to set per-image attribute. |
| 722 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 723 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 724 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 725 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 726 | (void) CloneString(&_image_info->density,ArgOption(NULL)); |
| 727 | (void) CloneString(&_draw_info->density,_image_info->density); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 728 | break; |
| 729 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 730 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 731 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 732 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 733 | SyncImageSettings() used to set per-image attribute. |
| 734 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 735 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 736 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 737 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 738 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 739 | break; |
| 740 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 741 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 742 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 743 | /* Image Option is only used to set _draw_info */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 744 | arg1=ArgOption("undefined"); |
| 745 | parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); |
| 746 | if (parse < 0) |
| 747 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", |
| 748 | option,arg1); |
| 749 | _draw_info->direction=(DirectionType) parse; |
| 750 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 751 | break; |
| 752 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 753 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 754 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 755 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); |
| 756 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 757 | break; |
| 758 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 759 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 760 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 761 | /* only used in setting new images */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 762 | arg1=ArgOption("undefined"); |
| 763 | parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); |
| 764 | if (parse < 0) |
| 765 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", |
| 766 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 767 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 768 | break; |
| 769 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 770 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 771 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 772 | /* _image_info attr (on/off), _quantize_info attr (on/off) |
| 773 | but also ImageInfo and _quantize_info method! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 774 | FUTURE: merge the duality of the dithering options |
| 775 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 776 | _image_info->dither = _quantize_info->dither = ArgBoolean; |
| 777 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); |
| 778 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 779 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 780 | if (_quantize_info->dither_method == NoDitherMethod) |
| 781 | _image_info->dither = _quantize_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 782 | break; |
| 783 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 784 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 785 | } |
| 786 | case 'e': |
| 787 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 788 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 789 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 790 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); |
| 791 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 792 | break; |
| 793 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 794 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 795 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 796 | /* Both _image_info attr and ImageInfo */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 797 | arg1 = ArgOption("undefined"); |
| 798 | parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); |
| 799 | if (parse < 0) |
| 800 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", |
| 801 | option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 802 | /* FUTURE: check alloc/free of endian string! - remove? */ |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 803 | _image_info->endian=(EndianType) (*arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 804 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 805 | break; |
| 806 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 807 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 808 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 809 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 810 | break; |
| 811 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 812 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 813 | } |
| 814 | case 'f': |
| 815 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 816 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 817 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 818 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 819 | break; |
| 820 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 821 | if (LocaleCompare("fill",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 | /* Set "fill" OR "fill-pattern" in _draw_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 824 | The original fill color is preserved if a fill-pattern is given. |
| 825 | That way it does not effect other operations that directly using |
| 826 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 827 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 828 | MagickBooleanType |
| 829 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 830 | |
| 831 | ExceptionInfo |
| 832 | *sans; |
| 833 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 834 | PixelInfo |
| 835 | color; |
| 836 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 837 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 838 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 839 | if (_draw_info->fill_pattern != (Image *) NULL) |
| 840 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 841 | |
| 842 | /* is it a color or a image? -- ignore exceptions */ |
| 843 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 844 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 845 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 846 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 847 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 848 | _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 849 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 850 | _draw_info->fill=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 851 | break; |
| 852 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 853 | if (LocaleCompare("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 854 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 855 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 856 | arg1 = ArgOption("undefined"); |
| 857 | parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); |
| 858 | if (parse < 0) |
| 859 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", |
| 860 | option,arg1); |
| 861 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 862 | break; |
| 863 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 864 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 865 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 866 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); |
| 867 | (void) CloneString(&_image_info->font,_draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 868 | break; |
| 869 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 870 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 871 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 872 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 873 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 874 | register const char |
| 875 | *q; |
| 876 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 877 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 878 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 879 | _image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 880 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 881 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 882 | break; |
| 883 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 884 | if (LocaleCompare("fuzz",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 885 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 886 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 887 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 888 | SyncImageSettings() used to set per-image attribute. |
| 889 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 890 | FUTURE: Can't find anything else using _image_info->fuzz directly! |
| 891 | remove direct sttribute from image_info |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 892 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 893 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 894 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 895 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 896 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 897 | QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 898 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 899 | break; |
| 900 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 901 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 902 | } |
| 903 | case 'g': |
| 904 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 905 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 906 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 907 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 908 | arg1 = ArgOption("none"); |
| 909 | parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); |
| 910 | if (parse < 0) |
| 911 | CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", |
| 912 | option,arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 913 | _draw_info->gravity=(GravityType) parse; |
anthony | e849097 | 2012-04-03 13:16:01 +0000 | [diff] [blame] | 914 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 915 | break; |
| 916 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 917 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 918 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 919 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 920 | SyncImageSettings() used to set per-image attribute. |
| 921 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 922 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 923 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 924 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 925 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 926 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 927 | break; |
| 928 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 929 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 930 | } |
| 931 | case 'i': |
| 932 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 933 | if (LocaleCompare("intent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 934 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 935 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 936 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 937 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 938 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 939 | arg1 = ArgOption("indefined"); |
| 940 | parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); |
| 941 | if (parse < 0) |
| 942 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", |
| 943 | option,arg1); |
| 944 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 945 | break; |
| 946 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 947 | if (LocaleCompare("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 948 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 949 | /* _image_info is directly used by coders (so why an image setting?) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 950 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 951 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 952 | arg1 = ArgOption("undefined"); |
| 953 | parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); |
| 954 | if (parse < 0) |
| 955 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", |
| 956 | option,arg1); |
| 957 | _image_info->interlace=(InterlaceType) parse; |
| 958 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 959 | break; |
| 960 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 961 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 962 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 963 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 964 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 965 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 966 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 967 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 968 | break; |
| 969 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 970 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 971 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 972 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 973 | arg1 = ArgOption("undefined"); |
| 974 | parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); |
| 975 | if (parse < 0) |
| 976 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", |
| 977 | option,arg1); |
| 978 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 979 | break; |
| 980 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 981 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 982 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 983 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 984 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 985 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 986 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 987 | break; |
| 988 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 989 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 990 | } |
| 991 | case 'k': |
| 992 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 993 | if (LocaleCompare("kerning",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 994 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 995 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 996 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 997 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 998 | _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 999 | break; |
| 1000 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1001 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1002 | } |
| 1003 | case 'l': |
| 1004 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1005 | if (LocaleCompare("label",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1006 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1007 | /* only used for new images - not in SyncImageOptions() */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1008 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1009 | break; |
| 1010 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1011 | if (LocaleCompare("limit",option+1) == 0) |
| 1012 | { |
| 1013 | MagickSizeType |
| 1014 | limit; |
| 1015 | |
| 1016 | limit=MagickResourceInfinity; |
| 1017 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 1018 | if ( parse < 0 ) |
| 1019 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 1020 | option,arg1); |
| 1021 | if (LocaleCompare("unlimited",arg2) != 0) |
| 1022 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
| 1023 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
| 1024 | break; |
| 1025 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1026 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1027 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1028 | if (IfSetOption) { |
| 1029 | if ((strchr(arg1,'%') == (char *) NULL)) |
| 1030 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1031 | (void) SetLogFormat(arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1032 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1033 | break; |
| 1034 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1035 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1036 | { |
| 1037 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1038 | break; |
| 1039 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1040 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1041 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1042 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1043 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1044 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1045 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1046 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1047 | break; |
| 1048 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1049 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1050 | } |
| 1051 | case 'm': |
| 1052 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1053 | if (LocaleCompare("mattecolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1054 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1055 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1056 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1057 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1058 | &_image_info->matte_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1059 | break; |
| 1060 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1061 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1062 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1063 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1064 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1065 | break; |
| 1066 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1067 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1068 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1069 | /* Setting (used by some input coders!) -- why? |
| 1070 | Warning: This is also Special '-type' SimpleOperator |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1071 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1072 | _image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1073 | break; |
| 1074 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1075 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1076 | } |
| 1077 | case 'o': |
| 1078 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1079 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1080 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1081 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1082 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1083 | FUTURE: make set meta-data operator instead. |
| 1084 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1085 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1086 | parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
| 1087 | ArgOption("undefined")); |
| 1088 | if (parse < 0) |
| 1089 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", |
| 1090 | option,arg1); |
| 1091 | _image_info->orientation=(OrientationType)parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1092 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1093 | break; |
| 1094 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1095 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1096 | } |
| 1097 | case 'p': |
| 1098 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1099 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1100 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1101 | /* Only used for new images and image generators. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1102 | SyncImageSettings() used to set per-image attribute. ????? |
| 1103 | That last is WRONG!!!! |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1104 | FUTURE: adjust named 'page' sizes according density |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1105 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1106 | char |
| 1107 | *canonical_page, |
| 1108 | page[MaxTextExtent]; |
| 1109 | |
| 1110 | const char |
| 1111 | *image_option; |
| 1112 | |
| 1113 | MagickStatusType |
| 1114 | flags; |
| 1115 | |
| 1116 | RectangleInfo |
| 1117 | geometry; |
| 1118 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1119 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1120 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1121 | (void) DeleteImageOption(_image_info,option+1); |
| 1122 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1123 | break; |
| 1124 | } |
| 1125 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1126 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1127 | if (image_option != (const char *) NULL) |
| 1128 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1129 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1130 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1131 | canonical_page=DestroyString(canonical_page); |
| 1132 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1133 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1134 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1135 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1136 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1137 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1138 | (void) SetImageOption(_image_info,option+1,page); |
| 1139 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1140 | break; |
| 1141 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1142 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1143 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1144 | _image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1145 | break; |
| 1146 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1147 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1148 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1149 | if (IfSetOption) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1150 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1151 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1152 | _image_info->pointsize = |
| 1153 | _draw_info->pointsize = |
| 1154 | StringToDouble(arg1,(char **) NULL); |
| 1155 | } |
| 1156 | else { |
| 1157 | _image_info->pointsize=0.0; /* unset pointsize */ |
| 1158 | _draw_info->pointsize=12.0; |
| 1159 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1160 | break; |
| 1161 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1162 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1163 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1164 | arg1=ArgOption("-1"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1165 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1166 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1167 | (void) SetMagickPrecision(StringToInteger(arg1)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1168 | break; |
| 1169 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1170 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1171 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1172 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1173 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1174 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1175 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1176 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1177 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1178 | break; |
| 1179 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1180 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1181 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1182 | } |
| 1183 | case 'q': |
| 1184 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1185 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1186 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1187 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1188 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1189 | _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1) |
| 1190 | : UNDEFINED_COMPRESSION_QUALITY; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1191 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1192 | break; |
| 1193 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1194 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1195 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1196 | /* Just a set direct in _quantize_info */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1197 | arg1=ArgOption("undefined"); |
| 1198 | parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
| 1199 | if (parse < 0) |
| 1200 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 1201 | option,arg1); |
| 1202 | _quantize_info->colorspace=(ColorspaceType)parse; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1203 | break; |
| 1204 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1205 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1206 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1207 | /* FUTURE: if two -quiet is performed you can not do +quiet! |
| 1208 | This needs to be checked over thoughly. |
| 1209 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1210 | static WarningHandler |
| 1211 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1212 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1213 | WarningHandler |
| 1214 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1215 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1216 | if ( tmp != (WarningHandler) NULL) |
| 1217 | warning_handler = tmp; /* remember the old handler */ |
| 1218 | if (!IfSetOption) /* set the old handler */ |
| 1219 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1220 | break; |
| 1221 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1222 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1223 | } |
| 1224 | case 'r': |
| 1225 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1226 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1227 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1228 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1229 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1230 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1231 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1232 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1233 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1234 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1235 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1236 | break; |
| 1237 | } |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1238 | if (LocaleCompare("regard-warnings",option+1) == 0) |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 1239 | /* FUTURE: to be replaced by a 'fatal-level' type setting */ |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1240 | break; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1241 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1242 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1243 | /* _draw_info only setting */ |
| 1244 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1245 | break; |
| 1246 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1247 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
| 1248 | { |
| 1249 | /* link image and setting stacks - option is itself saved on stack! */ |
| 1250 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1251 | break; |
| 1252 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1253 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1254 | } |
| 1255 | case 's': |
| 1256 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1257 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1258 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1259 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1260 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1261 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1262 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1263 | break; |
| 1264 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1265 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1266 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1267 | /* SyncImageSettings() used to set this as a per-image attribute. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1268 | What ??? Why ???? |
| 1269 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1270 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1271 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1272 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1273 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1274 | break; |
| 1275 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1276 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1277 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1278 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1279 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame^] | 1280 | SetRandomSecretKey( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1281 | IfSetOption ? (size_t) StringToUnsignedLong(arg1) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1282 | : (size_t) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1283 | break; |
| 1284 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1285 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1286 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1287 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1288 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1289 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1290 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1291 | break; |
| 1292 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1293 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1294 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1295 | arg1=ArgOption("undefined"); |
| 1296 | parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1); |
| 1297 | if (parse < 0) |
| 1298 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStretchType", |
| 1299 | option,arg1); |
| 1300 | _draw_info->stretch=(StretchType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1301 | break; |
| 1302 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1303 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1304 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1305 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1306 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1307 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1308 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1309 | MagickBooleanType |
| 1310 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1311 | |
| 1312 | ExceptionInfo |
| 1313 | *sans; |
| 1314 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1315 | PixelInfo |
| 1316 | color; |
| 1317 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1318 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1319 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1320 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1321 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1322 | |
| 1323 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1324 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1325 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1326 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1327 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1328 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1329 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1330 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1331 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1332 | break; |
| 1333 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1334 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1335 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1336 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1337 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1338 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1339 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1340 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1341 | break; |
| 1342 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1343 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1344 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1345 | arg1=ArgOption("undefined"); |
| 1346 | parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1); |
| 1347 | if (parse < 0) |
| 1348 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStyleType", |
| 1349 | option,arg1); |
| 1350 | _draw_info->style=(StyleType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1351 | break; |
| 1352 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1353 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1354 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1355 | /* FUTURE: syncronize to storage - but what does that mean? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1356 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1357 | break; |
| 1358 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1359 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1360 | } |
| 1361 | case 't': |
| 1362 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1363 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1364 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1365 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1366 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1367 | break; |
| 1368 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1369 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1370 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1371 | /* FUTURE: move _image_info string to option splay-tree |
| 1372 | Other than "montage" what uses "texture" ???? |
| 1373 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1374 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1375 | break; |
| 1376 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1377 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1378 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1379 | _draw_info->fill_pattern=IfSetOption |
| 1380 | ?GetImageCache(_image_info,arg1,_exception) |
| 1381 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1382 | break; |
| 1383 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1384 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1385 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1386 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1387 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1388 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1389 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1390 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1391 | break; |
| 1392 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1393 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1394 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1395 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1396 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1397 | SyncImageSettings() used to set per-image attribute. |
| 1398 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1399 | Note that +transparent-color, means fall-back to image |
| 1400 | attribute so ImageOption is deleted, not set to a default. |
| 1401 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1402 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1403 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1404 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1405 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1406 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1407 | break; |
| 1408 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1409 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1410 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1411 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1412 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1413 | break; |
| 1414 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1415 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1416 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1417 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1418 | parse=ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 1419 | ArgOption("undefined")); |
| 1420 | if (parse < 0) |
| 1421 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageType", |
| 1422 | option,arg1); |
| 1423 | _image_info->type=(ImageType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1424 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1425 | break; |
| 1426 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1427 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1428 | } |
| 1429 | case 'u': |
| 1430 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1431 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1432 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1433 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1434 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1435 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1436 | break; |
| 1437 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1438 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1439 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1440 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1441 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1442 | FUTURE: this probably should be part of the density setting |
| 1443 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1444 | parse=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
| 1445 | ArgOption("undefined")); |
| 1446 | if (parse < 0) |
| 1447 | CLIWandExceptArgBreak(OptionError,"UnrecognizedUnitsType", |
| 1448 | option,arg1); |
| 1449 | _image_info->units=(ResolutionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1450 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1451 | break; |
| 1452 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1453 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1454 | } |
| 1455 | case 'v': |
| 1456 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1457 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1458 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1459 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1460 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1461 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1462 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1463 | _image_info->verbose= ArgBoolean; |
| 1464 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1465 | break; |
| 1466 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1467 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1468 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1469 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1470 | Only used by coder FPX |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1471 | And it only tests existance, not its content! |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1472 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1473 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1474 | break; |
| 1475 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1476 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1477 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1478 | /* SyncImageSettings() used to set per-image attribute. |
| 1479 | This is VERY deep in the image caching structure. |
| 1480 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1481 | parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 1482 | ArgOption("undefined")); |
| 1483 | if (parse < 0) |
| 1484 | CLIWandExceptArgBreak(OptionError,"UnrecognizedVirtualPixelMethod", |
| 1485 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1486 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1487 | break; |
| 1488 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1489 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1490 | } |
| 1491 | case 'w': |
| 1492 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1493 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1494 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1495 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1496 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1497 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1498 | arg1=ArgOption("all"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1499 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1500 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1501 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1502 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1503 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1504 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1505 | if (_draw_info->weight <= 800) |
| 1506 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1507 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1508 | if (_draw_info->weight >= 100) |
| 1509 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1510 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1511 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1512 | break; |
| 1513 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1514 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1515 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1516 | /* Used as a image chromaticity setting |
| 1517 | SyncImageSettings() used to set per-image attribute. |
| 1518 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1519 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1520 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1521 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1522 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1523 | break; |
| 1524 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1525 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1526 | } |
| 1527 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1528 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1529 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1530 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1531 | #undef _image_info |
| 1532 | #undef _exception |
| 1533 | #undef _draw_info |
| 1534 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1535 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1536 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1537 | #undef ArgBooleanNot |
| 1538 | #undef ArgBooleanString |
| 1539 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1540 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1541 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1542 | } |
| 1543 | |
| 1544 | /* |
| 1545 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1546 | % % |
| 1547 | % % |
| 1548 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1549 | + 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] | 1550 | % % |
| 1551 | % % |
| 1552 | % % |
| 1553 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1554 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1555 | % WandSimpleOperatorImages() applys one simple image operation given to all |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1556 | % the images in the CLI wand, with the settings that was previously saved in |
| 1557 | % the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1558 | % |
| 1559 | % 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] | 1560 | % extra settings that were already saved in the wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1561 | % |
anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1562 | % The format of the WandSimpleOperatorImage method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1563 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1564 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1565 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1566 | % |
| 1567 | % A description of each parameter follows: |
| 1568 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1569 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1570 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1571 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1572 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1573 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1574 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1575 | % Any problems will be added to the 'exception' entry of the given wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1576 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1577 | % Example usage... |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1578 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1579 | % CLISimpleOperatorImages(cli_wand, "-crop","100x100+20+30",NULL); |
| 1580 | % CLISimpleOperatorImages(cli_wand, "+repage",NULL,NULL); |
| 1581 | % CLISimpleOperatorImages(cli_wand, "+distort","SRT","45"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1582 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1583 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1584 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1585 | % cli_wand |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1586 | % argc,argv |
| 1587 | % i=index in argv |
| 1588 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 1589 | % option_info = GetCommandOptionInfo(argv[i]); |
| 1590 | % count=option_info->type; |
| 1591 | % option_type=option_info->flags; |
| 1592 | % |
| 1593 | % if ( (option_type & SimpleOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1594 | % CLISimpleOperatorImages(cli_wand, argv[i], |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1595 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 1596 | % count>=2 ? argv[i+2] : (char *)NULL ); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1597 | % i += count+1; |
| 1598 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1599 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1600 | |
| 1601 | /* |
| 1602 | Internal subrountine to apply one simple image operation to the current |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1603 | image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1604 | |
| 1605 | The image in the list may be modified in three different ways... |
| 1606 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1607 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1608 | * one image replace by a list of images (-separate and -crop only!) |
| 1609 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1610 | In each case the result replaces the single original image in the list, as |
| 1611 | well as the pointer to the modified image (last image added if replaced by a |
| 1612 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1613 | |
| 1614 | As the image pointed to may be replaced, the first image in the list may |
| 1615 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1616 | return the Image pointer to the first image in list. |
| 1617 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1618 | static void CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1619 | const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1620 | { |
| 1621 | Image * |
| 1622 | new_image; |
| 1623 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1624 | GeometryInfo |
| 1625 | geometry_info; |
| 1626 | |
| 1627 | RectangleInfo |
| 1628 | geometry; |
| 1629 | |
| 1630 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1631 | flags; |
| 1632 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1633 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1634 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1635 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 1636 | #define _image_info (cli_wand->wand.image_info) |
| 1637 | #define _image (cli_wand->wand.images) |
| 1638 | #define _exception (cli_wand->wand.exception) |
| 1639 | #define _draw_info (cli_wand->draw_info) |
| 1640 | #define _quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1641 | #define IfNormalOp (*option=='-') |
| 1642 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1643 | #define normal_op IsMagickTrue(IfNormalOp) |
| 1644 | #define plus_alt_op IsMagickFalse(IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1645 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1646 | assert(cli_wand != (MagickCLI *) NULL); |
| 1647 | assert(cli_wand->signature == WandSignature); |
| 1648 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1649 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1650 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1651 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1652 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1653 | (void) SyncImageSettings(_image_info,_image,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1654 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1655 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1656 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1657 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1658 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1659 | /* FUTURE: We may need somthing a little more optimized than this! |
| 1660 | Perhaps, do the 'sync' if 'settings tainted' before next operator. |
| 1661 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1662 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1663 | { |
| 1664 | case 'a': |
| 1665 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1666 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1667 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1668 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1669 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1670 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1671 | if ((flags & SigmaValue) == 0) |
| 1672 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1673 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1674 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1675 | break; |
| 1676 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1677 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1678 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1679 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1680 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1681 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1682 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1683 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1684 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1685 | break; |
| 1686 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1687 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1688 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1689 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1690 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1691 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1692 | if ((flags & SigmaValue) == 0) |
| 1693 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1694 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1695 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1696 | break; |
| 1697 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1698 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1699 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1700 | parse=ParseCommandOption(MagickAlphaOptions,MagickFalse,arg1); |
| 1701 | if (parse < 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1702 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelType", |
| 1703 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1704 | (void) SetImageAlphaChannel(_image,(AlphaChannelType)parse, |
| 1705 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1706 | break; |
| 1707 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1708 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1709 | { |
| 1710 | char |
| 1711 | *text, |
| 1712 | geometry[MaxTextExtent]; |
| 1713 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1714 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1715 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1716 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1717 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1718 | if ((flags & SigmaValue) == 0) |
| 1719 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1720 | text=InterpretImageProperties(_image_info,_image,arg2, |
| 1721 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1722 | if (text == (char *) NULL) |
| 1723 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1724 | (void) CloneString(&_draw_info->text,text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1725 | text=DestroyString(text); |
| 1726 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1727 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1728 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1729 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1730 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1731 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1732 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1733 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1734 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1735 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1736 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1737 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1738 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1739 | break; |
| 1740 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1741 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1742 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1743 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1744 | break; |
| 1745 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1746 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1747 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1748 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1749 | break; |
| 1750 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1751 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1752 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1753 | /* This should probably be a MagickCore function */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1754 | switch (_image->orientation) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1755 | { |
| 1756 | case TopRightOrientation: |
| 1757 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1758 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1759 | break; |
| 1760 | } |
| 1761 | case BottomRightOrientation: |
| 1762 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1763 | new_image=RotateImage(_image,180.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1764 | break; |
| 1765 | } |
| 1766 | case BottomLeftOrientation: |
| 1767 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1768 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1769 | break; |
| 1770 | } |
| 1771 | case LeftTopOrientation: |
| 1772 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1773 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1774 | break; |
| 1775 | } |
| 1776 | case RightTopOrientation: |
| 1777 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1778 | new_image=RotateImage(_image,90.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1779 | break; |
| 1780 | } |
| 1781 | case RightBottomOrientation: |
| 1782 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1783 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1784 | break; |
| 1785 | } |
| 1786 | case LeftBottomOrientation: |
| 1787 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1788 | new_image=RotateImage(_image,270.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1789 | break; |
| 1790 | } |
| 1791 | default: |
| 1792 | break; |
| 1793 | } |
| 1794 | if (new_image != (Image *) NULL) |
| 1795 | new_image->orientation=TopLeftOrientation; |
| 1796 | break; |
| 1797 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1798 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1799 | } |
| 1800 | case 'b': |
| 1801 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1802 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1803 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1804 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1805 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1806 | (void) BlackThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1807 | break; |
| 1808 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1809 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1810 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1811 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1812 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1813 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1814 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1815 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1816 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1817 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1818 | break; |
| 1819 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1820 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1821 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1822 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1823 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1824 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1825 | if ((flags & SigmaValue) == 0) |
| 1826 | geometry_info.sigma=1.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1827 | new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1828 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1829 | break; |
| 1830 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1831 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1832 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1833 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1834 | compose; |
| 1835 | |
| 1836 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1837 | value; |
| 1838 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1839 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1840 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1841 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1842 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1843 | if (value != (const char *) NULL) |
| 1844 | compose=(CompositeOperator) ParseCommandOption( |
| 1845 | MagickComposeOptions,MagickFalse,value); |
| 1846 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1847 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1848 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1849 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1850 | if ((flags & SigmaValue) == 0) |
| 1851 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1852 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1853 | break; |
| 1854 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1855 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1856 | { |
| 1857 | double |
| 1858 | brightness, |
| 1859 | contrast; |
| 1860 | |
| 1861 | GeometryInfo |
| 1862 | geometry_info; |
| 1863 | |
| 1864 | MagickStatusType |
| 1865 | flags; |
| 1866 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1867 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1868 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1869 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1870 | brightness=geometry_info.rho; |
| 1871 | contrast=0.0; |
| 1872 | if ((flags & SigmaValue) != 0) |
| 1873 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1874 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1875 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1876 | break; |
| 1877 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1878 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1879 | } |
| 1880 | case 'c': |
| 1881 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1882 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1883 | { |
| 1884 | char |
| 1885 | *color_correction_collection; |
| 1886 | |
| 1887 | /* |
| 1888 | Color correct with a color decision list. |
| 1889 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1890 | color_correction_collection=FileToString(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1891 | if (color_correction_collection == (char *) NULL) |
| 1892 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1893 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 1894 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1895 | break; |
| 1896 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1897 | if (LocaleCompare("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1898 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1899 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1900 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1901 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1902 | if ((flags & SigmaValue) == 0) |
| 1903 | geometry_info.sigma=1.0; |
| 1904 | if ((flags & XiValue) == 0) |
| 1905 | geometry_info.xi=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1906 | new_image=CharcoalImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1907 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1908 | break; |
| 1909 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1910 | if (LocaleCompare("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1911 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1912 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1913 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1914 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 1915 | new_image=ChopImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1916 | break; |
| 1917 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1918 | if (LocaleCompare("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1919 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1920 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1921 | break; |
| 1922 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1923 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1924 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1925 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1926 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1927 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1928 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1929 | break; |
| 1930 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1931 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1932 | { |
| 1933 | CacheView |
| 1934 | *mask_view; |
| 1935 | |
| 1936 | Image |
| 1937 | *mask_image; |
| 1938 | |
| 1939 | register Quantum |
| 1940 | *restrict q; |
| 1941 | |
| 1942 | register ssize_t |
| 1943 | x; |
| 1944 | |
| 1945 | ssize_t |
| 1946 | y; |
| 1947 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1948 | if (IfPlusOp) { |
| 1949 | /* "+clip-mask" Remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1950 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1951 | break; |
| 1952 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1953 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1954 | if (mask_image == (Image *) NULL) |
| 1955 | break; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1956 | if (IfMagickFalse(SetImageStorageClass(mask_image,DirectClass,_exception))) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1957 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1958 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1959 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1960 | mask_view=AcquireCacheView(mask_image); |
| 1961 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1962 | { |
| 1963 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1964 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1965 | if (q == (Quantum *) NULL) |
| 1966 | break; |
| 1967 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1968 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1969 | if (IfMagickFalse(mask_image->matte)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1970 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1971 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1972 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1973 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1974 | q+=GetPixelChannels(mask_image); |
| 1975 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1976 | if (IfMagickFalse(SyncCacheViewAuthenticPixels(mask_view,_exception))) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1977 | break; |
| 1978 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1979 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1980 | mask_view=DestroyCacheView(mask_view); |
| 1981 | mask_image->matte=MagickTrue; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1982 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1983 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1984 | break; |
| 1985 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1986 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1987 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1988 | (void) ClipImagePath(_image,arg1,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1989 | break; |
| 1990 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1991 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1992 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1993 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1994 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1995 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1996 | break; |
| 1997 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1998 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1999 | { |
| 2000 | KernelInfo |
| 2001 | *kernel; |
| 2002 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2003 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2004 | if (kernel == (KernelInfo *) NULL) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2005 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2006 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2007 | kernel=DestroyKernelInfo(kernel); |
| 2008 | break; |
| 2009 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2010 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2011 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2012 | /* Reduce the number of colors in the image. |
| 2013 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2014 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2015 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2016 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2017 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2018 | if ((_image->storage_class == DirectClass) || |
| 2019 | _image->colors > _quantize_info->number_colors) |
| 2020 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2021 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2022 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2023 | break; |
| 2024 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2025 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2026 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2027 | /* WARNING: this is both a image_info setting (already done) |
| 2028 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2029 | |
| 2030 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2031 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2032 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2033 | Note that +colorspace sets "undefined" or no effect on |
| 2034 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2035 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2036 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2037 | (void) TransformImageColorspace(_image, |
| 2038 | IfNormalOp ? _image_info->colorspace : RGBColorspace, |
| 2039 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2040 | break; |
| 2041 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2042 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2043 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2044 | CLIWandWarnDepreciated(normal_op?"-level":"+level"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2045 | (void) ContrastImage(_image,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2046 | break; |
| 2047 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2048 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2049 | { |
| 2050 | double |
| 2051 | black_point, |
| 2052 | white_point; |
| 2053 | |
| 2054 | MagickStatusType |
| 2055 | flags; |
| 2056 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2057 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2058 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2059 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2060 | black_point=geometry_info.rho; |
| 2061 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2062 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2063 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2064 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2065 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2066 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2067 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2068 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2069 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2070 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2071 | break; |
| 2072 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2073 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2074 | { |
| 2075 | KernelInfo |
| 2076 | *kernel_info; |
| 2077 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2078 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2079 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2080 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 2081 | /* kernel_info->bias=_image->bias; -- FUTURE: check this path! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2082 | new_image=ConvolveImage(_image,kernel_info,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2083 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2084 | break; |
| 2085 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2086 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2087 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2088 | /* WARNING: This can generate multiple images! */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2089 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2090 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2091 | new_image=CropImageToTiles(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2092 | break; |
| 2093 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2094 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2095 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2096 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2097 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2098 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2099 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2100 | break; |
| 2101 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2102 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2103 | } |
| 2104 | case 'd': |
| 2105 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2106 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2107 | { |
| 2108 | StringInfo |
| 2109 | *passkey; |
| 2110 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2111 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2112 | if (passkey == (StringInfo *) NULL) |
| 2113 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2114 | |
| 2115 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2116 | passkey=DestroyStringInfo(passkey); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2117 | break; |
| 2118 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2119 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2120 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2121 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2122 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2123 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2124 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2125 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2126 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2127 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2128 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2129 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2130 | break; |
| 2131 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2132 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2133 | { |
| 2134 | double |
| 2135 | threshold; |
| 2136 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2137 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2138 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2139 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2140 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2141 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2142 | else |
| 2143 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2144 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2145 | break; |
| 2146 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2147 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2148 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2149 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2150 | break; |
| 2151 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2152 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2153 | { |
| 2154 | char |
| 2155 | *args, |
| 2156 | token[MaxTextExtent]; |
| 2157 | |
| 2158 | const char |
| 2159 | *p; |
| 2160 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2161 | double |
| 2162 | *arguments; |
| 2163 | |
| 2164 | register ssize_t |
| 2165 | x; |
| 2166 | |
| 2167 | size_t |
| 2168 | number_arguments; |
| 2169 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2170 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2171 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2172 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2173 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2174 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2175 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2176 | double |
| 2177 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2178 | /* Special Case - Argument is actually a resize geometry! |
| 2179 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2180 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2181 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2182 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2183 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2184 | option,arg2); |
| 2185 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2186 | resize_args[0]=(double) geometry.width; |
| 2187 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2188 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2189 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2190 | break; |
| 2191 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2192 | /* handle percent arguments */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2193 | args=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2194 | if (args == (char *) NULL) |
| 2195 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2196 | /* convert arguments into an array of doubles |
| 2197 | FUTURE: make this a separate function. |
| 2198 | Also make use of new 'sentinal' feature to avoid need for |
| 2199 | tokenization. |
| 2200 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2201 | p=(char *) args; |
| 2202 | for (x=0; *p != '\0'; x++) |
| 2203 | { |
| 2204 | GetMagickToken(p,&p,token); |
| 2205 | if (*token == ',') |
| 2206 | GetMagickToken(p,&p,token); |
| 2207 | } |
| 2208 | number_arguments=(size_t) x; |
| 2209 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 2210 | sizeof(*arguments)); |
| 2211 | if (arguments == (double *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2212 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 2213 | "MemoryAllocationFailed",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2214 | (void) ResetMagickMemory(arguments,0,number_arguments* |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2215 | sizeof(*arguments)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2216 | p=(char *) args; |
| 2217 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 2218 | { |
| 2219 | GetMagickToken(p,&p,token); |
| 2220 | if (*token == ',') |
| 2221 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2222 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2223 | } |
| 2224 | args=DestroyString(args); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2225 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2226 | number_arguments,arguments,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2227 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 2228 | break; |
| 2229 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2230 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2231 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2232 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2233 | (void) DrawImage(_image,_draw_info,_exception); |
| 2234 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2235 | break; |
| 2236 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2237 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2238 | } |
| 2239 | case 'e': |
| 2240 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2241 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2242 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2243 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2244 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2245 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2246 | if ((flags & SigmaValue) == 0) |
| 2247 | geometry_info.sigma=1.0; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2248 | new_image=EdgeImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2249 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2250 | break; |
| 2251 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2252 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2253 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2254 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2255 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2256 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2257 | if ((flags & SigmaValue) == 0) |
| 2258 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2259 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2260 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2261 | break; |
| 2262 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2263 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2264 | { |
| 2265 | StringInfo |
| 2266 | *passkey; |
| 2267 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2268 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2269 | if (passkey != (StringInfo *) NULL) |
| 2270 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2271 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2272 | passkey=DestroyStringInfo(passkey); |
| 2273 | } |
| 2274 | break; |
| 2275 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2276 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2277 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2278 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2279 | break; |
| 2280 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2281 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2282 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2283 | (void) EqualizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2284 | break; |
| 2285 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2286 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2287 | { |
| 2288 | double |
| 2289 | constant; |
| 2290 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2291 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2292 | if ( parse < 0 ) |
| 2293 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2294 | option,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2295 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2296 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2297 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2298 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2299 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2300 | break; |
| 2301 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2302 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2303 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2304 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2305 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2306 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2307 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2308 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2309 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2310 | geometry.height=_image->rows; |
| 2311 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2312 | break; |
| 2313 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2314 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2315 | } |
| 2316 | case 'f': |
| 2317 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2318 | if (LocaleCompare("features",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2319 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2320 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2321 | if (IfPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2322 | (void) DeleteImageArtifact(_image,"identify:features"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2323 | break; |
| 2324 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2325 | (void) SetImageArtifact(_image,"identify:features","true"); |
| 2326 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2327 | break; |
| 2328 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2329 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2330 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2331 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2332 | break; |
| 2333 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2334 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2335 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2336 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2337 | break; |
| 2338 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2339 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2340 | { |
| 2341 | PixelInfo |
| 2342 | target; |
| 2343 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2344 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2345 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2346 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2347 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2348 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
| 2349 | geometry.y,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2350 | break; |
| 2351 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2352 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2353 | { |
| 2354 | FrameInfo |
| 2355 | frame_info; |
| 2356 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2357 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2358 | compose; |
| 2359 | |
| 2360 | const char* |
| 2361 | value; |
| 2362 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2363 | value=GetImageOption(_image_info,"compose"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2364 | if (value != (const char *) NULL) |
| 2365 | compose=(CompositeOperator) ParseCommandOption( |
| 2366 | MagickComposeOptions,MagickFalse,value); |
| 2367 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2368 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2369 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2370 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2371 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2372 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2373 | frame_info.width=geometry.width; |
| 2374 | frame_info.height=geometry.height; |
| 2375 | if ((flags & HeightValue) == 0) |
| 2376 | frame_info.height=geometry.width; |
| 2377 | frame_info.outer_bevel=geometry.x; |
| 2378 | frame_info.inner_bevel=geometry.y; |
| 2379 | frame_info.x=(ssize_t) frame_info.width; |
| 2380 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2381 | frame_info.width=_image->columns+2*frame_info.width; |
| 2382 | frame_info.height=_image->rows+2*frame_info.height; |
| 2383 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2384 | break; |
| 2385 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2386 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2387 | { |
| 2388 | char |
| 2389 | *arguments, |
| 2390 | token[MaxTextExtent]; |
| 2391 | |
| 2392 | const char |
| 2393 | *p; |
| 2394 | |
| 2395 | double |
| 2396 | *parameters; |
| 2397 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2398 | register ssize_t |
| 2399 | x; |
| 2400 | |
| 2401 | size_t |
| 2402 | number_parameters; |
| 2403 | |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2404 | /* |
| 2405 | Function Modify Image Values |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2406 | FUTURE: code should be almost a duplicate of that is "distort" |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2407 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2408 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2409 | if ( parse < 0 ) |
| 2410 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2411 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2412 | arguments=InterpretImageProperties(_image_info,_image,arg2, |
| 2413 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2414 | if (arguments == (char *) NULL) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2415 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2416 | p=(char *) arguments; |
| 2417 | for (x=0; *p != '\0'; x++) |
| 2418 | { |
| 2419 | GetMagickToken(p,&p,token); |
| 2420 | if (*token == ',') |
| 2421 | GetMagickToken(p,&p,token); |
| 2422 | } |
| 2423 | number_parameters=(size_t) x; |
| 2424 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 2425 | sizeof(*parameters)); |
| 2426 | if (parameters == (double *) NULL) |
| 2427 | ThrowWandFatalException(ResourceLimitFatalError, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2428 | "MemoryAllocationFailed",_image->filename); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2429 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 2430 | sizeof(*parameters)); |
| 2431 | p=(char *) arguments; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2432 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2433 | GetMagickToken(p,&p,token); |
| 2434 | if (*token == ',') |
| 2435 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2436 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2437 | } |
| 2438 | arguments=DestroyString(arguments); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2439 | (void) FunctionImage(_image,(MagickFunction)parse,number_parameters, |
| 2440 | parameters,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2441 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 2442 | break; |
| 2443 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2444 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2445 | } |
| 2446 | case 'g': |
| 2447 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2448 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2449 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2450 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2451 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2452 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2453 | (void) GammaImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2454 | _exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2455 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2456 | _image->gamma=StringToDouble(arg1,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2457 | break; |
| 2458 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2459 | if (LocaleCompare("gaussian-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2460 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2461 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2462 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2463 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2464 | if ((flags & SigmaValue) == 0) |
| 2465 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2466 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2467 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2468 | break; |
| 2469 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2470 | if (LocaleCompare("gaussian",option+1) == 0) |
| 2471 | { |
| 2472 | CLIWandWarnDepreciated("-gaussian-blur"); |
| 2473 | CLISimpleOperatorImage(cli_wand,"-gaussian-blur",arg1,NULL); |
| 2474 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2475 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2476 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2477 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2478 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2479 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2480 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2481 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2482 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2483 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2484 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2485 | if (_image->geometry != (char *) NULL) |
| 2486 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2487 | break; |
| 2488 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2489 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2490 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2491 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2492 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2493 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2494 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2495 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2496 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2497 | break; |
| 2498 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2499 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2500 | } |
| 2501 | case 'h': |
| 2502 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2503 | if (LocaleCompare("highlight-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2504 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2505 | (void) SetImageArtifact(_image,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2506 | break; |
| 2507 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2508 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2509 | } |
| 2510 | case 'i': |
| 2511 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2512 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2513 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2514 | const char |
| 2515 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2516 | *text; |
| 2517 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2518 | format=GetImageOption(_image_info,"format"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2519 | if (format == (char *) NULL) |
| 2520 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2521 | (void) IdentifyImage(_image,stdout,_image_info->verbose, |
| 2522 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2523 | break; |
| 2524 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2525 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2526 | if (text == (char *) NULL) |
| 2527 | break; |
| 2528 | (void) fputs(text,stdout); |
| 2529 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2530 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2531 | break; |
| 2532 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2533 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2534 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2535 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2536 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2537 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2538 | new_image=ImplodeImage(_image,geometry_info.rho, |
| 2539 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2540 | break; |
| 2541 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2542 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2543 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2544 | /* FUTURE: New to IMv7 |
| 2545 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2546 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2547 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2548 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2549 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2550 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2551 | break; |
| 2552 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2553 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2554 | } |
| 2555 | case 'l': |
| 2556 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2557 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2558 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2559 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2560 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2561 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2562 | if ((flags & PercentValue) != 0) |
| 2563 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2564 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2565 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2566 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2567 | break; |
| 2568 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2569 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2570 | { |
| 2571 | MagickRealType |
| 2572 | black_point, |
| 2573 | gamma, |
| 2574 | white_point; |
| 2575 | |
| 2576 | MagickStatusType |
| 2577 | flags; |
| 2578 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2579 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2580 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2581 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2582 | black_point=geometry_info.rho; |
| 2583 | white_point=(MagickRealType) QuantumRange; |
| 2584 | if ((flags & SigmaValue) != 0) |
| 2585 | white_point=geometry_info.sigma; |
| 2586 | gamma=1.0; |
| 2587 | if ((flags & XiValue) != 0) |
| 2588 | gamma=geometry_info.xi; |
| 2589 | if ((flags & PercentValue) != 0) |
| 2590 | { |
| 2591 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2592 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2593 | } |
| 2594 | if ((flags & SigmaValue) == 0) |
| 2595 | white_point=(MagickRealType) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2596 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2597 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2598 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2599 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2600 | break; |
| 2601 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2602 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2603 | { |
| 2604 | char |
| 2605 | token[MaxTextExtent]; |
| 2606 | |
| 2607 | const char |
| 2608 | *p; |
| 2609 | |
| 2610 | PixelInfo |
| 2611 | black_point, |
| 2612 | white_point; |
| 2613 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2614 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2615 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2616 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2617 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2618 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2619 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2620 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2621 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2622 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2623 | GetMagickToken(p,&p,token); |
| 2624 | if (*token == '\0') |
| 2625 | white_point=black_point; /* set everything to that color */ |
| 2626 | else |
| 2627 | { |
| 2628 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2629 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2630 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2631 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2632 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2633 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2634 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2635 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2636 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2637 | (void) LevelImageColors(_image,&black_point,&white_point, |
| 2638 | plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2639 | break; |
| 2640 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2641 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2642 | { |
| 2643 | double |
| 2644 | black_point, |
| 2645 | white_point; |
| 2646 | |
| 2647 | MagickStatusType |
| 2648 | flags; |
| 2649 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2650 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2651 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2652 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2653 | black_point=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2654 | white_point=(MagickRealType) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2655 | if ((flags & SigmaValue) != 0) |
| 2656 | white_point=geometry_info.sigma; |
| 2657 | if ((flags & PercentValue) != 0) |
| 2658 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2659 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2660 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2661 | } |
| 2662 | if ((flags & SigmaValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2663 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2664 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2665 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2666 | break; |
| 2667 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2668 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2669 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2670 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2671 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2672 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2673 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2674 | if ((flags & XValue) == 0) |
| 2675 | geometry.x=1; |
| 2676 | if ((flags & YValue) == 0) |
| 2677 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2678 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2679 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2680 | break; |
| 2681 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2682 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2683 | } |
| 2684 | case 'm': |
| 2685 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2686 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2687 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2688 | CLIWandWarnDepreciated("-remap"); |
| 2689 | CLISimpleOperatorImage(cli_wand,"-remap",NULL,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2690 | break; |
| 2691 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2692 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2693 | { |
| 2694 | Image |
| 2695 | *mask; |
| 2696 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2697 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2698 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2699 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2700 | break; |
| 2701 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2702 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2703 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2704 | if (mask == (Image *) NULL) |
| 2705 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2706 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2707 | mask=DestroyImage(mask); |
| 2708 | break; |
| 2709 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2710 | if (LocaleCompare("matte",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2711 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2712 | CLIWandWarnDepreciated(IfNormalOp?"-alpha Set":"-alpha Off"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2713 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2714 | DeactivateAlphaChannel, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2715 | break; |
| 2716 | } |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2717 | if (LocaleCompare("median",option+1) == 0) |
| 2718 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2719 | CLIWandWarnDepreciated("-statistic Median"); |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2720 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2721 | break; |
| 2722 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2723 | if (LocaleCompare("mode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2724 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2725 | /* FUTURE: note this is also a special "montage" option */ |
| 2726 | CLIWandWarnDepreciated("-statistic Mode"); |
| 2727 | CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2728 | break; |
| 2729 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2730 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2731 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2732 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2733 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2734 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2735 | break; |
| 2736 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2737 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2738 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2739 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2740 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2741 | break; |
| 2742 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2743 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2744 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2745 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2746 | break; |
| 2747 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2748 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2749 | { |
| 2750 | char |
| 2751 | token[MaxTextExtent]; |
| 2752 | |
| 2753 | const char |
| 2754 | *p; |
| 2755 | |
| 2756 | KernelInfo |
| 2757 | *kernel; |
| 2758 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2759 | ssize_t |
| 2760 | iterations; |
| 2761 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2762 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2763 | GetMagickToken(p,&p,token); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2764 | parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
| 2765 | if ( parse < 0 ) |
| 2766 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2767 | option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2768 | iterations=1L; |
| 2769 | GetMagickToken(p,&p,token); |
| 2770 | if ((*p == ':') || (*p == ',')) |
| 2771 | GetMagickToken(p,&p,token); |
| 2772 | if ((*p != '\0')) |
| 2773 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2774 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2775 | if (kernel == (KernelInfo *) NULL) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2776 | CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel", |
| 2777 | option,arg2); |
| 2778 | new_image=MorphologyImage(_image,(MorphologyMethod)parse, |
| 2779 | iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2780 | kernel=DestroyKernelInfo(kernel); |
| 2781 | break; |
| 2782 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2783 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2784 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2785 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2786 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2787 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2788 | if ((flags & SigmaValue) == 0) |
| 2789 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2790 | new_image=MotionBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2791 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2792 | break; |
| 2793 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2794 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2795 | } |
| 2796 | case 'n': |
| 2797 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2798 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2799 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2800 | (void) NegateImage(_image, plus_alt_op, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2801 | break; |
| 2802 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2803 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2804 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2805 | double |
| 2806 | attenuate; |
| 2807 | |
| 2808 | const char* |
| 2809 | value; |
| 2810 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2811 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2812 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2813 | CLIWandWarnDepreciated("-statistic NonPeak"); |
| 2814 | CLISimpleOperatorImage(cli_wand,"-statistic","NonPeak",arg1); |
| 2815 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2816 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2817 | parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1); |
| 2818 | if ( parse < 0 ) |
| 2819 | CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType", |
| 2820 | option,arg1); |
| 2821 | attenuate=1.0; |
| 2822 | value=GetImageOption(_image_info,"attenuate"); |
| 2823 | if (value != (const char *) NULL) |
| 2824 | attenuate=StringToDouble(value,(char **) NULL); |
| 2825 | new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate, |
| 2826 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2827 | break; |
| 2828 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2829 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2830 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2831 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2832 | break; |
| 2833 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2834 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2835 | } |
| 2836 | case 'o': |
| 2837 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2838 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2839 | { |
| 2840 | PixelInfo |
| 2841 | target; |
| 2842 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2843 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 2844 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,plus_alt_op, |
| 2845 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2846 | break; |
| 2847 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2848 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2849 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2850 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2851 | break; |
| 2852 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2853 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2854 | } |
| 2855 | case 'p': |
| 2856 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2857 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2858 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2859 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2860 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2861 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2862 | break; |
| 2863 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2864 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2865 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2866 | const char |
| 2867 | *caption; |
| 2868 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2869 | double |
| 2870 | angle; |
| 2871 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2872 | if (IfPlusOp) { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2873 | RandomInfo |
| 2874 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2875 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2876 | random_info=AcquireRandomInfo(); |
| 2877 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2878 | random_info=DestroyRandomInfo(random_info); |
| 2879 | } |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2880 | else { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2881 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2882 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2883 | flags=ParseGeometry(arg1,&geometry_info); |
| 2884 | angle=geometry_info.rho; |
| 2885 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2886 | caption=GetImageProperty(_image,"caption",_exception); |
| 2887 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 2888 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2889 | break; |
| 2890 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2891 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2892 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2893 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2894 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2895 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2896 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
| 2897 | _quantize_info->dither,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2898 | break; |
| 2899 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2900 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2901 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2902 | /* FUTURE: should be a 'Genesis' option? |
| 2903 | Option however is also in WandSettingOptionInfo() |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2904 | Why??? |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2905 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2906 | parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1); |
| 2907 | if ( parse < 0 ) |
| 2908 | CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType", |
| 2909 | option,arg1); |
| 2910 | new_image=PreviewImage(_image,(PreviewType)parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2911 | break; |
| 2912 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2913 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2914 | { |
| 2915 | const char |
| 2916 | *name; |
| 2917 | |
| 2918 | const StringInfo |
| 2919 | *profile; |
| 2920 | |
| 2921 | Image |
| 2922 | *profile_image; |
| 2923 | |
| 2924 | ImageInfo |
| 2925 | *profile_info; |
| 2926 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2927 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2928 | { /* Remove a profile from the _image. */ |
| 2929 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 2930 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2931 | break; |
| 2932 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2933 | /* Associate a profile with the _image. */ |
| 2934 | profile_info=CloneImageInfo(_image_info); |
| 2935 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2936 | if (profile != (StringInfo *) NULL) |
| 2937 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2938 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2939 | profile_info=DestroyImageInfo(profile_info); |
| 2940 | if (profile_image == (Image *) NULL) |
| 2941 | { |
| 2942 | StringInfo |
| 2943 | *profile; |
| 2944 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2945 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2946 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2947 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2948 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2949 | if (profile != (StringInfo *) NULL) |
| 2950 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2951 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2952 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2953 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2954 | profile=DestroyStringInfo(profile); |
| 2955 | } |
| 2956 | profile_info=DestroyImageInfo(profile_info); |
| 2957 | break; |
| 2958 | } |
| 2959 | ResetImageProfileIterator(profile_image); |
| 2960 | name=GetNextImageProfile(profile_image); |
| 2961 | while (name != (const char *) NULL) |
| 2962 | { |
| 2963 | profile=GetImageProfile(profile_image,name); |
| 2964 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2965 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 2966 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2967 | name=GetNextImageProfile(profile_image); |
| 2968 | } |
| 2969 | profile_image=DestroyImage(profile_image); |
| 2970 | break; |
| 2971 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2972 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2973 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2974 | case 'r': |
| 2975 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2976 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2977 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2978 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2979 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2980 | flags=ParseGeometry(arg1,&geometry_info); |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2981 | new_image=RadialBlurImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2982 | break; |
| 2983 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2984 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2985 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2986 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2987 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2988 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2989 | if ((flags & SigmaValue) == 0) |
| 2990 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2991 | (void) RaiseImage(_image,&geometry,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2992 | break; |
| 2993 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2994 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2995 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2996 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2997 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2998 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2999 | break; |
| 3000 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3001 | if (LocaleCompare("recolor",option+1) == 0) |
| 3002 | { |
| 3003 | CLIWandWarnDepreciated("-color-matrix"); |
| 3004 | CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL); |
| 3005 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3006 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3007 | { |
| 3008 | Image |
| 3009 | *remap_image; |
| 3010 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3011 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3012 | if (remap_image == (Image *) NULL) |
| 3013 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3014 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3015 | remap_image=DestroyImage(remap_image); |
| 3016 | break; |
| 3017 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3018 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3019 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3020 | if (IfNormalOp) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 3021 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3022 | if (IfMagickFalse(IsGeometry(arg1))) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 3023 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3024 | arg1); |
| 3025 | (void) ResetImagePage(_image,arg1); |
| 3026 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3027 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3028 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3029 | break; |
| 3030 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3031 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3032 | { |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 3033 | /* FUTURE: Roll into a resize special operation */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3034 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3035 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3036 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3037 | if ((flags & SigmaValue) == 0) |
| 3038 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3039 | new_image=ResampleImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3040 | geometry_info.sigma,_image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3041 | break; |
| 3042 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3043 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3044 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3045 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3046 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3047 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3048 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3049 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3050 | break; |
| 3051 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3052 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3053 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3054 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3055 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3056 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3057 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3058 | break; |
| 3059 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3060 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3061 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3062 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3063 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3064 | if (strchr(arg1,'>') != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3065 | if (_image->columns <= _image->rows) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3066 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3067 | if (strchr(arg1,'<') != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3068 | if (_image->columns >= _image->rows) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3069 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3070 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3071 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3072 | break; |
| 3073 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3074 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3075 | } |
| 3076 | case 's': |
| 3077 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3078 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3079 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3080 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3081 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3082 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3083 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3084 | new_image=SampleImage(_image,geometry.width,geometry.height, |
| 3085 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3086 | break; |
| 3087 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3088 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3089 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3090 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3091 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3092 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3093 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3094 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3095 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3096 | break; |
| 3097 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3098 | if (LocaleCompare("segment",option+1) == 0) |
| 3099 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3100 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3101 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3102 | flags=ParseGeometry(arg1,&geometry_info); |
| 3103 | if ((flags & SigmaValue) == 0) |
| 3104 | geometry_info.sigma=1.0; |
| 3105 | (void) SegmentImage(_image,_image->colorspace, |
| 3106 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3107 | _exception); |
| 3108 | break; |
| 3109 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3110 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3111 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3112 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3113 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3114 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3115 | if ((flags & PercentValue) != 0) |
| 3116 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3117 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3118 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3119 | break; |
| 3120 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3121 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3122 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3123 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3124 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3125 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3126 | break; |
| 3127 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3128 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3129 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3130 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3131 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3132 | new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1, |
| 3133 | (double) QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3134 | break; |
| 3135 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3136 | if (LocaleCompare("set",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3137 | { |
| 3138 | char |
| 3139 | *value; |
| 3140 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3141 | if (IfPlusOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3142 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3143 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3144 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3145 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3146 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3147 | (void) DeleteImageOption(_image_info,arg1+7); |
| 3148 | (void) DeleteImageArtifact(_image,arg1+7); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3149 | } |
| 3150 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3151 | (void) DeleteImageProperty(_image,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3152 | break; |
| 3153 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3154 | value=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3155 | if (value == (char *) NULL) |
| 3156 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3157 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3158 | (void) SetImageRegistry(StringRegistryType,arg1+9,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3159 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3160 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3161 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3162 | (void) SetImageOption(_image_info,arg1+7,value); |
| 3163 | (void) SetImageArtifact(_image,arg1+7,value); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3164 | } |
| 3165 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3166 | (void) SetImageProperty(_image,arg1,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3167 | value=DestroyString(value); |
| 3168 | break; |
| 3169 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3170 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3171 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3172 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3173 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3174 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3175 | if ((flags & SigmaValue) == 0) |
| 3176 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3177 | new_image=ShadeImage(_image,normal_op,geometry_info.rho, |
| 3178 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3179 | break; |
| 3180 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3181 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3182 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3183 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3184 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3185 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3186 | if ((flags & SigmaValue) == 0) |
| 3187 | geometry_info.sigma=1.0; |
| 3188 | if ((flags & XiValue) == 0) |
| 3189 | geometry_info.xi=4.0; |
| 3190 | if ((flags & PsiValue) == 0) |
| 3191 | geometry_info.psi=4.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3192 | new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3193 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3194 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3195 | break; |
| 3196 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3197 | if (LocaleCompare("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3198 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3199 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3200 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3201 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3202 | if ((flags & SigmaValue) == 0) |
| 3203 | geometry_info.sigma=1.0; |
| 3204 | if ((flags & XiValue) == 0) |
| 3205 | geometry_info.xi=0.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3206 | new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3207 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3208 | break; |
| 3209 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3210 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3211 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3212 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3213 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3214 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3215 | new_image=ShaveImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3216 | break; |
| 3217 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3218 | if (LocaleCompare("shear",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3219 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3220 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3221 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3222 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3223 | if ((flags & SigmaValue) == 0) |
| 3224 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3225 | new_image=ShearImage(_image,geometry_info.rho, |
| 3226 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3227 | break; |
| 3228 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3229 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3230 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3231 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3232 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3233 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3234 | if ((flags & SigmaValue) == 0) |
| 3235 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3236 | if ((flags & PercentValue) != 0) |
| 3237 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3238 | 100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3239 | (void) SigmoidalContrastImage(_image,normal_op,geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3240 | geometry_info.sigma, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3241 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3242 | break; |
| 3243 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3244 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3245 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3246 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3247 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3248 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3249 | if ((flags & SigmaValue) == 0) |
| 3250 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3251 | new_image=SketchImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3252 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3253 | break; |
| 3254 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3255 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3256 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3257 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3258 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3259 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3260 | QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3261 | break; |
| 3262 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3263 | if (LocaleCompare("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3264 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3265 | char |
| 3266 | *arguments; |
| 3267 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3268 | parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1); |
| 3269 | if ( parse < 0 ) |
| 3270 | CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod", |
| 3271 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3272 | arguments=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3273 | if (arguments == (char *) NULL) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3274 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
| 3275 | new_image=SparseColorOption(_image,(SparseColorMethod)parse, |
| 3276 | arguments,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3277 | arguments=DestroyString(arguments); |
| 3278 | break; |
| 3279 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3280 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3281 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3282 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3283 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3284 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 3285 | new_image=SpliceImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3286 | break; |
| 3287 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3288 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3289 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3290 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3291 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3292 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3293 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3294 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3295 | break; |
| 3296 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3297 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3298 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3299 | parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1); |
| 3300 | if ( parse < 0 ) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3301 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStatisticType", |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3302 | option,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3303 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3304 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3305 | flags=ParseGeometry(arg2,&geometry_info); |
| 3306 | if ((flags & SigmaValue) == 0) |
| 3307 | geometry_info.sigma=geometry_info.rho; |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3308 | new_image=StatisticImage(_image,(StatisticType)parse, |
| 3309 | (size_t) geometry_info.rho,(size_t) geometry_info.sigma, |
| 3310 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3311 | break; |
| 3312 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3313 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3314 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3315 | (void) StripImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3316 | break; |
| 3317 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3318 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3319 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3320 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3321 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3322 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3323 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3324 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3325 | break; |
| 3326 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3327 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3328 | } |
| 3329 | case 't': |
| 3330 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3331 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3332 | { |
| 3333 | double |
| 3334 | threshold; |
| 3335 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3336 | threshold=(double) QuantumRange/2; |
| 3337 | if (normal_op) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3338 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3339 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3340 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3341 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3342 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3343 | break; |
| 3344 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3345 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3346 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3347 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3348 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3349 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3350 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3351 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3352 | break; |
| 3353 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3354 | if (LocaleCompare("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3355 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3356 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3357 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3358 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3359 | break; |
| 3360 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3361 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3362 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3363 | CLIWandWarnDepreciated("+distort AffineProjection"); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3364 | new_image=AffineTransformImage(_image,&_draw_info->affine,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3365 | break; |
| 3366 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3367 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3368 | { |
| 3369 | PixelInfo |
| 3370 | target; |
| 3371 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3372 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3373 | (void) TransparentPaintImage(_image,&target,(Quantum) |
| 3374 | TransparentAlpha,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3375 | break; |
| 3376 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3377 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3378 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3379 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3380 | break; |
| 3381 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3382 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3383 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3384 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3385 | break; |
| 3386 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3387 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3388 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3389 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3390 | break; |
| 3391 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3392 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3393 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3394 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3395 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3396 | break; |
| 3397 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3398 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3399 | } |
| 3400 | case 'u': |
| 3401 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3402 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3403 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3404 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? |
| 3405 | Option is not documented, bt appears to be for "identify". |
| 3406 | We may need a identify specific verbose! |
| 3407 | */ |
| 3408 | if (plus_alt_op) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3409 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3410 | break; |
| 3411 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3412 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3413 | (void) SetImageArtifact(_image,"verbose","true"); |
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("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3417 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3418 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3419 | break; |
| 3420 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3421 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3422 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3423 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3424 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3425 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3426 | if ((flags & SigmaValue) == 0) |
| 3427 | geometry_info.sigma=1.0; |
| 3428 | if ((flags & XiValue) == 0) |
| 3429 | geometry_info.xi=1.0; |
| 3430 | if ((flags & PsiValue) == 0) |
| 3431 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3432 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
| 3433 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3434 | break; |
| 3435 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3436 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3437 | } |
| 3438 | case 'v': |
| 3439 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3440 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3441 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3442 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3443 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3444 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3445 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3446 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3447 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3448 | break; |
| 3449 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3450 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3451 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3452 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3453 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3454 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3455 | if ((flags & SigmaValue) == 0) |
| 3456 | geometry_info.sigma=1.0; |
| 3457 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3458 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3459 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3460 | geometry_info.psi=0.1*_image->rows; |
| 3461 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3462 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3463 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3464 | break; |
| 3465 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3466 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3467 | } |
| 3468 | case 'w': |
| 3469 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3470 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3471 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3472 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3473 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3474 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3475 | if ((flags & SigmaValue) == 0) |
| 3476 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3477 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3478 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3479 | break; |
| 3480 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3481 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3482 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3483 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3484 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3485 | (void) WhiteThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3486 | break; |
| 3487 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3488 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3489 | } |
| 3490 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3491 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3492 | } |
| 3493 | /* |
| 3494 | Replace current image with any image that was generated |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3495 | and set image point to last image (so image->next is correct) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3496 | */ |
| 3497 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3498 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3499 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3500 | return; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3501 | #undef _image_info |
| 3502 | #undef _draw_info |
| 3503 | #undef _quantize_info |
| 3504 | #undef _image |
| 3505 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3506 | #undef IfNormalOp |
| 3507 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3508 | #undef normal_op |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3509 | #undef plus_alt_op |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3510 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3511 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3512 | WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3513 | const char *option, const char *arg1, const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3514 | { |
| 3515 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3516 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3517 | i; |
| 3518 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3519 | assert(cli_wand != (MagickCLI *) NULL); |
| 3520 | assert(cli_wand->signature == WandSignature); |
| 3521 | assert(cli_wand->wand.signature == WandSignature); |
| 3522 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3523 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3524 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3525 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3526 | #if !USE_WAND_METHODS |
| 3527 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3528 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3529 | n=GetImageListLength(cli_wand->wand.images); |
| 3530 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3531 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3532 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3533 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3534 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3535 | break; |
| 3536 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3537 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3538 | assert( i == n ); |
| 3539 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3540 | #else |
| 3541 | MagickResetIterator(&cli_wand->wand); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3542 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3543 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3544 | MagickResetIterator(&cli_wand->wand); |
| 3545 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3546 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3547 | } |
| 3548 | |
| 3549 | /* |
| 3550 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3551 | % % |
| 3552 | % % |
| 3553 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3554 | + 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] | 3555 | % % |
| 3556 | % % |
| 3557 | % % |
| 3558 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3559 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3560 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3561 | % entire image list as a whole. The result is often a complete replacment |
| 3562 | % 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] | 3563 | % |
| 3564 | % The format of the MogrifyImage method is: |
| 3565 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3566 | % void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3567 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3568 | % |
| 3569 | % A description of each parameter follows: |
| 3570 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3571 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3572 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3573 | % o option: The option string for the operation |
| 3574 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3575 | % o arg1, arg2: optional argument strings to the operation |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3576 | % arg2 is currently not used |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3577 | % |
| 3578 | % Example usage... |
| 3579 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3580 | % CLIListOperatorImages(cli_wand,MagickFalse,"-duplicate", "3", NULL); |
| 3581 | % CLIListOperatorImages(cli_wand,MagickTrue, "+append", NULL, NULL); |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3582 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 3583 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3584 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3585 | % cli_wand |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3586 | % argc,argv |
| 3587 | % i=index in argv |
| 3588 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 3589 | % option_info = GetCommandOptionInfo(argv[i]); |
| 3590 | % count=option_info->type; |
| 3591 | % option_type=option_info->flags; |
| 3592 | % |
| 3593 | % if ( (option_type & ListOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3594 | % CLIListOperatorImages(cli_wand,argv[i], |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3595 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 3596 | % count>=2 ? argv[i+2] : (char *)NULL ); |
| 3597 | % i += count+1; |
| 3598 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3599 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3600 | WandExport void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3601 | const char *option,const char *arg1, const char *magick_unused(arg2)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3602 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3603 | ssize_t |
| 3604 | parse; |
| 3605 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3606 | Image |
| 3607 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3608 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3609 | #define _image_info (cli_wand->wand.image_info) |
| 3610 | #define _images (cli_wand->wand.images) |
| 3611 | #define _exception (cli_wand->wand.exception) |
| 3612 | #define _draw_info (cli_wand->draw_info) |
| 3613 | #define _quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3614 | #define IfNormalOp (*option=='-') |
| 3615 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3616 | #define normal_op IsMagickTrue(IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3617 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3618 | assert(cli_wand != (MagickCLI *) NULL); |
| 3619 | assert(cli_wand->signature == WandSignature); |
| 3620 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3621 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3622 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3623 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3624 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3625 | (void) SyncImagesSettings(_image_info,_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3626 | |
| 3627 | new_images=NewImageList(); |
| 3628 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3629 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3630 | { |
| 3631 | case 'a': |
| 3632 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3633 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3634 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3635 | new_images=AppendImages(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3636 | break; |
| 3637 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3638 | if (LocaleCompare("average",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3639 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3640 | CLIWandWarnDepreciated("-evaluate-sequence Mean"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3641 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3642 | break; |
| 3643 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3644 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3645 | } |
| 3646 | case 'c': |
| 3647 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3648 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3649 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3650 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3651 | break; |
| 3652 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3653 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3654 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3655 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3656 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3657 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3658 | /* FUTURE - make this a compose option, and thus can be used |
| 3659 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3660 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3661 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3662 | new_images=RemoveFirstImageFromList(&_images); |
| 3663 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3664 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3665 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3666 | break; |
cristy | e52fb5e | 2012-04-06 23:30:20 +0000 | [diff] [blame] | 3667 | (void) ClutImage(new_images,clut_image,new_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3668 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3669 | break; |
| 3670 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3671 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3672 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3673 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3674 | break; |
| 3675 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3676 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3677 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3678 | /* FUTURE - this may be replaced by a 'channel' method */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3679 | new_images=CombineImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3680 | break; |
| 3681 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3682 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3683 | { |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3684 | CompositeOperator |
| 3685 | compose; |
| 3686 | |
| 3687 | const char* |
| 3688 | value; |
| 3689 | |
| 3690 | MagickBooleanType |
| 3691 | clip_to_self; |
| 3692 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3693 | Image |
| 3694 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3695 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3696 | |
| 3697 | RectangleInfo |
| 3698 | geometry; |
| 3699 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3700 | /* Compose value from "-compose" option only */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3701 | value=GetImageOption(_image_info,"compose"); |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3702 | if (value == (const char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3703 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3704 | else |
| 3705 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 3706 | MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3707 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3708 | /* Get "clip-to-self" expert setting (false is normal) */ |
cristy | ca0e82c | 2012-04-10 11:53:24 +0000 | [diff] [blame] | 3709 | value=GetImageOption(_image_info,"compose:clip-to-self"); |
| 3710 | if (value == (const char *) NULL) |
| 3711 | clip_to_self=MagickTrue; |
| 3712 | else |
| 3713 | clip_to_self=IsStringTrue(GetImageOption(_image_info, |
| 3714 | "compose:clip-to-self")); /* if this is true */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3715 | value=GetImageOption(_image_info,"compose:outside-overlay"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3716 | if (value != (const char *) NULL) { /* or this false */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3717 | /* FUTURE: depreciate warning for "compose:outside-overlay"*/ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3718 | clip_to_self= IsMagickFalse(IsStringNotFalse(value)); |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3719 | } |
| 3720 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3721 | new_images=RemoveFirstImageFromList(&_images); |
| 3722 | source_image=RemoveFirstImageFromList(&_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3723 | if (source_image == (Image *) NULL) |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3724 | break; /* FUTURE - produce Exception, rather than silent fail */ |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3725 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3726 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3727 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3728 | source_image->geometry,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3729 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3730 | SetGeometry(source_image,&geometry); |
| 3731 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3732 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
| 3733 | new_images->gravity, &geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3734 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3735 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3736 | if (mask_image != (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3737 | { /* handle a third write mask image */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3738 | if ((compose == DisplaceCompositeOp) || |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3739 | (compose == DistortCompositeOp)) { |
| 3740 | /* Merge Y displacement into X displace/distort map. */ |
| 3741 | (void) CompositeImage(source_image,mask_image, |
| 3742 | CopyGreenCompositeOp,MagickTrue,0,0,_exception); |
| 3743 | mask_image=DestroyImage(mask_image); |
| 3744 | } |
| 3745 | else { |
| 3746 | /* Set a blending mask for the composition. */ |
| 3747 | (void) NegateImage(mask_image,MagickFalse,_exception); |
| 3748 | (void) SetImageMask(new_images,mask_image,_exception); |
| 3749 | mask_image=DestroyImage(mask_image); |
| 3750 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3751 | } |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3752 | (void) CompositeImage(new_images,source_image,compose,clip_to_self, |
| 3753 | geometry.x,geometry.y,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3754 | (void) SetImageMask(new_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3755 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3756 | break; |
| 3757 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3758 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3759 | } |
| 3760 | case 'd': |
| 3761 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3762 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3763 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3764 | CLIWandWarnDepreciated("-layer CompareAny"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3765 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3766 | break; |
| 3767 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3768 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3769 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3770 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3771 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3772 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3773 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3774 | break; |
| 3775 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3776 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3777 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3778 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3779 | { |
| 3780 | const char |
| 3781 | *p; |
| 3782 | |
| 3783 | size_t |
| 3784 | number_duplicates; |
| 3785 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3786 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3787 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3788 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3789 | number_duplicates=(size_t) StringToLong(arg1); |
| 3790 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3791 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3792 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3793 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3794 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3795 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3796 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3797 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3798 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3799 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3800 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3801 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3802 | break; |
| 3803 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3804 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3805 | } |
| 3806 | case 'e': |
| 3807 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3808 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3809 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3810 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3811 | if ( parse < 0 ) |
| 3812 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3813 | option,arg1); |
| 3814 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
| 3815 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3816 | break; |
| 3817 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3818 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3819 | } |
| 3820 | case 'f': |
| 3821 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3822 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3823 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3824 | new_images=ForwardFourierTransformImage(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3825 | break; |
| 3826 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3827 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3828 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3829 | /* REDIRECTED to use -layers flatten instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3830 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3831 | break; |
| 3832 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3833 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3834 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3835 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3836 | break; |
| 3837 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3838 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3839 | } |
| 3840 | case 'h': |
| 3841 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3842 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3843 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3844 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3845 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3846 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3847 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3848 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3849 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3850 | new_images=RemoveFirstImageFromList(&_images); |
| 3851 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3852 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3853 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3854 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3855 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3856 | break; |
| 3857 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3858 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3859 | } |
| 3860 | case 'i': |
| 3861 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3862 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3863 | { |
| 3864 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3865 | *magnitude_image, |
| 3866 | *phase_image; |
| 3867 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3868 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3869 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3870 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3871 | if (phase_image == (Image *) NULL) |
| 3872 | break; |
| 3873 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3874 | normal_op,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3875 | magnitude_image=DestroyImage(magnitude_image); |
| 3876 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3877 | break; |
| 3878 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3879 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3880 | { |
| 3881 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3882 | *insert_image, |
| 3883 | *index_image; |
| 3884 | |
| 3885 | ssize_t |
| 3886 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3887 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3888 | if (IfNormalOp && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3889 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3890 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3891 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3892 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3893 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3894 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3895 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3896 | PrependImageToList(&_images,insert_image); |
| 3897 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3898 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3899 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3900 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3901 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3902 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3903 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3904 | InsertImageInList(&index_image,insert_image); |
| 3905 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3906 | _images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3907 | break; |
| 3908 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3909 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3910 | } |
| 3911 | case 'l': |
| 3912 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3913 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3914 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3915 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3916 | if ( parse < 0 ) |
| 3917 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3918 | option,arg1); |
| 3919 | switch ((ImageLayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3920 | { |
| 3921 | case CoalesceLayer: |
| 3922 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3923 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3924 | break; |
| 3925 | } |
| 3926 | case CompareAnyLayer: |
| 3927 | case CompareClearLayer: |
| 3928 | case CompareOverlayLayer: |
| 3929 | default: |
| 3930 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3931 | new_images=CompareImagesLayers(_images,(ImageLayerMethod) parse, |
| 3932 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3933 | break; |
| 3934 | } |
| 3935 | case MergeLayer: |
| 3936 | case FlattenLayer: |
| 3937 | case MosaicLayer: |
| 3938 | case TrimBoundsLayer: |
| 3939 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3940 | new_images=MergeImageLayers(_images,(ImageLayerMethod) parse, |
| 3941 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3942 | break; |
| 3943 | } |
| 3944 | case DisposeLayer: |
| 3945 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3946 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3947 | break; |
| 3948 | } |
| 3949 | case OptimizeImageLayer: |
| 3950 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3951 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3952 | break; |
| 3953 | } |
| 3954 | case OptimizePlusLayer: |
| 3955 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3956 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3957 | break; |
| 3958 | } |
| 3959 | case OptimizeTransLayer: |
| 3960 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3961 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3962 | break; |
| 3963 | } |
| 3964 | case RemoveDupsLayer: |
| 3965 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3966 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3967 | break; |
| 3968 | } |
| 3969 | case RemoveZeroLayer: |
| 3970 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3971 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3972 | break; |
| 3973 | } |
| 3974 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3975 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3976 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3977 | if (new_images == (Image *) NULL) |
| 3978 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3979 | _images=DestroyImageList(_images); |
| 3980 | _images=OptimizeImageLayers(new_images,_exception); |
| 3981 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3982 | break; |
| 3983 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3984 | OptimizeImageTransparency(_images,_exception); |
| 3985 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 3986 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3987 | break; |
| 3988 | } |
| 3989 | case CompositeLayer: |
| 3990 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3991 | Image |
| 3992 | *source; |
| 3993 | |
| 3994 | RectangleInfo |
| 3995 | geometry; |
| 3996 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3997 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3998 | compose; |
| 3999 | |
| 4000 | const char* |
| 4001 | value; |
| 4002 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4003 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4004 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4005 | if (value != (const char *) NULL) |
| 4006 | compose=(CompositeOperator) ParseCommandOption( |
| 4007 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4008 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4009 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4010 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4011 | while (source != (Image *) NULL) |
| 4012 | { |
| 4013 | source=GetNextImageInList(source); |
| 4014 | if ((source != (Image *) NULL) && |
| 4015 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 4016 | break; |
| 4017 | } |
| 4018 | if (source != (Image *) NULL) |
| 4019 | { |
| 4020 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 4021 | (GetNextImageInList(source) == (Image *) NULL)) |
| 4022 | source=(Image *) NULL; |
| 4023 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4024 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4025 | source=SplitImageList(source->previous); |
| 4026 | DeleteImageFromList(&source); |
| 4027 | } |
| 4028 | } |
| 4029 | if (source == (Image *) NULL) |
| 4030 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4031 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4032 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4033 | break; |
| 4034 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4035 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4036 | SetGeometry(_images,&geometry); |
| 4037 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4038 | geometry.width=source->page.width != 0 ? |
| 4039 | source->page.width : source->columns; |
| 4040 | geometry.height=source->page.height != 0 ? |
| 4041 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4042 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 4043 | _images->page.width : _images->columns, |
| 4044 | _images->page.height != 0 ? _images->page.height : |
| 4045 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4046 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4047 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4048 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 4049 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4050 | source=DestroyImageList(source); |
| 4051 | break; |
| 4052 | } |
| 4053 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4054 | break; |
| 4055 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4056 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4057 | } |
| 4058 | case 'm': |
| 4059 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4060 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4061 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 4062 | CLIWandWarnDepreciated("+remap"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4063 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4064 | break; |
| 4065 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4066 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4067 | { |
| 4068 | Image |
| 4069 | *morph_image; |
| 4070 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4071 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 4072 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4073 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4074 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4075 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4076 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4077 | _images=DestroyImageList(_images); |
| 4078 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4079 | break; |
| 4080 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4081 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4082 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4083 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 4084 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4085 | break; |
| 4086 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4087 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4088 | } |
| 4089 | case 'p': |
| 4090 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4091 | if (LocaleCompare("print",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4092 | { |
| 4093 | char |
| 4094 | *string; |
| 4095 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4096 | string=InterpretImageProperties(_image_info,_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4097 | if (string == (char *) NULL) |
| 4098 | break; |
| 4099 | (void) FormatLocaleFile(stdout,"%s",string); |
| 4100 | string=DestroyString(string); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4101 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4102 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4103 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4104 | { |
| 4105 | char |
| 4106 | **arguments; |
| 4107 | |
| 4108 | int |
| 4109 | j, |
| 4110 | number_arguments; |
| 4111 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4112 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4113 | if (arguments == (char **) NULL) |
| 4114 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4115 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4116 | { |
| 4117 | char |
| 4118 | breaker, |
| 4119 | quote, |
| 4120 | *token; |
| 4121 | |
| 4122 | const char |
| 4123 | *arguments; |
| 4124 | |
| 4125 | int |
| 4126 | next, |
| 4127 | status; |
| 4128 | |
| 4129 | size_t |
| 4130 | length; |
| 4131 | |
| 4132 | TokenInfo |
| 4133 | *token_info; |
| 4134 | |
| 4135 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4136 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4137 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4138 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4139 | token=(char *) NULL; |
| 4140 | if (~length >= (MaxTextExtent-1)) |
| 4141 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4142 | sizeof(*token)); |
| 4143 | if (token == (char *) NULL) |
| 4144 | break; |
| 4145 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4146 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4147 | token_info=AcquireTokenInfo(); |
| 4148 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4149 | "\"",'\0',&breaker,&next,"e); |
| 4150 | token_info=DestroyTokenInfo(token_info); |
| 4151 | if (status == 0) |
| 4152 | { |
| 4153 | const char |
| 4154 | *argv; |
| 4155 | |
| 4156 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4157 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4158 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4159 | } |
| 4160 | token=DestroyString(token); |
| 4161 | break; |
| 4162 | } |
| 4163 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4164 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4165 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4166 | for (j=0; j < number_arguments; j++) |
| 4167 | arguments[j]=DestroyString(arguments[j]); |
| 4168 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4169 | break; |
| 4170 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4171 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4172 | } |
| 4173 | case 'r': |
| 4174 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4175 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4176 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4177 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4178 | break; |
| 4179 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4180 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4181 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4182 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4183 | break; |
| 4184 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4185 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4186 | } |
| 4187 | case 's': |
| 4188 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4189 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4190 | { |
| 4191 | Image |
| 4192 | *smush_image; |
| 4193 | |
| 4194 | ssize_t |
| 4195 | offset; |
| 4196 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4197 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 4198 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4199 | offset=(ssize_t) StringToLong(arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4200 | smush_image=SmushImages(_images,normal_op,offset,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4201 | if (smush_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4202 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4203 | _images=DestroyImageList(_images); |
| 4204 | _images=smush_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4205 | break; |
| 4206 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4207 | if (LocaleCompare("swap",option+1) == 0) { |
| 4208 | Image |
| 4209 | *p, |
| 4210 | *q, |
| 4211 | *swap; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4212 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4213 | ssize_t |
| 4214 | index, |
| 4215 | swap_index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4216 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4217 | index=-1; |
| 4218 | swap_index=-2; |
| 4219 | if (IfNormalOp) { |
| 4220 | GeometryInfo |
| 4221 | geometry_info; |
| 4222 | |
| 4223 | MagickStatusType |
| 4224 | flags; |
| 4225 | |
| 4226 | swap_index=(-1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4227 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 4228 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4229 | flags=ParseGeometry(arg1,&geometry_info); |
| 4230 | index=(ssize_t) geometry_info.rho; |
| 4231 | if ((flags & SigmaValue) != 0) |
| 4232 | swap_index=(ssize_t) geometry_info.sigma; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4233 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4234 | p=GetImageFromList(_images,index); |
| 4235 | q=GetImageFromList(_images,swap_index); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4236 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) { |
| 4237 | if (IfNormalOp) |
| 4238 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1) |
| 4239 | else |
| 4240 | CLIWandExceptionBreak(OptionError,"TwoOrMoreImagesRequired",option); |
| 4241 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4242 | if (p == q) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4243 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4244 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4245 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
| 4246 | ReplaceImageInList(&q,swap); |
| 4247 | _images=GetFirstImageInList(q); |
| 4248 | break; |
| 4249 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4250 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4251 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4252 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4253 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4254 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4255 | if (new_images == (Image *) NULL) |
| 4256 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4257 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4258 | if (_images != (Image *) NULL) |
| 4259 | _images=DestroyImageList(_images); |
| 4260 | _images=GetFirstImageInList(new_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4261 | return; |
| 4262 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4263 | #undef _image_info |
| 4264 | #undef _images |
| 4265 | #undef _exception |
| 4266 | #undef _draw_info |
| 4267 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4268 | #undef IfNormalOp |
| 4269 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4270 | #undef normal_op |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4271 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4272 | |
| 4273 | /* |
| 4274 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4275 | % % |
| 4276 | % % |
| 4277 | % % |
| 4278 | + C L I S p e c i a l O p e r a t i o n s % |
| 4279 | % % |
| 4280 | % % |
| 4281 | % % |
| 4282 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4283 | % |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4284 | % CLISpecialOperator() Applies operations that may not actually need images |
| 4285 | % in an image list wen it is applied. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4286 | % |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4287 | % The classic operators of this type is -read, which actually creates images |
| 4288 | % even when no images are present. Or image stack operators, which can be |
| 4289 | % applied to empty image lists. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4290 | % |
| 4291 | % Note: unlike other Operators, these may involve other special 'option' |
| 4292 | % character prefixes, other than simply '-' or '+'. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4293 | % |
| 4294 | % The format of the CLISpecialOption method is: |
| 4295 | % |
| 4296 | % void CLISpecialOption(MagickCLI *cli_wand,const char *option, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4297 | % const char *arg1) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4298 | % |
| 4299 | % A description of each parameter follows: |
| 4300 | % |
| 4301 | % o cli_wand: the main CLI Wand to use. |
| 4302 | % |
| 4303 | % o option: The special option (with any switch char) to process |
| 4304 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4305 | % o arg1: Argument for option, if required |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4306 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4307 | % Example Usage... |
| 4308 | % |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4309 | % CLISpecialOperator(cli_wand,"-read","rose:"); |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4310 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4311 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4312 | % |
| 4313 | % cli_wand |
| 4314 | % argc,argv |
| 4315 | % i=index in argv |
| 4316 | % |
| 4317 | % option_info = GetCommandOptionInfo(argv[i]); |
| 4318 | % count=option_info->type; |
| 4319 | % option_type=option_info->flags; |
| 4320 | % |
| 4321 | % if ( (option_type & SpecialOptionFlag) != 0 ) |
| 4322 | % CLISpecialOperator(cli_wand,argv[i], |
| 4323 | % count>=1 ? argv[i+1] : (char *)NULL); |
| 4324 | % i += count+1; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4325 | % |
| 4326 | */ |
| 4327 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4328 | WandExport void CLISpecialOperator(MagickCLI *cli_wand, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4329 | const char *option, const char *arg1) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4330 | { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4331 | #define _image_info (cli_wand->wand.image_info) |
| 4332 | #define _images (cli_wand->wand.images) |
| 4333 | #define _exception (cli_wand->wand.exception) |
| 4334 | #define IfNormalOp (*option=='-') |
| 4335 | #define IfPlusOp (*option!='-') |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4336 | |
| 4337 | assert(cli_wand != (MagickCLI *) NULL); |
| 4338 | assert(cli_wand->signature == WandSignature); |
| 4339 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4340 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4341 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4342 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4343 | if(_images != (Image *)NULL) |
| 4344 | (void) SyncImagesSettings(cli_wand->wand.image_info,_images,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4345 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4346 | /* |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4347 | No-op options (ignore these) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4348 | */ |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4349 | if (LocaleCompare("noop",option+1) == 0) /* no argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4350 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4351 | if (LocaleCompare("sans",option+1) == 0) /* one argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4352 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4353 | if (LocaleCompare("sans0",option+1) == 0) /* no argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4354 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4355 | if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4356 | return; |
| 4357 | /* |
| 4358 | Image Reading |
| 4359 | */ |
| 4360 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4361 | ( LocaleCompare("--",option) == 0 ) ) { |
| 4362 | int |
| 4363 | argc; |
| 4364 | char |
| 4365 | **argv; |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4366 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4367 | ssize_t |
| 4368 | i; |
| 4369 | |
| 4370 | /* Expand the filename argument (meta-characters or "@filelist" ) */ |
| 4371 | argc = 1; |
cristy | e71f294 | 2012-04-04 11:07:05 +0000 | [diff] [blame] | 4372 | argv = (char **) &arg1; |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4373 | MagickBooleanType |
| 4374 | status=ExpandFilenames(&argc,&argv); |
| 4375 | |
| 4376 | if (IfMagickFalse(status)) |
| 4377 | CLIWandExceptArgReturn(ResourceLimitError,"MemoryAllocationFailed", |
| 4378 | option,GetExceptionMessage(errno)); |
| 4379 | |
| 4380 | /* loop over expanded list reading images */ |
| 4381 | for (i=0; i<argc; i++) { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4382 | #if !USE_WAND_METHODS |
| 4383 | Image * |
| 4384 | new_images; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4385 | if (IfMagickTrue(_image_info->ping)) |
| 4386 | new_images=PingImages(_image_info,argv[i],_exception); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4387 | else |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4388 | new_images=ReadImages(_image_info,argv[i],_exception); |
| 4389 | AppendImageToList(&_images, new_images); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4390 | #else |
| 4391 | /* read images using MagickWand method - no ping */ |
| 4392 | /* This is not working! - it locks up in a CPU loop! */ |
| 4393 | MagickSetLastIterator(&cli_wand->wand); |
| 4394 | MagickReadImage(&cli_wand->wand,arg1); |
| 4395 | MagickSetFirstIterator(&cli_wand->wand); |
| 4396 | #endif |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4397 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4398 | /* FUTURE: how do I free the expanded filename arguments??? */ |
| 4399 | |
| 4400 | return; |
| 4401 | } |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4402 | /* |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4403 | Image Writing (no-images present is valid in specific cases) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4404 | */ |
| 4405 | if (LocaleCompare("write",option+1) == 0) { |
| 4406 | char |
| 4407 | key[MaxTextExtent]; |
| 4408 | |
| 4409 | Image |
| 4410 | *write_images; |
| 4411 | |
| 4412 | ImageInfo |
| 4413 | *write_info; |
| 4414 | |
| 4415 | /* Need images, unless a "null:" output coder is used */ |
| 4416 | if ( cli_wand->wand.images == (Image *) NULL ) { |
anthony | a9e4f5d | 2012-04-12 06:44:02 +0000 | [diff] [blame] | 4417 | if ( LocaleCompare(arg1,"null:") == 0 ) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4418 | return; |
| 4419 | CLIWandExceptArgReturn(OptionError,"NoImagesForWrite",option,arg1); |
| 4420 | } |
| 4421 | |
| 4422 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
| 4423 | (void) DeleteImageRegistry(key); |
| 4424 | write_images=_images; |
| 4425 | if (IfPlusOp) |
| 4426 | write_images=CloneImageList(_images,_exception); |
| 4427 | write_info=CloneImageInfo(_image_info); |
| 4428 | (void) WriteImages(write_info,write_images,arg1,_exception); |
| 4429 | write_info=DestroyImageInfo(write_info); |
| 4430 | if (IfPlusOp) |
| 4431 | write_images=DestroyImageList(write_images); |
| 4432 | return; |
| 4433 | } |
| 4434 | /* |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4435 | Parenthesis and Brace operations |
| 4436 | */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4437 | if (LocaleCompare("(",option) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4438 | /* stack 'push' images */ |
| 4439 | Stack |
| 4440 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4441 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4442 | size_t |
| 4443 | size; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4444 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4445 | size=0; |
| 4446 | node=cli_wand->image_list_stack; |
| 4447 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4448 | size++; |
| 4449 | if ( size >= MAX_STACK_DEPTH ) |
| 4450 | CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option); |
| 4451 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4452 | if (node == (Stack *) NULL) |
| 4453 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4454 | "MemoryAllocationFailed",option); |
| 4455 | node->data = (void *)cli_wand->wand.images; |
| 4456 | cli_wand->wand.images = NewImageList(); |
| 4457 | node->next = cli_wand->image_list_stack; |
| 4458 | cli_wand->image_list_stack = node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4459 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4460 | /* handle respect-parenthesis */ |
| 4461 | if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info, |
| 4462 | "respect-parenthesis")))) |
| 4463 | option="{"; /* fall-thru so as to push image settings too */ |
| 4464 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4465 | return; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4466 | } |
| 4467 | if (LocaleCompare("{",option) == 0) { |
| 4468 | /* stack 'push' of image_info settings */ |
| 4469 | Stack |
| 4470 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4471 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4472 | size_t |
| 4473 | size; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4474 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4475 | size=0; |
| 4476 | node=cli_wand->image_info_stack; |
| 4477 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4478 | size++; |
| 4479 | if ( size >= MAX_STACK_DEPTH ) |
| 4480 | CLIWandExceptionReturn(OptionError,"CurlyBracesNestedTooDeeply",option); |
| 4481 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4482 | if (node == (Stack *) NULL) |
| 4483 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4484 | "MemoryAllocationFailed",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4485 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4486 | node->data = (void *)cli_wand->wand.image_info; |
| 4487 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
| 4488 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
| 4489 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4490 | option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4491 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4492 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4493 | return; |
| 4494 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4495 | |
| 4496 | node->next = cli_wand->image_info_stack; |
| 4497 | cli_wand->image_info_stack = node; |
| 4498 | |
| 4499 | return; |
| 4500 | } |
| 4501 | if (LocaleCompare(")",option) == 0) { |
| 4502 | /* pop images from stack */ |
| 4503 | Stack |
| 4504 | *node; |
| 4505 | |
| 4506 | node = (Stack *)cli_wand->image_list_stack; |
| 4507 | if ( node == (Stack *)NULL) |
| 4508 | CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option); |
| 4509 | cli_wand->image_list_stack = node->next; |
| 4510 | |
| 4511 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4512 | cli_wand->wand.images= (Image *)node->data; |
| 4513 | node = (Stack *)RelinquishMagickMemory(node); |
| 4514 | |
| 4515 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
| 4516 | node = cli_wand->image_info_stack; |
| 4517 | if ( node != (Stack *)NULL) |
| 4518 | { |
| 4519 | if (IfMagickTrue(IsStringTrue(GetImageOption( |
| 4520 | cli_wand->wand.image_info,"respect-parenthesis")))) |
| 4521 | option="}"; /* fall-thru so as to pop image settings too */ |
| 4522 | else |
| 4523 | return; |
| 4524 | } |
| 4525 | else |
| 4526 | return; |
| 4527 | } |
| 4528 | if (LocaleCompare("}",option) == 0) { |
| 4529 | /* pop image_info settings from stack */ |
| 4530 | Stack |
| 4531 | *node; |
| 4532 | |
| 4533 | node = (Stack *)cli_wand->image_info_stack; |
| 4534 | if ( node == (Stack *)NULL) |
| 4535 | CLIWandExceptionReturn(OptionError,"UnbalancedCurlyBraces",option); |
| 4536 | cli_wand->image_info_stack = node->next; |
| 4537 | |
| 4538 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
| 4539 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4540 | node = (Stack *)RelinquishMagickMemory(node); |
| 4541 | |
| 4542 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4543 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4544 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4545 | |
| 4546 | return; |
| 4547 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4548 | if (LocaleCompare("clone",option+1) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4549 | Image |
| 4550 | *new_images; |
| 4551 | |
| 4552 | if (*option == '+') |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4553 | arg1="-1"; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4554 | if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4555 | CLIWandExceptionReturn(OptionError,"InvalidArgument",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4556 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4557 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4558 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4559 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4560 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
| 4561 | new_images=CloneImages(new_images,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4562 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4563 | CLIWandExceptionReturn(OptionError,"NoSuchImage",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4564 | AppendImageToList(&_images,new_images); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4565 | return; |
| 4566 | } |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4567 | /* |
| 4568 | Informational Operations |
| 4569 | */ |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4570 | if (LocaleCompare("version",option+1) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4571 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
| 4572 | GetMagickVersion((size_t *) NULL)); |
| 4573 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 4574 | GetMagickCopyright()); |
| 4575 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 4576 | GetMagickFeatures()); |
| 4577 | return; |
| 4578 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4579 | if (LocaleCompare("list",option+1) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4580 | /* FUTURE: This should really be built into the MagickCore |
| 4581 | It does not actually require a cli-wand or and images! |
| 4582 | */ |
| 4583 | ssize_t |
| 4584 | list; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4585 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4586 | list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); |
| 4587 | if ( list < 0 ) { |
| 4588 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4589 | return; |
| 4590 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4591 | switch (list) |
| 4592 | { |
| 4593 | case MagickCoderOptions: |
| 4594 | { |
| 4595 | (void) ListCoderInfo((FILE *) NULL,_exception); |
| 4596 | break; |
| 4597 | } |
| 4598 | case MagickColorOptions: |
| 4599 | { |
| 4600 | (void) ListColorInfo((FILE *) NULL,_exception); |
| 4601 | break; |
| 4602 | } |
| 4603 | case MagickConfigureOptions: |
| 4604 | { |
| 4605 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
| 4606 | break; |
| 4607 | } |
| 4608 | case MagickDelegateOptions: |
| 4609 | { |
| 4610 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
| 4611 | break; |
| 4612 | } |
| 4613 | case MagickFontOptions: |
| 4614 | { |
| 4615 | (void) ListTypeInfo((FILE *) NULL,_exception); |
| 4616 | break; |
| 4617 | } |
| 4618 | case MagickFormatOptions: |
| 4619 | (void) ListMagickInfo((FILE *) NULL,_exception); |
| 4620 | break; |
| 4621 | case MagickLocaleOptions: |
| 4622 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
| 4623 | break; |
| 4624 | case MagickLogOptions: |
| 4625 | (void) ListLogInfo((FILE *) NULL,_exception); |
| 4626 | break; |
| 4627 | case MagickMagicOptions: |
| 4628 | (void) ListMagicInfo((FILE *) NULL,_exception); |
| 4629 | break; |
| 4630 | case MagickMimeOptions: |
| 4631 | (void) ListMimeInfo((FILE *) NULL,_exception); |
| 4632 | break; |
| 4633 | case MagickModuleOptions: |
| 4634 | (void) ListModuleInfo((FILE *) NULL,_exception); |
| 4635 | break; |
| 4636 | case MagickPolicyOptions: |
| 4637 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
| 4638 | break; |
| 4639 | case MagickResourceOptions: |
| 4640 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
| 4641 | break; |
| 4642 | case MagickThresholdOptions: |
| 4643 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
| 4644 | break; |
| 4645 | default: |
| 4646 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
| 4647 | _exception); |
| 4648 | break; |
| 4649 | } |
| 4650 | return; |
| 4651 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4652 | |
| 4653 | #if 0 |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4654 | // Other 'special' options this should handle |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 4655 | // "region" "reset" "arg" |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4656 | if ( ( process_flags & ProcessUnknownOptionError ) != 0 ) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4657 | #endif |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4658 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4659 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4660 | #undef _image_info |
| 4661 | #undef _images |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4662 | #undef _exception |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4663 | #undef IfNormalOp |
| 4664 | #undef IfPlusOp |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4665 | } |