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 | 45ef08f | 2012-12-07 13:13:34 +0000 | [diff] [blame] | 20 | % Copyright 1999-2013 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" |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 60 | #include "MagickCore/pixel-private.h" |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 61 | |
| 62 | /* |
| 63 | Define declarations. |
| 64 | */ |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 65 | #define USE_WAND_METHODS 1 |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 66 | #define MAX_STACK_DEPTH 32 |
| 67 | #define UNDEFINED_COMPRESSION_QUALITY 0UL |
| 68 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 69 | /* FUTURE: why is this default so specific? */ |
| 70 | #define DEFAULT_DISSIMILARITY_THRESHOLD "0.31830988618379067154" |
| 71 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 72 | /* |
| 73 | Constant declaration. (temporary exports) |
| 74 | */ |
| 75 | static const char |
| 76 | BackgroundColor[] = "#fff", /* white */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 77 | BorderColor[] = "#dfdfdf", /* sRGB gray */ |
| 78 | MatteColor[] = "#bdbdbd"; /* slightly darker gray */ |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 79 | |
| 80 | /* For Debugging Geometry Input */ |
| 81 | #define ReportGeometry(flags,info) \ |
| 82 | (void) FormatLocaleFile(stderr, "Geometry = 0x%04X : %lg x %lg %+lg %+lg\n", \ |
| 83 | flags, info.rho, info.sigma, info.xi, info.psi ) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | ** Function to report on the progress of image operations |
| 87 | */ |
| 88 | static MagickBooleanType MonitorProgress(const char *text, |
| 89 | const MagickOffsetType offset,const MagickSizeType extent, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 90 | void *wand_unused(cli_wandent_data)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 91 | { |
| 92 | char |
| 93 | message[MaxTextExtent], |
| 94 | tag[MaxTextExtent]; |
| 95 | |
| 96 | const char |
| 97 | *locale_message; |
| 98 | |
| 99 | register char |
| 100 | *p; |
| 101 | |
| 102 | if (extent < 2) |
| 103 | return(MagickTrue); |
| 104 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 105 | p=strrchr(tag,'/'); |
| 106 | if (p != (char *) NULL) |
| 107 | *p='\0'; |
| 108 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
| 109 | locale_message=GetLocaleMessage(message); |
| 110 | if (locale_message == message) |
| 111 | locale_message=tag; |
| 112 | if (p == (char *) NULL) |
| 113 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 114 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 115 | (100L*offset/(extent-1))); |
| 116 | else |
| 117 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
| 118 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 119 | (100L*offset/(extent-1))); |
| 120 | if (offset == (MagickOffsetType) (extent-1)) |
| 121 | (void) FormatLocaleFile(stderr,"\n"); |
| 122 | (void) fflush(stderr); |
| 123 | return(MagickTrue); |
| 124 | } |
| 125 | |
| 126 | /* |
| 127 | ** GetImageCache() will read an image into a image cache if not already |
| 128 | ** present then return the image that is in the cache under that filename. |
| 129 | */ |
| 130 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 131 | ExceptionInfo *exception) |
| 132 | { |
| 133 | char |
| 134 | key[MaxTextExtent]; |
| 135 | |
| 136 | ExceptionInfo |
| 137 | *sans_exception; |
| 138 | |
| 139 | Image |
| 140 | *image; |
| 141 | |
| 142 | ImageInfo |
| 143 | *read_info; |
| 144 | |
| 145 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
| 146 | sans_exception=AcquireExceptionInfo(); |
| 147 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 148 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 149 | if (image != (Image *) NULL) |
| 150 | return(image); |
| 151 | read_info=CloneImageInfo(image_info); |
| 152 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 153 | image=ReadImage(read_info,exception); |
| 154 | read_info=DestroyImageInfo(read_info); |
| 155 | if (image != (Image *) NULL) |
| 156 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 157 | return(image); |
| 158 | } |
| 159 | |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 160 | /* |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 161 | SparseColorOption() parse the complex -sparse-color argument into an |
| 162 | an array of floating point values than call SparseColorImage(). |
| 163 | Argument is a complex mix of floating-point pixel coodinates, and color |
| 164 | specifications (or direct floating point numbers). The number of floats |
| 165 | needed to represent a color varies depending on teh current channel |
| 166 | setting. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 167 | |
| 168 | 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] | 169 | */ |
| 170 | static Image *SparseColorOption(const Image *image, |
| 171 | const SparseColorMethod method,const char *arguments, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 172 | ExceptionInfo *exception) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 173 | { |
| 174 | char |
| 175 | token[MaxTextExtent]; |
| 176 | |
| 177 | const char |
| 178 | *p; |
| 179 | |
| 180 | double |
| 181 | *sparse_arguments; |
| 182 | |
| 183 | Image |
| 184 | *sparse_image; |
| 185 | |
| 186 | PixelInfo |
| 187 | color; |
| 188 | |
| 189 | MagickBooleanType |
| 190 | error; |
| 191 | |
| 192 | register size_t |
| 193 | x; |
| 194 | |
| 195 | size_t |
| 196 | number_arguments, |
| 197 | number_colors; |
| 198 | |
| 199 | assert(image != (Image *) NULL); |
| 200 | assert(image->signature == MagickSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 201 | if (IfMagickTrue(image->debug)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 202 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 203 | assert(exception != (ExceptionInfo *) NULL); |
| 204 | assert(exception->signature == MagickSignature); |
| 205 | /* |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 206 | Limit channels according to image |
| 207 | add up number of values needed per color. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 208 | */ |
| 209 | number_colors=0; |
| 210 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 211 | number_colors++; |
| 212 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 213 | number_colors++; |
| 214 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 215 | number_colors++; |
| 216 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 217 | (image->colorspace == CMYKColorspace)) |
| 218 | number_colors++; |
| 219 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 220 | image->alpha_trait == BlendPixelTrait) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 221 | number_colors++; |
| 222 | |
| 223 | /* |
| 224 | Read string, to determine number of arguments needed, |
| 225 | */ |
| 226 | p=arguments; |
| 227 | x=0; |
| 228 | while( *p != '\0' ) |
| 229 | { |
| 230 | GetMagickToken(p,&p,token); |
| 231 | if ( token[0] == ',' ) continue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 232 | if ( isalpha((int) token[0]) || token[0] == '#' ) |
| 233 | x += number_colors; /* color argument found */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 234 | else |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 235 | x++; /* floating point argument */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 236 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 237 | /* control points and color values */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 238 | error = IsMagickTrue( x % (2+number_colors) ); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 239 | number_arguments=x; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 240 | if ( IfMagickTrue(error) ) { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 241 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 242 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 243 | "Invalid number of Arguments"); |
| 244 | return( (Image *)NULL); |
| 245 | } |
| 246 | |
| 247 | /* Allocate and fill in the floating point arguments */ |
| 248 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 249 | sizeof(*sparse_arguments)); |
| 250 | if (sparse_arguments == (double *) NULL) { |
| 251 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 252 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 253 | return( (Image *)NULL); |
| 254 | } |
| 255 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 256 | sizeof(*sparse_arguments)); |
| 257 | p=arguments; |
| 258 | x=0; |
| 259 | while( *p != '\0' && x < number_arguments ) { |
| 260 | /* X coordinate */ |
| 261 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 262 | if ( token[0] == '\0' ) break; |
| 263 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 264 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 265 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 266 | "Color found, instead of X-coord"); |
| 267 | error = MagickTrue; |
| 268 | break; |
| 269 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 270 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 271 | /* Y coordinate */ |
| 272 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 273 | if ( token[0] == '\0' ) break; |
| 274 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 275 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 276 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 277 | "Color found, instead of Y-coord"); |
| 278 | error = MagickTrue; |
| 279 | break; |
| 280 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 281 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 282 | /* color name or function given in string argument */ |
| 283 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 284 | if ( token[0] == '\0' ) break; |
| 285 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 286 | /* Color string given */ |
| 287 | (void) QueryColorCompliance(token,AllCompliance,&color, |
| 288 | exception); |
| 289 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 290 | sparse_arguments[x++] = QuantumScale*color.red; |
| 291 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 292 | sparse_arguments[x++] = QuantumScale*color.green; |
| 293 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 294 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 295 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 296 | (image->colorspace == CMYKColorspace)) |
| 297 | sparse_arguments[x++] = QuantumScale*color.black; |
| 298 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 299 | image->alpha_trait == BlendPixelTrait) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 300 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 301 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 302 | else { |
| 303 | /* Colors given as a set of floating point values - experimental */ |
| 304 | /* NB: token contains the first floating point value to use! */ |
| 305 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 306 | { |
| 307 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 308 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 309 | break; |
| 310 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 311 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 312 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 313 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 314 | { |
| 315 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 316 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 317 | break; |
| 318 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 319 | token[0] = ','; /* used this token - get another */ |
| 320 | } |
| 321 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 322 | { |
| 323 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 324 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 325 | break; |
| 326 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 327 | token[0] = ','; /* used this token - get another */ |
| 328 | } |
| 329 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 330 | (image->colorspace == CMYKColorspace)) |
| 331 | { |
| 332 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 333 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 334 | break; |
| 335 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 336 | token[0] = ','; /* used this token - get another */ |
| 337 | } |
| 338 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 339 | image->alpha_trait == BlendPixelTrait) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 340 | { |
| 341 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 342 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 343 | break; |
| 344 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 345 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | } |
| 349 | if ( number_arguments != x && !error ) { |
| 350 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 351 | "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 352 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 353 | return( (Image *)NULL); |
| 354 | } |
| 355 | if ( error ) |
| 356 | return( (Image *)NULL); |
| 357 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 358 | /* Call the Sparse Color Interpolation function with the parsed arguments */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 359 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 360 | exception); |
| 361 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 362 | return( sparse_image ); |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 367 | % % |
| 368 | % % |
| 369 | % % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 370 | % C L I S e t t i n g O p t i o n I n f o % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 371 | % % |
| 372 | % % |
| 373 | % % |
| 374 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 375 | % |
| 376 | % CLISettingOptionInfo() applies a single settings option into a CLI wand |
| 377 | % holding the image_info, draw_info, quantize_info structures that will be |
| 378 | % used when processing the images. |
| 379 | % |
| 380 | % These options do no require images to be present in the CLI wand for them |
| 381 | % to be able to be set, in which case they will generally be applied to image |
| 382 | % that are read in later |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 383 | % |
| 384 | % Options handled by this function are listed in CommandOptions[] of |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 385 | % "option.c" that is one of "SettingOptionFlags" option flags. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 386 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 387 | % The format of the CLISettingOptionInfo method is: |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 388 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 389 | % void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 390 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 391 | % |
| 392 | % A description of each parameter follows: |
| 393 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 394 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 395 | % |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 396 | % o option: The option string to be set |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 397 | % |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 398 | % o arg1, arg2: optional argument strings to the operation |
| 399 | % arg2 is currently only used by "-limit" |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 400 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 401 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 402 | WandPrivate 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 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 405 | ssize_t |
| 406 | parse; /* option argument parsing (string to value table lookup) */ |
| 407 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 408 | assert(cli_wand != (MagickCLI *) NULL); |
| 409 | assert(cli_wand->signature == WandSignature); |
| 410 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 411 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 412 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 413 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 414 | #define _image_info (cli_wand->wand.image_info) |
| 415 | #define _exception (cli_wand->wand.exception) |
| 416 | #define _draw_info (cli_wand->draw_info) |
| 417 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 418 | #define IfSetOption (*option=='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 419 | #define ArgBoolean IsMagickTrue(IfSetOption) |
| 420 | #define ArgBooleanNot IsMagickFalse(IfSetOption) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 421 | #define ArgBooleanString (IfSetOption?"true":"false") |
| 422 | #define ArgOption(def) (IfSetOption?arg1:(const char *)(def)) |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 423 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 424 | #if 0 |
| 425 | Setting are not directly involved with images, so can not |
| 426 | interpret Percent Escapes in Arguments, At least not yet */ |
| 427 | |
| 428 | #define _process_flags (cli_wand->process_flags) |
| 429 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
| 430 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 431 | arg1 = arg1n, |
| 432 | arg2 = arg2n; |
| 433 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 434 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 435 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 436 | /* Interpret Percent escapes in argument 1 */ |
| 437 | if (arg1n != (char *) NULL) { |
| 438 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 439 | if (arg1 == (char *) NULL) { |
| 440 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 441 | arg1=arg1n; /* use the given argument as is */ |
| 442 | } |
| 443 | } |
| 444 | if (arg2n != (char *) NULL) { |
| 445 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 446 | if (arg2 == (char *) NULL) { |
| 447 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 448 | arg2=arg2n; /* use the given argument as is */ |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | #undef _process_flags |
| 453 | #undef _option_type |
| 454 | #endif |
| 455 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 456 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 457 | { |
| 458 | case 'a': |
| 459 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 460 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 461 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 462 | _image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 463 | break; |
| 464 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 465 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 466 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 467 | CLIWandWarnReplaced("-draw 'affine ...'"); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 468 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 469 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 470 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 471 | GetAffineMatrix(&_draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 472 | break; |
| 473 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 474 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 475 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 476 | _image_info->antialias = |
| 477 | _draw_info->stroke_antialias = |
| 478 | _draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 479 | break; |
| 480 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 481 | if (LocaleCompare("attenuate",option+1) == 0) |
| 482 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 483 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 484 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 485 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 486 | break; |
| 487 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 488 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 489 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 490 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 491 | break; |
| 492 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 493 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 494 | } |
| 495 | case 'b': |
| 496 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 497 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 498 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 499 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 500 | _image_info only used directly for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 501 | SyncImageSettings() used to set per-image attribute. |
| 502 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 503 | FUTURE: if _image_info->background_color is not set then |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 504 | we should fall back to per-image background_color |
| 505 | |
| 506 | At this time -background will 'wipe out' the per-image |
| 507 | background color! |
| 508 | |
| 509 | Better error handling of QueryColorCompliance() needed. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 510 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 511 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 512 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 513 | &_image_info->background_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 514 | break; |
| 515 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 516 | if (LocaleCompare("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 517 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 518 | /* FUTURE: bias OBSOLETED, replaced by Artifact "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 519 | as it is actually rarely used except in direct convolve operations |
| 520 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 521 | |
| 522 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 523 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 524 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 525 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 526 | (void) SetImageOption(_image_info,"convolve:bias",ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 527 | break; |
| 528 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 529 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 530 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 531 | /* Used as a image chromaticity setting |
| 532 | SyncImageSettings() used to set per-image attribute. |
| 533 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 534 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 535 | break; |
| 536 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 537 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 538 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 539 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 540 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 541 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 542 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 543 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 544 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 545 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 546 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 547 | break; |
| 548 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 549 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 550 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 551 | /* FUTURE: both _image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 552 | SyncImageSettings() used to set per-image attribute. |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 553 | Better error checking of QueryColorCompliance(). |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 554 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 555 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 556 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 557 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 558 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 559 | &_image_info->border_color,_exception); |
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 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 562 | break; |
| 563 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 564 | (void) DeleteImageOption(_image_info,option+1); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 565 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 566 | &_image_info->border_color,_exception); |
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 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 569 | break; |
| 570 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 571 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 572 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 573 | CLIWandWarnReplaced("-undercolor"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 574 | CLISettingOptionInfo(cli_wand,"-undercolor",arg1, arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 575 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 576 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 577 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 578 | } |
| 579 | case 'c': |
| 580 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 581 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 582 | { |
| 583 | MagickSizeType |
| 584 | limit; |
| 585 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 586 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 587 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 588 | limit=MagickResourceInfinity; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 589 | if (LocaleCompare("unlimited",arg1) != 0) |
| 590 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 591 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 592 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 593 | break; |
| 594 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 595 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 596 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 597 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 598 | break; |
| 599 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 600 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 601 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 602 | arg1=ArgOption("default"); |
| 603 | parse=ParseChannelOption(arg1); |
| 604 | if (parse < 0) |
| 605 | CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType", |
| 606 | option,arg1); |
| 607 | _image_info->channel=(ChannelType) parse; |
| 608 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 609 | break; |
| 610 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 611 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 612 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 613 | /* Setting used for new images via AquireImage() |
| 614 | But also used as a SimpleImageOperator |
| 615 | Undefined colorspace means don't modify images on |
| 616 | read or as a operation */ |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 617 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 618 | ArgOption("undefined")); |
| 619 | if (parse < 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 620 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 621 | option,arg1); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 622 | _image_info->colorspace=(ColorspaceType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 623 | break; |
| 624 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 625 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 626 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 627 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 628 | break; |
| 629 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 630 | if (LocaleCompare("compose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 631 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 632 | /* FUTURE: _image_info should be used, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 633 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 634 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 635 | This setting should NOT be used to set image 'compose' |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 636 | "-layer" operators shoud use _image_info if defined otherwise |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 637 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 638 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 639 | parse = ParseCommandOption(MagickComposeOptions,MagickFalse, |
| 640 | ArgOption("undefined")); |
| 641 | if (parse < 0) |
| 642 | CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", |
| 643 | option,arg1); |
| 644 | _image_info->compose=(CompositeOperator) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 645 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 646 | break; |
| 647 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 648 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 649 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 650 | /* FUTURE: What should be used? _image_info or ImageOption ??? |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 651 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 652 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 653 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 654 | The coders appears to use _image_info, not Image_Option |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 655 | however the image attribute (for save) is set from the |
| 656 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 657 | |
| 658 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 659 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 660 | parse = ParseCommandOption(MagickCompressOptions,MagickFalse, |
| 661 | ArgOption("undefined")); |
| 662 | if (parse < 0) |
| 663 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", |
| 664 | option,arg1); |
| 665 | _image_info->compression=(CompressionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 666 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 667 | break; |
| 668 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 669 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 670 | } |
| 671 | case 'd': |
| 672 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 673 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 674 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 675 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 676 | arg1=ArgOption("none"); |
| 677 | parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); |
| 678 | if (parse < 0) |
| 679 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", |
| 680 | option,arg1); |
| 681 | (void) SetLogEventMask(arg1); |
| 682 | _image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 683 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 684 | break; |
| 685 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 686 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 687 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 688 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 689 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 690 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 691 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 692 | else |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 693 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 694 | break; |
| 695 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 696 | /* DefineImageOption() equals SetImageOption() but with '=' */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 697 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 698 | (void) DefineImageOption(_image_info,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 699 | else if (IsMagickFalse(DeleteImageOption(_image_info,arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 700 | CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 701 | break; |
| 702 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 703 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 704 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 705 | /* Only used for new images via AcquireImage() |
| 706 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 707 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 708 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 709 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 710 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 711 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 712 | break; |
| 713 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 714 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 715 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 716 | /* FUTURE: strings used in _image_info attr and _draw_info! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 717 | Basically as density can be in a XxY form! |
| 718 | |
| 719 | SyncImageSettings() used to set per-image attribute. |
| 720 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 721 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 722 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 723 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 724 | (void) CloneString(&_image_info->density,ArgOption(NULL)); |
| 725 | (void) CloneString(&_draw_info->density,_image_info->density); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 726 | break; |
| 727 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 728 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 729 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 730 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 731 | SyncImageSettings() used to set per-image attribute. |
| 732 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 733 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 734 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 735 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 736 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 737 | break; |
| 738 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 739 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 740 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 741 | /* Image Option is only used to set _draw_info */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 742 | arg1=ArgOption("undefined"); |
| 743 | parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); |
| 744 | if (parse < 0) |
| 745 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", |
| 746 | option,arg1); |
| 747 | _draw_info->direction=(DirectionType) parse; |
| 748 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 749 | break; |
| 750 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 751 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 752 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 753 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); |
| 754 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 755 | break; |
| 756 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 757 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 758 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 759 | /* only used in setting new images */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 760 | arg1=ArgOption("undefined"); |
| 761 | parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); |
| 762 | if (parse < 0) |
| 763 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", |
| 764 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 765 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 766 | break; |
| 767 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 768 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 769 | { |
| 770 | /* FUTURE: this is only used by CompareImages() which is used |
| 771 | only by the "compare" CLI program at this time. */ |
| 772 | arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD); |
| 773 | if (IfMagickFalse(IsGeometry(arg1))) |
| 774 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 775 | (void) SetImageOption(_image_info,option+1,arg1); |
| 776 | break; |
| 777 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 778 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 779 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 780 | /* _image_info attr (on/off), _quantize_info attr (on/off) |
| 781 | but also ImageInfo and _quantize_info method! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 782 | FUTURE: merge the duality of the dithering options |
| 783 | */ |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 784 | _image_info->dither = ArgBoolean; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 785 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); |
| 786 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 787 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 788 | if (_quantize_info->dither_method == NoDitherMethod) |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 789 | _image_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 790 | break; |
| 791 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 792 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 793 | } |
| 794 | case 'e': |
| 795 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 796 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 797 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 798 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); |
| 799 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 800 | break; |
| 801 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 802 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 803 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 804 | /* Both _image_info attr and ImageInfo */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 805 | arg1 = ArgOption("undefined"); |
| 806 | parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); |
| 807 | if (parse < 0) |
| 808 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", |
| 809 | option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 810 | /* FUTURE: check alloc/free of endian string! - remove? */ |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 811 | _image_info->endian=(EndianType) (*arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 812 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 813 | break; |
| 814 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 815 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 816 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 817 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 818 | break; |
| 819 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 820 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 821 | } |
| 822 | case 'f': |
| 823 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 824 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 825 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 826 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 827 | break; |
| 828 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 829 | if (LocaleCompare("fill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 830 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 831 | /* Set "fill" OR "fill-pattern" in _draw_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 832 | The original fill color is preserved if a fill-pattern is given. |
| 833 | That way it does not effect other operations that directly using |
| 834 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 835 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 836 | MagickBooleanType |
| 837 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 838 | |
| 839 | ExceptionInfo |
| 840 | *sans; |
| 841 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 842 | PixelInfo |
| 843 | color; |
| 844 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 845 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 846 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 847 | if (_draw_info->fill_pattern != (Image *) NULL) |
| 848 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 849 | |
| 850 | /* is it a color or a image? -- ignore exceptions */ |
| 851 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 852 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 853 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 854 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 855 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 856 | _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 857 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 858 | _draw_info->fill=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 859 | break; |
| 860 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 861 | if (LocaleCompare("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 862 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 863 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 864 | arg1 = ArgOption("undefined"); |
| 865 | parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); |
| 866 | if (parse < 0) |
| 867 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", |
| 868 | option,arg1); |
| 869 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 870 | break; |
| 871 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 872 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 873 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 874 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); |
| 875 | (void) CloneString(&_image_info->font,_draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 876 | break; |
| 877 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 878 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 879 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 880 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 881 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 882 | register const char |
| 883 | *q; |
| 884 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 885 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 886 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 887 | _image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 888 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 889 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 890 | break; |
| 891 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 892 | if (LocaleCompare("fuzz",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 893 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 894 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 895 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 896 | SyncImageSettings() used to set per-image attribute. |
| 897 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 898 | FUTURE: Can't find anything else using _image_info->fuzz directly! |
| 899 | remove direct sttribute from image_info |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 900 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 901 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 902 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 903 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 904 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 905 | QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 906 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 907 | break; |
| 908 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 909 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 910 | } |
| 911 | case 'g': |
| 912 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 913 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 914 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 915 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 916 | arg1 = ArgOption("none"); |
| 917 | parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); |
| 918 | if (parse < 0) |
| 919 | CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", |
| 920 | option,arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 921 | _draw_info->gravity=(GravityType) parse; |
anthony | e849097 | 2012-04-03 13:16:01 +0000 | [diff] [blame] | 922 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 923 | break; |
| 924 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 925 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 926 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 927 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 928 | SyncImageSettings() used to set per-image attribute. |
| 929 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 930 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 931 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 932 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 933 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 934 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 935 | break; |
| 936 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 937 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 938 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 939 | case 'h': |
| 940 | { |
| 941 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 942 | { |
| 943 | /* FUTURE: this is only used by CompareImages() which is used |
| 944 | only by the "compare" CLI program at this time. */ |
| 945 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 946 | break; |
| 947 | } |
| 948 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
| 949 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 950 | case 'i': |
| 951 | { |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame^] | 952 | if (LocaleCompare("intensity",option+1) == 0) |
| 953 | { |
| 954 | arg1 = ArgOption("undefined"); |
| 955 | parse = ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,arg1); |
| 956 | if (parse < 0) |
| 957 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType",option,arg1); |
| 958 | (void) SetImageOption(_image_info,option+1,arg1); |
| 959 | break; |
| 960 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 961 | if (LocaleCompare("intent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 962 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 963 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 964 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 965 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 966 | */ |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame^] | 967 | arg1 = ArgOption("undefined"); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 968 | parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); |
| 969 | if (parse < 0) |
| 970 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", |
| 971 | option,arg1); |
| 972 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 973 | break; |
| 974 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 975 | if (LocaleCompare("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 976 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 977 | /* _image_info is directly used by coders (so why an image setting?) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 978 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 979 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 980 | arg1 = ArgOption("undefined"); |
| 981 | parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); |
| 982 | if (parse < 0) |
| 983 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", |
| 984 | option,arg1); |
| 985 | _image_info->interlace=(InterlaceType) parse; |
| 986 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 987 | break; |
| 988 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 989 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 990 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 991 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 992 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 993 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 994 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 995 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 996 | break; |
| 997 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 998 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 999 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1000 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1001 | arg1 = ArgOption("undefined"); |
| 1002 | parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); |
| 1003 | if (parse < 0) |
| 1004 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", |
| 1005 | option,arg1); |
| 1006 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1007 | break; |
| 1008 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1009 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1010 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1011 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1012 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1013 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1014 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1015 | break; |
| 1016 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1017 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1018 | } |
| 1019 | case 'k': |
| 1020 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1021 | if (LocaleCompare("kerning",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1022 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1023 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1024 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1025 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1026 | _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1027 | break; |
| 1028 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1029 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1030 | } |
| 1031 | case 'l': |
| 1032 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1033 | if (LocaleCompare("label",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1034 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1035 | /* only used for new images - not in SyncImageOptions() */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1036 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1037 | break; |
| 1038 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1039 | if (LocaleCompare("limit",option+1) == 0) |
| 1040 | { |
| 1041 | MagickSizeType |
| 1042 | limit; |
| 1043 | |
| 1044 | limit=MagickResourceInfinity; |
| 1045 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 1046 | if ( parse < 0 ) |
| 1047 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 1048 | option,arg1); |
| 1049 | if (LocaleCompare("unlimited",arg2) != 0) |
| 1050 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
| 1051 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
| 1052 | break; |
| 1053 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1054 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1055 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1056 | if (IfSetOption) { |
| 1057 | if ((strchr(arg1,'%') == (char *) NULL)) |
| 1058 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1059 | (void) SetLogFormat(arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1060 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1061 | break; |
| 1062 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1063 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1064 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1065 | /* FUTURE: this is only used by CompareImages() which is used |
| 1066 | only by the "compare" CLI program at this time. */ |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1067 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1068 | break; |
| 1069 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1070 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1071 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1072 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1073 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1074 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1075 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1076 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1077 | break; |
| 1078 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1079 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1080 | } |
| 1081 | case 'm': |
| 1082 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1083 | if (LocaleCompare("mattecolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1084 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1085 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1086 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1087 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1088 | &_image_info->matte_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1089 | break; |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1090 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1091 | if (LocaleCompare("metric",option+1) == 0) |
| 1092 | { |
| 1093 | /* FUTURE: this is only used by CompareImages() which is used |
| 1094 | only by the "compare" CLI program at this time. */ |
| 1095 | parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1); |
| 1096 | if ( parse < 0 ) |
| 1097 | CLIWandExceptArgBreak(OptionError,"UnrecognizedMetricType", |
| 1098 | option,arg1); |
| 1099 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1100 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1101 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1102 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1103 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1104 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1105 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1106 | break; |
| 1107 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1108 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1109 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1110 | /* Setting (used by some input coders!) -- why? |
| 1111 | Warning: This is also Special '-type' SimpleOperator |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1112 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1113 | _image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1114 | break; |
| 1115 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1116 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1117 | } |
| 1118 | case 'o': |
| 1119 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1120 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1121 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1122 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1123 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1124 | FUTURE: make set meta-data operator instead. |
| 1125 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1126 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1127 | parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
| 1128 | ArgOption("undefined")); |
| 1129 | if (parse < 0) |
| 1130 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", |
| 1131 | option,arg1); |
| 1132 | _image_info->orientation=(OrientationType)parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1133 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1134 | break; |
| 1135 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1136 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1137 | } |
| 1138 | case 'p': |
| 1139 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1140 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1141 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1142 | /* Only used for new images and image generators. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1143 | SyncImageSettings() used to set per-image attribute. ????? |
| 1144 | That last is WRONG!!!! |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1145 | FUTURE: adjust named 'page' sizes according density |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1146 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1147 | char |
| 1148 | *canonical_page, |
| 1149 | page[MaxTextExtent]; |
| 1150 | |
| 1151 | const char |
| 1152 | *image_option; |
| 1153 | |
| 1154 | MagickStatusType |
| 1155 | flags; |
| 1156 | |
| 1157 | RectangleInfo |
| 1158 | geometry; |
| 1159 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1160 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1161 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1162 | (void) DeleteImageOption(_image_info,option+1); |
| 1163 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1164 | break; |
| 1165 | } |
| 1166 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1167 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1168 | if (image_option != (const char *) NULL) |
| 1169 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1170 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1171 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1172 | canonical_page=DestroyString(canonical_page); |
| 1173 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1174 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1175 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1176 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1177 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1178 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1179 | (void) SetImageOption(_image_info,option+1,page); |
| 1180 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1181 | break; |
| 1182 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1183 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1184 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1185 | _image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1186 | break; |
| 1187 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1188 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1189 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1190 | if (IfSetOption) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1191 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1192 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1193 | _image_info->pointsize = |
| 1194 | _draw_info->pointsize = |
| 1195 | StringToDouble(arg1,(char **) NULL); |
| 1196 | } |
| 1197 | else { |
| 1198 | _image_info->pointsize=0.0; /* unset pointsize */ |
| 1199 | _draw_info->pointsize=12.0; |
| 1200 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1201 | break; |
| 1202 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1203 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1204 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1205 | arg1=ArgOption("-1"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1206 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1207 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1208 | (void) SetMagickPrecision(StringToInteger(arg1)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1209 | break; |
| 1210 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1211 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1212 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1213 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1214 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1215 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1216 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1217 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1218 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1219 | break; |
| 1220 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 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 'q': |
| 1225 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1226 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1227 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1228 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1229 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1230 | _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1) |
| 1231 | : UNDEFINED_COMPRESSION_QUALITY; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1232 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1233 | break; |
| 1234 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1235 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1236 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1237 | /* Just a set direct in _quantize_info */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1238 | arg1=ArgOption("undefined"); |
| 1239 | parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
| 1240 | if (parse < 0) |
| 1241 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 1242 | option,arg1); |
| 1243 | _quantize_info->colorspace=(ColorspaceType)parse; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1244 | break; |
| 1245 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1246 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1247 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1248 | /* FUTURE: if two -quiet is performed you can not do +quiet! |
| 1249 | This needs to be checked over thoughly. |
| 1250 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1251 | static WarningHandler |
| 1252 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1253 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1254 | WarningHandler |
| 1255 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1256 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1257 | if ( tmp != (WarningHandler) NULL) |
| 1258 | warning_handler = tmp; /* remember the old handler */ |
| 1259 | if (!IfSetOption) /* set the old handler */ |
| 1260 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1261 | break; |
| 1262 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1263 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1264 | } |
| 1265 | case 'r': |
| 1266 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1267 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1268 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1269 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1270 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1271 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1272 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1273 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1274 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1275 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1276 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1277 | break; |
| 1278 | } |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1279 | if (LocaleCompare("regard-warnings",option+1) == 0) |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 1280 | /* FUTURE: to be replaced by a 'fatal-level' type setting */ |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1281 | break; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1282 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1283 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1284 | /* _draw_info only setting */ |
| 1285 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1286 | break; |
| 1287 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1288 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
| 1289 | { |
| 1290 | /* link image and setting stacks - option is itself saved on stack! */ |
| 1291 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1292 | break; |
| 1293 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1294 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1295 | } |
| 1296 | case 's': |
| 1297 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1298 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1299 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1300 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1301 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1302 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1303 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1304 | break; |
| 1305 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1306 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1307 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1308 | /* SyncImageSettings() used to set this as a per-image attribute. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1309 | What ??? Why ???? |
| 1310 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1311 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1312 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1313 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1314 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1315 | break; |
| 1316 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1317 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1318 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1319 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1320 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame] | 1321 | SetRandomSecretKey( |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 1322 | IfSetOption ? (unsigned long) StringToUnsignedLong(arg1) |
| 1323 | : (unsigned long) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1324 | break; |
| 1325 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1326 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1327 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1328 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1329 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1330 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1331 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1332 | break; |
| 1333 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1334 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1335 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1336 | arg1=ArgOption("undefined"); |
| 1337 | parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1); |
| 1338 | if (parse < 0) |
| 1339 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStretchType", |
| 1340 | option,arg1); |
| 1341 | _draw_info->stretch=(StretchType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1342 | break; |
| 1343 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1344 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1345 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1346 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1347 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1348 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1349 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1350 | MagickBooleanType |
| 1351 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1352 | |
| 1353 | ExceptionInfo |
| 1354 | *sans; |
| 1355 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1356 | PixelInfo |
| 1357 | color; |
| 1358 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1359 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1360 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1361 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1362 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1363 | |
| 1364 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1365 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1366 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1367 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1368 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1369 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1370 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1371 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1372 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1373 | break; |
| 1374 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1375 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1376 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1377 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1378 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1379 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1380 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1381 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1382 | break; |
| 1383 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1384 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1385 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1386 | arg1=ArgOption("undefined"); |
| 1387 | parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1); |
| 1388 | if (parse < 0) |
| 1389 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStyleType", |
| 1390 | option,arg1); |
| 1391 | _draw_info->style=(StyleType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1392 | break; |
| 1393 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1394 | #if 0 |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1395 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 1396 | { |
| 1397 | /* FUTURE: this is only used by CompareImages() which is used |
| 1398 | only by the "compare" CLI program at this time. */ |
| 1399 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1400 | break; |
| 1401 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1402 | #endif |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1403 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1404 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1405 | /* FUTURE: syncronize to storage - but what does that mean? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1406 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1407 | break; |
| 1408 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1409 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1410 | } |
| 1411 | case 't': |
| 1412 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1413 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1414 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1415 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1416 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1417 | break; |
| 1418 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1419 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1420 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1421 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1422 | /* FUTURE: move _image_info string to option splay-tree |
| 1423 | Other than "montage" what uses "texture" ???? |
| 1424 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1425 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1426 | break; |
| 1427 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1428 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1429 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1430 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1431 | _draw_info->fill_pattern=IfSetOption |
| 1432 | ?GetImageCache(_image_info,arg1,_exception) |
| 1433 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1434 | break; |
| 1435 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1436 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1437 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1438 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1439 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1440 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1441 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1442 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1443 | break; |
| 1444 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1445 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1446 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1447 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1448 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1449 | SyncImageSettings() used to set per-image attribute. |
| 1450 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1451 | Note that +transparent-color, means fall-back to image |
| 1452 | attribute so ImageOption is deleted, not set to a default. |
| 1453 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1454 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1455 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1456 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1457 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1458 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1459 | break; |
| 1460 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1461 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1462 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1463 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1464 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1465 | break; |
| 1466 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1467 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1468 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1469 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1470 | parse=ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 1471 | ArgOption("undefined")); |
| 1472 | if (parse < 0) |
| 1473 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageType", |
| 1474 | option,arg1); |
| 1475 | _image_info->type=(ImageType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1476 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1477 | break; |
| 1478 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1479 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1480 | } |
| 1481 | case 'u': |
| 1482 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1483 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1484 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1485 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1486 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1487 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1488 | break; |
| 1489 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1490 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1491 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1492 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1493 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1494 | FUTURE: this probably should be part of the density setting |
| 1495 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1496 | parse=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
| 1497 | ArgOption("undefined")); |
| 1498 | if (parse < 0) |
| 1499 | CLIWandExceptArgBreak(OptionError,"UnrecognizedUnitsType", |
| 1500 | option,arg1); |
| 1501 | _image_info->units=(ResolutionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1502 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1503 | break; |
| 1504 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1505 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1506 | } |
| 1507 | case 'v': |
| 1508 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1509 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1510 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1511 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1512 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1513 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1514 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1515 | _image_info->verbose= ArgBoolean; |
| 1516 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1517 | break; |
| 1518 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1519 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1520 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1521 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1522 | Only used by coder FPX |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1523 | And it only tests existance, not its content! |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1524 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1525 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1526 | break; |
| 1527 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1528 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1529 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1530 | /* SyncImageSettings() used to set per-image attribute. |
| 1531 | This is VERY deep in the image caching structure. |
| 1532 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1533 | parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 1534 | ArgOption("undefined")); |
| 1535 | if (parse < 0) |
| 1536 | CLIWandExceptArgBreak(OptionError,"UnrecognizedVirtualPixelMethod", |
| 1537 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1538 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1539 | break; |
| 1540 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1541 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1542 | } |
| 1543 | case 'w': |
| 1544 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1545 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1546 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1547 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1548 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1549 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1550 | arg1=ArgOption("all"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1551 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1552 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1553 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1554 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1555 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1556 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1557 | if (_draw_info->weight <= 800) |
| 1558 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1559 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1560 | if (_draw_info->weight >= 100) |
| 1561 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1562 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1563 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1564 | break; |
| 1565 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1566 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1567 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1568 | /* Used as a image chromaticity setting |
| 1569 | SyncImageSettings() used to set per-image attribute. |
| 1570 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1571 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1572 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1573 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1574 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1575 | break; |
| 1576 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1577 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1578 | } |
| 1579 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1580 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1581 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1582 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1583 | #if 0 |
| 1584 | /* clean up percent escape interpreted strings */ |
| 1585 | if (arg1 != arg1n ) |
| 1586 | arg1=DestroyString((char *)arg1); |
| 1587 | if (arg2 != arg2n ) |
| 1588 | arg2=DestroyString((char *)arg2); |
| 1589 | #endif |
| 1590 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1591 | #undef _image_info |
| 1592 | #undef _exception |
| 1593 | #undef _draw_info |
| 1594 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1595 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1596 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1597 | #undef ArgBooleanNot |
| 1598 | #undef ArgBooleanString |
| 1599 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1600 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1601 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1602 | } |
| 1603 | |
| 1604 | /* |
| 1605 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1606 | % % |
| 1607 | % % |
| 1608 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1609 | + 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] | 1610 | % % |
| 1611 | % % |
| 1612 | % % |
| 1613 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1614 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1615 | % CLISimpleOperatorImages() applys one simple image operation given to all |
| 1616 | % the images in the CLI wand, using any per-image or global settings that was |
| 1617 | % previously saved in the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1618 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1619 | % It is assumed that any such settings are up-to-date. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1620 | % |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 1621 | % The format of the WandSimpleOperatorImages method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1622 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1623 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1624 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1625 | % |
| 1626 | % A description of each parameter follows: |
| 1627 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1628 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1629 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1630 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1631 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1632 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1633 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1634 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1635 | |
| 1636 | /* |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1637 | CLISimpleOperatorImage() is an Internal subrountine to apply one simple |
| 1638 | image operation to the current image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1639 | |
| 1640 | The image in the list may be modified in three different ways... |
| 1641 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1642 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1643 | * one image replace by a list of images (-separate and -crop only!) |
| 1644 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1645 | In each case the result replaces the single original image in the list, as |
| 1646 | well as the pointer to the modified image (last image added if replaced by a |
| 1647 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1648 | |
| 1649 | As the image pointed to may be replaced, the first image in the list may |
| 1650 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1651 | return the Image pointer to the first image in list. |
| 1652 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 1653 | static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1654 | const char *option, const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1655 | { |
| 1656 | Image * |
| 1657 | new_image; |
| 1658 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1659 | GeometryInfo |
| 1660 | geometry_info; |
| 1661 | |
| 1662 | RectangleInfo |
| 1663 | geometry; |
| 1664 | |
| 1665 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1666 | flags; |
| 1667 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1668 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1669 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1670 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1671 | const char /* For percent escape interpretImageProperties() */ |
| 1672 | *arg1, |
| 1673 | *arg2; |
| 1674 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 1675 | #define _image_info (cli_wand->wand.image_info) |
| 1676 | #define _image (cli_wand->wand.images) |
| 1677 | #define _exception (cli_wand->wand.exception) |
| 1678 | #define _draw_info (cli_wand->draw_info) |
| 1679 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1680 | #define _process_flags (cli_wand->process_flags) |
| 1681 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1682 | #define IfNormalOp (*option=='-') |
| 1683 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1684 | #define normal_op IsMagickTrue(IfNormalOp) |
| 1685 | #define plus_alt_op IsMagickFalse(IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1686 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1687 | assert(cli_wand != (MagickCLI *) NULL); |
| 1688 | assert(cli_wand->signature == WandSignature); |
| 1689 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1690 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1691 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1692 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1693 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1694 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 1695 | arg1 = arg1n, |
| 1696 | arg2 = arg2n; |
| 1697 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 1698 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 1699 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 1700 | /* Interpret Percent escapes in argument 1 */ |
| 1701 | if (arg1n != (char *) NULL) { |
| 1702 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 1703 | if (arg1 == (char *) NULL) { |
| 1704 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1705 | arg1=arg1n; /* use the given argument as is */ |
| 1706 | } |
| 1707 | } |
| 1708 | if (arg2n != (char *) NULL) { |
| 1709 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 1710 | if (arg2 == (char *) NULL) { |
| 1711 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1712 | arg2=arg2n; /* use the given argument as is */ |
| 1713 | } |
| 1714 | } |
| 1715 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1716 | #undef _process_flags |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1717 | #undef _option_type |
| 1718 | |
| 1719 | #if 0 |
| 1720 | (void) FormatLocaleFile(stderr, |
| 1721 | "CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); |
| 1722 | #endif |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1723 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1724 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1725 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1726 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1727 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1728 | { |
| 1729 | case 'a': |
| 1730 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1731 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1732 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1733 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1734 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1735 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1736 | if ((flags & SigmaValue) == 0) |
| 1737 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1738 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1739 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1740 | break; |
| 1741 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1742 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1743 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1744 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1745 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1746 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1747 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1748 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1749 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1750 | break; |
| 1751 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1752 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1753 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1754 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1755 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1756 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1757 | if ((flags & SigmaValue) == 0) |
| 1758 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1759 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1760 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1761 | break; |
| 1762 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1763 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1764 | { |
cristy | 288a353 | 2012-08-28 00:19:44 +0000 | [diff] [blame] | 1765 | parse=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1766 | if (parse < 0) |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 1767 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelOption", |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1768 | option,arg1); |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 1769 | (void) SetImageAlphaChannel(_image,(AlphaChannelOption)parse, |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1770 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1771 | break; |
| 1772 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1773 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1774 | { |
| 1775 | char |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1776 | geometry[MaxTextExtent]; |
| 1777 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1778 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1779 | flags=ParseGeometry(arg1,&geometry_info); |
cristy | 8592b05 | 2013-02-07 01:24:54 +0000 | [diff] [blame] | 1780 | if (flags == 0) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1781 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1782 | if ((flags & SigmaValue) == 0) |
| 1783 | geometry_info.sigma=geometry_info.rho; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1784 | (void) CloneString(&_draw_info->text,arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1785 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1786 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1787 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1788 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1789 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1790 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1791 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1792 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1793 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1794 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1795 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1796 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1797 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1798 | break; |
| 1799 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1800 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1801 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1802 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1803 | break; |
| 1804 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1805 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1806 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1807 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1808 | break; |
| 1809 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1810 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1811 | { |
cristy | fa5f6c7 | 2013-01-01 14:37:35 +0000 | [diff] [blame] | 1812 | new_image=AutoOrientImage(_image,_image->orientation,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1813 | break; |
| 1814 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1815 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1816 | } |
| 1817 | case 'b': |
| 1818 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1819 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1820 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1821 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1822 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1823 | (void) BlackThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1824 | break; |
| 1825 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1826 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1827 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1828 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1829 | if (IfNormalOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1830 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1831 | if ((flags & RhoValue) == 0) |
| 1832 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1833 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1834 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1835 | break; |
| 1836 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1837 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1838 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1839 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1840 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1841 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1842 | if ((flags & SigmaValue) == 0) |
| 1843 | geometry_info.sigma=1.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1844 | new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1845 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1846 | break; |
| 1847 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1848 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1849 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1850 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1851 | compose; |
| 1852 | |
| 1853 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1854 | value; |
| 1855 | |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1856 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1857 | if ((flags & (WidthValue | HeightValue)) == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1858 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1859 | compose=OverCompositeOp; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1860 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1861 | if (value != (const char *) NULL) |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1862 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1863 | MagickFalse,value); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1864 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1865 | break; |
| 1866 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1867 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1868 | { |
| 1869 | double |
| 1870 | brightness, |
| 1871 | contrast; |
| 1872 | |
| 1873 | GeometryInfo |
| 1874 | geometry_info; |
| 1875 | |
| 1876 | MagickStatusType |
| 1877 | flags; |
| 1878 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1879 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1880 | if ((flags & RhoValue) == 0) |
| 1881 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1882 | brightness=geometry_info.rho; |
| 1883 | contrast=0.0; |
| 1884 | if ((flags & SigmaValue) != 0) |
| 1885 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1886 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1887 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1888 | break; |
| 1889 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1890 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1891 | } |
| 1892 | case 'c': |
| 1893 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1894 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1895 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1896 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1897 | char |
| 1898 | *color_correction_collection; |
| 1899 | |
| 1900 | /* |
| 1901 | Color correct with a color decision list. |
| 1902 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1903 | color_correction_collection=FileToString(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1904 | if (color_correction_collection == (char *) NULL) |
| 1905 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1906 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 1907 | _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("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1911 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1912 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1913 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1914 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1915 | if ((flags & SigmaValue) == 0) |
| 1916 | geometry_info.sigma=1.0; |
| 1917 | if ((flags & XiValue) == 0) |
| 1918 | geometry_info.xi=1.0; |
cristy | ee3f752 | 2012-12-21 19:27:44 +0000 | [diff] [blame] | 1919 | new_image=CharcoalImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1920 | _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("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1924 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1925 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1926 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1927 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 1928 | new_image=ChopImage(_image,&geometry,_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("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1932 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1933 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1934 | break; |
| 1935 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1936 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1937 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1938 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1939 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1940 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1941 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1942 | break; |
| 1943 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1944 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1945 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1946 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1947 | CacheView |
| 1948 | *mask_view; |
| 1949 | |
| 1950 | Image |
| 1951 | *mask_image; |
| 1952 | |
| 1953 | register Quantum |
| 1954 | *restrict q; |
| 1955 | |
| 1956 | register ssize_t |
| 1957 | x; |
| 1958 | |
| 1959 | ssize_t |
| 1960 | y; |
| 1961 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1962 | if (IfPlusOp) { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1963 | /* use "+clip-mask" Remove the write mask for -clip-path */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1964 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1965 | break; |
| 1966 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1967 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1968 | if (mask_image == (Image *) NULL) |
| 1969 | break; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1970 | if (IfMagickFalse(SetImageStorageClass(mask_image,DirectClass,_exception))) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1971 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1972 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1973 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
cristy | 46ff267 | 2012-12-14 15:32:26 +0000 | [diff] [blame] | 1974 | mask_view=AcquireAuthenticCacheView(mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1975 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1976 | { |
| 1977 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1978 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1979 | if (q == (Quantum *) NULL) |
| 1980 | break; |
| 1981 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1982 | { |
cristy | dc2d327 | 2013-02-12 14:00:44 +0000 | [diff] [blame] | 1983 | if (mask_image->alpha_trait != BlendPixelTrait) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1984 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1985 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1986 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1987 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1988 | q+=GetPixelChannels(mask_image); |
| 1989 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1990 | if (IfMagickFalse(SyncCacheViewAuthenticPixels(mask_view,_exception))) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1991 | break; |
| 1992 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1993 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1994 | mask_view=DestroyCacheView(mask_view); |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 1995 | mask_image->alpha_trait=BlendPixelTrait; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1996 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1997 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1998 | break; |
| 1999 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2000 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2001 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2002 | (void) ClipImagePath(_image,arg1,normal_op,_exception); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2003 | /* Note: Use "+clip-mask" remove the write mask added */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2004 | break; |
| 2005 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2006 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2007 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2008 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2009 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2010 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2011 | break; |
| 2012 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2013 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2014 | { |
| 2015 | KernelInfo |
| 2016 | *kernel; |
| 2017 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2018 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2019 | if (kernel == (KernelInfo *) NULL) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2020 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2021 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2022 | kernel=DestroyKernelInfo(kernel); |
| 2023 | break; |
| 2024 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2025 | if (LocaleCompare("colors",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 | /* Reduce the number of colors in the image. |
| 2028 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2029 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2030 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2031 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2032 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2033 | if ((_image->storage_class == DirectClass) || |
| 2034 | _image->colors > _quantize_info->number_colors) |
| 2035 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2036 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2037 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2038 | break; |
| 2039 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2040 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2041 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2042 | /* WARNING: this is both a image_info setting (already done) |
| 2043 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2044 | |
| 2045 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2046 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2047 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2048 | Note that +colorspace sets "undefined" or no effect on |
| 2049 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2050 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2051 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2052 | (void) TransformImageColorspace(_image, |
| 2053 | IfNormalOp ? _image_info->colorspace : RGBColorspace, |
| 2054 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2055 | break; |
| 2056 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2057 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2058 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2059 | CLIWandWarnReplaced(normal_op?"-level":"+level"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2060 | (void) ContrastImage(_image,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2061 | break; |
| 2062 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2063 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2064 | { |
| 2065 | double |
| 2066 | black_point, |
| 2067 | white_point; |
| 2068 | |
| 2069 | MagickStatusType |
| 2070 | flags; |
| 2071 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2072 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2073 | if ((flags & RhoValue) == 0) |
| 2074 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2075 | black_point=geometry_info.rho; |
| 2076 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2077 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2078 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2079 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2080 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2081 | } |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2082 | white_point=(double) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2083 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2084 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2085 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2086 | break; |
| 2087 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2088 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2089 | { |
| 2090 | KernelInfo |
| 2091 | *kernel_info; |
| 2092 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2093 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2094 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2095 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | a12d8ba | 2012-04-29 16:33:41 +0000 | [diff] [blame] | 2096 | new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info, |
| 2097 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2098 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2099 | break; |
| 2100 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2101 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2102 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2103 | /* WARNING: This can generate multiple images! */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2104 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2105 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2106 | new_image=CropImageToTiles(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2107 | break; |
| 2108 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2109 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2110 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2111 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2112 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2113 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2114 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2115 | break; |
| 2116 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2117 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2118 | } |
| 2119 | case 'd': |
| 2120 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2121 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2122 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2123 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2124 | StringInfo |
| 2125 | *passkey; |
| 2126 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2127 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2128 | if (passkey == (StringInfo *) NULL) |
| 2129 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2130 | |
| 2131 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2132 | passkey=DestroyStringInfo(passkey); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2133 | break; |
| 2134 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2135 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2136 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2137 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2138 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2139 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2140 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2141 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2142 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2143 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2144 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2145 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2146 | break; |
| 2147 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2148 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2149 | { |
| 2150 | double |
| 2151 | threshold; |
| 2152 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2153 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2154 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2155 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2156 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2157 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2158 | else |
| 2159 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2160 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2161 | break; |
| 2162 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2163 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2164 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2165 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2166 | break; |
| 2167 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2168 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2169 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2170 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2171 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2172 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2173 | ssize_t |
| 2174 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2175 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2176 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2177 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2178 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2179 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2180 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2181 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2182 | double |
| 2183 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2184 | /* Special Case - Argument is actually a resize geometry! |
| 2185 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2186 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2187 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2188 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2189 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2190 | option,arg2); |
| 2191 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2192 | resize_args[0]=(double) geometry.width; |
| 2193 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2194 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2195 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2196 | break; |
| 2197 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2198 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2199 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2200 | if (args == (double *)NULL ) |
| 2201 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2202 | |
| 2203 | new_image=DistortImage(_image,(DistortImageMethod) parse,count,args, |
| 2204 | plus_alt_op,_exception); |
| 2205 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2206 | break; |
| 2207 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2208 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2209 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2210 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2211 | (void) DrawImage(_image,_draw_info,_exception); |
| 2212 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2213 | break; |
| 2214 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2215 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2216 | } |
| 2217 | case 'e': |
| 2218 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2219 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2220 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2221 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2222 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2223 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2224 | if ((flags & SigmaValue) == 0) |
| 2225 | geometry_info.sigma=1.0; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2226 | new_image=EdgeImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2227 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2228 | break; |
| 2229 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2230 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2231 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2232 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2233 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2234 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2235 | if ((flags & SigmaValue) == 0) |
| 2236 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2237 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2238 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2239 | break; |
| 2240 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2241 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2242 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2243 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2244 | StringInfo |
| 2245 | *passkey; |
| 2246 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2247 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2248 | if (passkey != (StringInfo *) NULL) |
| 2249 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2250 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2251 | passkey=DestroyStringInfo(passkey); |
| 2252 | } |
| 2253 | break; |
| 2254 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2255 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2256 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2257 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2258 | break; |
| 2259 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2260 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2261 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2262 | (void) EqualizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2263 | break; |
| 2264 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2265 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2266 | { |
| 2267 | double |
| 2268 | constant; |
| 2269 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2270 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2271 | if ( parse < 0 ) |
| 2272 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2273 | option,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2274 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2275 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2276 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2277 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2278 | _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("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2282 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2283 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2284 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2285 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2286 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2287 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2288 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2289 | geometry.height=_image->rows; |
| 2290 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2291 | break; |
| 2292 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2293 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2294 | } |
| 2295 | case 'f': |
| 2296 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2297 | if (LocaleCompare("features",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2298 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2299 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2300 | if (IfPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2301 | (void) DeleteImageArtifact(_image,"identify:features"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2302 | break; |
| 2303 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2304 | (void) SetImageArtifact(_image,"identify:features","true"); |
| 2305 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2306 | break; |
| 2307 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2308 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2309 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2310 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2311 | break; |
| 2312 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2313 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2314 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2315 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2316 | break; |
| 2317 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2318 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2319 | { |
| 2320 | PixelInfo |
| 2321 | target; |
| 2322 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2323 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2324 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2325 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2326 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2327 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
cristy | 4b89261 | 2012-08-03 19:31:31 +0000 | [diff] [blame] | 2328 | geometry.y,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2329 | break; |
| 2330 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2331 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2332 | { |
| 2333 | FrameInfo |
| 2334 | frame_info; |
| 2335 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2336 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2337 | compose; |
| 2338 | |
| 2339 | const char* |
| 2340 | value; |
| 2341 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2342 | value=GetImageOption(_image_info,"compose"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2343 | compose=OverCompositeOp; /* use Over not _image->compose */ |
cristy | 4b89261 | 2012-08-03 19:31:31 +0000 | [diff] [blame] | 2344 | if (value != (const char *) NULL) |
| 2345 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 2346 | MagickFalse,value); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2347 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2348 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2349 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2350 | frame_info.width=geometry.width; |
| 2351 | frame_info.height=geometry.height; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2352 | frame_info.outer_bevel=geometry.x; |
| 2353 | frame_info.inner_bevel=geometry.y; |
| 2354 | frame_info.x=(ssize_t) frame_info.width; |
| 2355 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2356 | frame_info.width=_image->columns+2*frame_info.width; |
| 2357 | frame_info.height=_image->rows+2*frame_info.height; |
| 2358 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2359 | break; |
| 2360 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2361 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2362 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2363 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2364 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2365 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2366 | ssize_t |
| 2367 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2368 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2369 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2370 | if ( parse < 0 ) |
| 2371 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2372 | option,arg1); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2373 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2374 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2375 | if (args == (double *)NULL ) |
| 2376 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2377 | |
| 2378 | (void) FunctionImage(_image,(MagickFunction)parse,count,args, |
| 2379 | _exception); |
| 2380 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2381 | break; |
| 2382 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2383 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2384 | } |
| 2385 | case 'g': |
| 2386 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2387 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2388 | { |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2389 | double |
| 2390 | constant; |
| 2391 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2392 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2393 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2394 | constant=StringToDouble(arg1,(char **) NULL); |
| 2395 | #if 0 |
| 2396 | /* Using Gamma, via a cache */ |
| 2397 | if (IfPlusOp) |
cristy | 3e3ec3a | 2012-11-03 23:11:06 +0000 | [diff] [blame] | 2398 | constant=PerceptibleReciprocal(constant); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2399 | (void) GammaImage(_image,constant,_exception); |
| 2400 | #else |
| 2401 | /* Using Evaluate POW, direct update of values - more accurite */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2402 | if (IfNormalOp) |
cristy | 3e3ec3a | 2012-11-03 23:11:06 +0000 | [diff] [blame] | 2403 | constant=PerceptibleReciprocal(constant); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2404 | (void) EvaluateImage(_image,PowEvaluateOperator,constant,_exception); |
| 2405 | #endif |
| 2406 | /* Set gamma setting -- Old meaning of "+gamma" |
| 2407 | * _image->gamma=StringToDouble(arg1,(char **) NULL); |
| 2408 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2409 | break; |
| 2410 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2411 | if (LocaleCompare("gaussian-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2412 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2413 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2414 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2415 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2416 | if ((flags & SigmaValue) == 0) |
| 2417 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2418 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2419 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2420 | break; |
| 2421 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2422 | if (LocaleCompare("gaussian",option+1) == 0) |
| 2423 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2424 | CLIWandWarnReplaced("-gaussian-blur"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2425 | CLISimpleOperatorImage(cli_wand,"-gaussian-blur",arg1,NULL); |
| 2426 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2427 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2428 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2429 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2430 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2431 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2432 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2433 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2434 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2435 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2436 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2437 | if (_image->geometry != (char *) NULL) |
| 2438 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2439 | break; |
| 2440 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2441 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2442 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2443 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2444 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2445 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2446 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2447 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2448 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2449 | break; |
| 2450 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2451 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2452 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2453 | case 'i': |
| 2454 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2455 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2456 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2457 | const char |
| 2458 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2459 | *text; |
| 2460 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2461 | format=GetImageOption(_image_info,"format"); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2462 | if (format == (char *) NULL) { |
| 2463 | (void) IdentifyImage(_image,stdout,_image_info->verbose,_exception); |
| 2464 | break; |
| 2465 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2466 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2467 | if (text == (char *) NULL) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2468 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 2469 | option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2470 | (void) fputs(text,stdout); |
| 2471 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2472 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2473 | break; |
| 2474 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2475 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2476 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2477 | flags=ParseGeometry(arg1,&geometry_info); |
| 2478 | if ((flags & RhoValue) == 0) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2479 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2480 | new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate, |
| 2481 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2482 | break; |
| 2483 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2484 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2485 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2486 | /* FUTURE: New to IMv7 |
| 2487 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2488 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2489 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2490 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2491 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2492 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2493 | break; |
| 2494 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2495 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2496 | } |
| 2497 | case 'l': |
| 2498 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2499 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2500 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2501 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2502 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2503 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | b5c691e | 2012-09-14 17:12:40 +0000 | [diff] [blame] | 2504 | if ((flags & SigmaValue) == 0) |
| 2505 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2506 | if ((flags & PercentValue) != 0) |
| 2507 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2508 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2509 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2510 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2511 | break; |
| 2512 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2513 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2514 | { |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2515 | double |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2516 | black_point, |
| 2517 | gamma, |
| 2518 | white_point; |
| 2519 | |
| 2520 | MagickStatusType |
| 2521 | flags; |
| 2522 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2523 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2524 | if ((flags & RhoValue) == 0) |
| 2525 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2526 | black_point=geometry_info.rho; |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2527 | white_point=(double) QuantumRange; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2528 | if ((flags & SigmaValue) != 0) |
| 2529 | white_point=geometry_info.sigma; |
| 2530 | gamma=1.0; |
| 2531 | if ((flags & XiValue) != 0) |
| 2532 | gamma=geometry_info.xi; |
| 2533 | if ((flags & PercentValue) != 0) |
| 2534 | { |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2535 | black_point*=(double) (QuantumRange/100.0); |
| 2536 | white_point*=(double) (QuantumRange/100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2537 | } |
| 2538 | if ((flags & SigmaValue) == 0) |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2539 | white_point=(double) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2540 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2541 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2542 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2543 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2544 | break; |
| 2545 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2546 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2547 | { |
| 2548 | char |
| 2549 | token[MaxTextExtent]; |
| 2550 | |
| 2551 | const char |
| 2552 | *p; |
| 2553 | |
| 2554 | PixelInfo |
| 2555 | black_point, |
| 2556 | white_point; |
| 2557 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2558 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2559 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2560 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2561 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2562 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2563 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2564 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2565 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2566 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2567 | GetMagickToken(p,&p,token); |
| 2568 | if (*token == '\0') |
| 2569 | white_point=black_point; /* set everything to that color */ |
| 2570 | else |
| 2571 | { |
| 2572 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2573 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2574 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2575 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2576 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2577 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2578 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2579 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2580 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2581 | (void) LevelImageColors(_image,&black_point,&white_point, |
| 2582 | plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2583 | break; |
| 2584 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2585 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2586 | { |
| 2587 | double |
| 2588 | black_point, |
| 2589 | white_point; |
| 2590 | |
| 2591 | MagickStatusType |
| 2592 | flags; |
| 2593 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2594 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2595 | if ((flags & RhoValue) == 0) |
| 2596 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2597 | black_point=geometry_info.rho; |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2598 | white_point=(double) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2599 | if ((flags & SigmaValue) != 0) |
| 2600 | white_point=geometry_info.sigma; |
| 2601 | if ((flags & PercentValue) != 0) |
| 2602 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2603 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2604 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2605 | } |
| 2606 | if ((flags & SigmaValue) == 0) |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2607 | white_point=(double) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2608 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2609 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2610 | break; |
| 2611 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2612 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2613 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2614 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2615 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2616 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2617 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2618 | if ((flags & XValue) == 0) |
| 2619 | geometry.x=1; |
| 2620 | if ((flags & YValue) == 0) |
| 2621 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2622 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2623 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2624 | break; |
| 2625 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2626 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2627 | } |
| 2628 | case 'm': |
| 2629 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2630 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2631 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2632 | CLIWandWarnReplaced("-remap"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2633 | CLISimpleOperatorImage(cli_wand,"-remap",NULL,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2634 | break; |
| 2635 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2636 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2637 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2638 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2639 | Image |
| 2640 | *mask; |
| 2641 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2642 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2643 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2644 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2645 | break; |
| 2646 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2647 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2648 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2649 | if (mask == (Image *) NULL) |
| 2650 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2651 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2652 | mask=DestroyImage(mask); |
| 2653 | break; |
| 2654 | } |
cristy | 52ad9e9 | 2013-02-08 23:23:29 +0000 | [diff] [blame] | 2655 | if (LocaleCompare("matte",option+1) == 0) |
| 2656 | { |
| 2657 | CLIWandWarnReplaced(IfNormalOp?"-alpha Set":"-alpha Off"); |
| 2658 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2659 | DeactivateAlphaChannel, _exception); |
| 2660 | break; |
| 2661 | } |
| 2662 | if (LocaleCompare("median",option+1) == 0) |
| 2663 | { |
| 2664 | CLIWandWarnReplaced("-statistic Median"); |
| 2665 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2666 | break; |
| 2667 | } |
| 2668 | if (LocaleCompare("mode",option+1) == 0) |
| 2669 | { |
| 2670 | /* FUTURE: note this is also a special "montage" option */ |
| 2671 | CLIWandWarnReplaced("-statistic Mode"); |
| 2672 | CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1); |
| 2673 | break; |
| 2674 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2675 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2676 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2677 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2678 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2679 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2680 | break; |
| 2681 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2682 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2683 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2684 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2685 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2686 | break; |
| 2687 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2688 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2689 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2690 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2691 | break; |
| 2692 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2693 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2694 | { |
| 2695 | char |
| 2696 | token[MaxTextExtent]; |
| 2697 | |
| 2698 | const char |
| 2699 | *p; |
| 2700 | |
| 2701 | KernelInfo |
| 2702 | *kernel; |
| 2703 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2704 | ssize_t |
| 2705 | iterations; |
| 2706 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2707 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2708 | GetMagickToken(p,&p,token); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2709 | parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
| 2710 | if ( parse < 0 ) |
| 2711 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2712 | option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2713 | iterations=1L; |
| 2714 | GetMagickToken(p,&p,token); |
| 2715 | if ((*p == ':') || (*p == ',')) |
| 2716 | GetMagickToken(p,&p,token); |
| 2717 | if ((*p != '\0')) |
| 2718 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2719 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2720 | if (kernel == (KernelInfo *) NULL) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2721 | CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel", |
| 2722 | option,arg2); |
| 2723 | new_image=MorphologyImage(_image,(MorphologyMethod)parse, |
| 2724 | iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2725 | kernel=DestroyKernelInfo(kernel); |
| 2726 | break; |
| 2727 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2728 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2729 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2730 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2731 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2732 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2733 | if ((flags & SigmaValue) == 0) |
| 2734 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2735 | new_image=MotionBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2736 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2737 | break; |
| 2738 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2739 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2740 | } |
| 2741 | case 'n': |
| 2742 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2743 | if (LocaleCompare("negate",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) NegateImage(_image, plus_alt_op, _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("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2749 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2750 | double |
| 2751 | attenuate; |
| 2752 | |
| 2753 | const char* |
| 2754 | value; |
| 2755 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2756 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2757 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2758 | CLIWandWarnReplaced("-statistic NonPeak"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2759 | CLISimpleOperatorImage(cli_wand,"-statistic","NonPeak",arg1); |
| 2760 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2761 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2762 | parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1); |
| 2763 | if ( parse < 0 ) |
| 2764 | CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType", |
| 2765 | option,arg1); |
| 2766 | attenuate=1.0; |
| 2767 | value=GetImageOption(_image_info,"attenuate"); |
| 2768 | if (value != (const char *) NULL) |
| 2769 | attenuate=StringToDouble(value,(char **) NULL); |
| 2770 | new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate, |
| 2771 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2772 | break; |
| 2773 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2774 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2775 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2776 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2777 | break; |
| 2778 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2779 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2780 | } |
| 2781 | case 'o': |
| 2782 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2783 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2784 | { |
| 2785 | PixelInfo |
| 2786 | target; |
| 2787 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2788 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 2789 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,plus_alt_op, |
| 2790 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2791 | break; |
| 2792 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2793 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2794 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2795 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2796 | break; |
| 2797 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2798 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2799 | } |
| 2800 | case 'p': |
| 2801 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2802 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2803 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2804 | flags=ParseGeometry(arg1,&geometry_info); |
| 2805 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2806 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2807 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2808 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2809 | break; |
| 2810 | } |
cristy | 7884a93 | 2012-11-04 14:33:51 +0000 | [diff] [blame] | 2811 | if (LocaleCompare("perceptible",option+1) == 0) |
| 2812 | { |
| 2813 | (void) PerceptibleImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2814 | _exception); |
| 2815 | break; |
| 2816 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2817 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2818 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2819 | const char |
| 2820 | *caption; |
| 2821 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2822 | double |
| 2823 | angle; |
| 2824 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2825 | if (IfPlusOp) { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2826 | RandomInfo |
| 2827 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2828 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2829 | random_info=AcquireRandomInfo(); |
| 2830 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2831 | random_info=DestroyRandomInfo(random_info); |
| 2832 | } |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2833 | else { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2834 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2835 | if ((flags & RhoValue) == 0) |
| 2836 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2837 | angle=geometry_info.rho; |
| 2838 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2839 | caption=GetImageProperty(_image,"caption",_exception); |
| 2840 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 2841 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2842 | break; |
| 2843 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2844 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2845 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2846 | flags=ParseGeometry(arg1,&geometry_info); |
| 2847 | if ((flags & RhoValue) == 0) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2848 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2849 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 2850 | _quantize_info->dither_method,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2851 | break; |
| 2852 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2853 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2854 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2855 | /* FUTURE: should be a 'Genesis' option? |
| 2856 | Option however is also in WandSettingOptionInfo() |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2857 | Why??? |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2858 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2859 | parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1); |
| 2860 | if ( parse < 0 ) |
| 2861 | CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType", |
| 2862 | option,arg1); |
| 2863 | new_image=PreviewImage(_image,(PreviewType)parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2864 | break; |
| 2865 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2866 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2867 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2868 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2869 | const char |
| 2870 | *name; |
| 2871 | |
| 2872 | const StringInfo |
| 2873 | *profile; |
| 2874 | |
| 2875 | Image |
| 2876 | *profile_image; |
| 2877 | |
| 2878 | ImageInfo |
| 2879 | *profile_info; |
| 2880 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2881 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2882 | { /* Remove a profile from the _image. */ |
| 2883 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 2884 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2885 | break; |
| 2886 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2887 | /* Associate a profile with the _image. */ |
| 2888 | profile_info=CloneImageInfo(_image_info); |
| 2889 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2890 | if (profile != (StringInfo *) NULL) |
| 2891 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2892 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2893 | profile_info=DestroyImageInfo(profile_info); |
| 2894 | if (profile_image == (Image *) NULL) |
| 2895 | { |
| 2896 | StringInfo |
| 2897 | *profile; |
| 2898 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2899 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2900 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2901 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2902 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2903 | if (profile != (StringInfo *) NULL) |
| 2904 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2905 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2906 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2907 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2908 | profile=DestroyStringInfo(profile); |
| 2909 | } |
| 2910 | profile_info=DestroyImageInfo(profile_info); |
| 2911 | break; |
| 2912 | } |
| 2913 | ResetImageProfileIterator(profile_image); |
| 2914 | name=GetNextImageProfile(profile_image); |
| 2915 | while (name != (const char *) NULL) |
| 2916 | { |
| 2917 | profile=GetImageProfile(profile_image,name); |
| 2918 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2919 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 2920 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2921 | name=GetNextImageProfile(profile_image); |
| 2922 | } |
| 2923 | profile_image=DestroyImage(profile_image); |
| 2924 | break; |
| 2925 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2926 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2927 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2928 | case 'r': |
| 2929 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2930 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2931 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2932 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2933 | if ((flags & RhoValue) == 0) |
| 2934 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2935 | new_image=RadialBlurImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2936 | break; |
| 2937 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2938 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2939 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2940 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2941 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2942 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2943 | (void) RaiseImage(_image,&geometry,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2944 | break; |
| 2945 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2946 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2947 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2948 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2949 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2950 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2951 | break; |
| 2952 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2953 | if (LocaleCompare("recolor",option+1) == 0) |
| 2954 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2955 | CLIWandWarnReplaced("-color-matrix"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2956 | CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL); |
| 2957 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2958 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2959 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2960 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2961 | Image |
| 2962 | *remap_image; |
| 2963 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2964 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2965 | if (remap_image == (Image *) NULL) |
| 2966 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2967 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2968 | remap_image=DestroyImage(remap_image); |
| 2969 | break; |
| 2970 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2971 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2972 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2973 | if (IfNormalOp) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2974 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2975 | if (IfMagickFalse(IsGeometry(arg1))) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2976 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 2977 | arg1); |
| 2978 | (void) ResetImagePage(_image,arg1); |
| 2979 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2980 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2981 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
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("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2985 | { |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 2986 | /* FUTURE: Roll into a resize special operation */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2987 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2988 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2989 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2990 | if ((flags & SigmaValue) == 0) |
| 2991 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2992 | new_image=ResampleImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2993 | geometry_info.sigma,_image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2994 | break; |
| 2995 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2996 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2997 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2998 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2999 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3000 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3001 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3002 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3003 | break; |
| 3004 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3005 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3006 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3007 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3008 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3009 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3010 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3011 | break; |
| 3012 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3013 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3014 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3015 | flags=ParseGeometry(arg1,&geometry_info); |
| 3016 | if ((flags & RhoValue) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3017 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | ad255a0 | 2012-04-19 15:02:01 +0000 | [diff] [blame] | 3018 | if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows)) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3019 | break; |
| 3020 | if ((flags & LessValue) != 0 && (_image->columns >= _image->rows)) |
| 3021 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3022 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3023 | break; |
| 3024 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3025 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3026 | } |
| 3027 | case 's': |
| 3028 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3029 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3030 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3031 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3032 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3033 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3034 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3035 | new_image=SampleImage(_image,geometry.width,geometry.height, |
| 3036 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3037 | break; |
| 3038 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3039 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3040 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3041 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3042 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3043 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3044 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3045 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3046 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3047 | break; |
| 3048 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3049 | if (LocaleCompare("segment",option+1) == 0) |
| 3050 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3051 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3052 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3053 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3054 | if ((flags & SigmaValue) == 0) |
| 3055 | geometry_info.sigma=1.0; |
| 3056 | (void) SegmentImage(_image,_image->colorspace, |
| 3057 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3058 | _exception); |
| 3059 | break; |
| 3060 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3061 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3062 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3063 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3064 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3065 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3066 | if ((flags & SigmaValue) == 0) |
| 3067 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3068 | if ((flags & PercentValue) != 0) |
| 3069 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3070 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3071 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3072 | break; |
| 3073 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3074 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3075 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3076 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3077 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3078 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3079 | break; |
| 3080 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3081 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3082 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3083 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3084 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3085 | new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1, |
| 3086 | (double) QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3087 | break; |
| 3088 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3089 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3090 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3091 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3092 | if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0)) |
| 3093 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3094 | new_image=ShadeImage(_image,normal_op,geometry_info.rho, |
| 3095 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3096 | break; |
| 3097 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3098 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3099 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3100 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3101 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3102 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3103 | if ((flags & SigmaValue) == 0) |
| 3104 | geometry_info.sigma=1.0; |
| 3105 | if ((flags & XiValue) == 0) |
| 3106 | geometry_info.xi=4.0; |
| 3107 | if ((flags & PsiValue) == 0) |
| 3108 | geometry_info.psi=4.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3109 | new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3110 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3111 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3112 | break; |
| 3113 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3114 | if (LocaleCompare("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3115 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3116 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3117 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3118 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3119 | if ((flags & SigmaValue) == 0) |
| 3120 | geometry_info.sigma=1.0; |
| 3121 | if ((flags & XiValue) == 0) |
| 3122 | geometry_info.xi=0.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3123 | new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3124 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3125 | break; |
| 3126 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3127 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3128 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3129 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3130 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3131 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3132 | new_image=ShaveImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3133 | break; |
| 3134 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3135 | if (LocaleCompare("shear",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3136 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3137 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3138 | if ((flags & RhoValue) == 0) |
| 3139 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3140 | if ((flags & SigmaValue) == 0) |
| 3141 | geometry_info.sigma=geometry_info.rho; |
cristy | 4b89261 | 2012-08-03 19:31:31 +0000 | [diff] [blame] | 3142 | new_image=ShearImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3143 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3144 | break; |
| 3145 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3146 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3147 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3148 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3149 | if ((flags & RhoValue) == 0) |
| 3150 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3151 | if ((flags & SigmaValue) == 0) |
| 3152 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3153 | if ((flags & PercentValue) != 0) |
| 3154 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3155 | 100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3156 | (void) SigmoidalContrastImage(_image,normal_op,geometry_info.rho, |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 3157 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3158 | break; |
| 3159 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3160 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3161 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3162 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3163 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3164 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3165 | if ((flags & SigmaValue) == 0) |
| 3166 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3167 | new_image=SketchImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3168 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3169 | break; |
| 3170 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3171 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3172 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3173 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3174 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3175 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3176 | QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3177 | break; |
| 3178 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3179 | if (LocaleCompare("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3180 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3181 | parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1); |
| 3182 | if ( parse < 0 ) |
| 3183 | CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod", |
| 3184 | option,arg1); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3185 | new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2, |
| 3186 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3187 | break; |
| 3188 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3189 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3190 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3191 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3192 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3193 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3194 | new_image=SpliceImage(_image,&geometry,_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("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3198 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3199 | flags=ParseGeometry(arg1,&geometry_info); |
| 3200 | if ((flags & RhoValue) == 0) |
| 3201 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3202 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3203 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3204 | break; |
| 3205 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3206 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3207 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3208 | parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1); |
| 3209 | if ( parse < 0 ) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3210 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStatisticType", |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3211 | option,arg1); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3212 | flags=ParseGeometry(arg2,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3213 | if ((flags & RhoValue) == 0) |
| 3214 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3215 | if ((flags & SigmaValue) == 0) |
| 3216 | geometry_info.sigma=geometry_info.rho; |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3217 | new_image=StatisticImage(_image,(StatisticType)parse, |
| 3218 | (size_t) geometry_info.rho,(size_t) geometry_info.sigma, |
| 3219 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3220 | break; |
| 3221 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3222 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3223 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3224 | (void) StripImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3225 | break; |
| 3226 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3227 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3228 | { |
cristy | 898c604 | 2012-06-24 00:36:34 +0000 | [diff] [blame] | 3229 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3230 | if ((flags & RhoValue) == 0) |
cristy | 898c604 | 2012-06-24 00:36:34 +0000 | [diff] [blame] | 3231 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3232 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3233 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3234 | break; |
| 3235 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3236 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3237 | } |
| 3238 | case 't': |
| 3239 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3240 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3241 | { |
| 3242 | double |
| 3243 | threshold; |
| 3244 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3245 | threshold=(double) QuantumRange/2; |
| 3246 | if (normal_op) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3247 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3248 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3249 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3250 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3251 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3252 | break; |
| 3253 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3254 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3255 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3256 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3257 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3258 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3259 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3260 | _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("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3264 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3265 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3266 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3267 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3268 | break; |
| 3269 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3270 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3271 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3272 | CLIWandWarnReplaced("+distort AffineProjection"); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3273 | new_image=AffineTransformImage(_image,&_draw_info->affine,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3274 | break; |
| 3275 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3276 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3277 | { |
| 3278 | PixelInfo |
| 3279 | target; |
| 3280 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3281 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3282 | (void) TransparentPaintImage(_image,&target,(Quantum) |
| 3283 | TransparentAlpha,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3284 | break; |
| 3285 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3286 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3287 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3288 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3289 | break; |
| 3290 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3291 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3292 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3293 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3294 | break; |
| 3295 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3296 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3297 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3298 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3299 | break; |
| 3300 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3301 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3302 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3303 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3304 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3305 | break; |
| 3306 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3307 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3308 | } |
| 3309 | case 'u': |
| 3310 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3311 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3312 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3313 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? |
| 3314 | Option is not documented, bt appears to be for "identify". |
| 3315 | We may need a identify specific verbose! |
| 3316 | */ |
| 3317 | if (plus_alt_op) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3318 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3319 | break; |
| 3320 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3321 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3322 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3323 | break; |
| 3324 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3325 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3326 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3327 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3328 | break; |
| 3329 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3330 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3331 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3332 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3333 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3334 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3335 | if ((flags & SigmaValue) == 0) |
| 3336 | geometry_info.sigma=1.0; |
| 3337 | if ((flags & XiValue) == 0) |
| 3338 | geometry_info.xi=1.0; |
| 3339 | if ((flags & PsiValue) == 0) |
| 3340 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3341 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
| 3342 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3343 | break; |
| 3344 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3345 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3346 | } |
| 3347 | case 'v': |
| 3348 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3349 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3350 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3351 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3352 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3353 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3354 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3355 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3356 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3357 | break; |
| 3358 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3359 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3360 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3361 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3362 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3363 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3364 | if ((flags & SigmaValue) == 0) |
| 3365 | geometry_info.sigma=1.0; |
| 3366 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3367 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3368 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3369 | geometry_info.psi=0.1*_image->rows; |
| 3370 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3371 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3372 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3373 | break; |
| 3374 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3375 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3376 | } |
| 3377 | case 'w': |
| 3378 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3379 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3380 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3381 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3382 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3383 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3384 | if ((flags & SigmaValue) == 0) |
| 3385 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3386 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3387 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3388 | break; |
| 3389 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3390 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3391 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3392 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3393 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3394 | (void) WhiteThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3395 | break; |
| 3396 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3397 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3398 | } |
| 3399 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3400 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3401 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3402 | /* clean up percent escape interpreted strings */ |
| 3403 | if (arg1 != arg1n ) |
| 3404 | arg1=DestroyString((char *)arg1); |
| 3405 | if (arg2 != arg2n ) |
| 3406 | arg2=DestroyString((char *)arg2); |
| 3407 | |
| 3408 | /* Replace current image with any image that was generated |
| 3409 | and set image point to last image (so image->next is correct) */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3410 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3411 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3412 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3413 | return(MagickTrue); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3414 | #undef _image_info |
| 3415 | #undef _draw_info |
| 3416 | #undef _quantize_info |
| 3417 | #undef _image |
| 3418 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3419 | #undef IfNormalOp |
| 3420 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3421 | #undef normal_op |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3422 | #undef plus_alt_op |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3423 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3424 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3425 | WandPrivate MagickBooleanType CLISimpleOperatorImages(MagickCLI *cli_wand, |
| 3426 | const char *option,const char *arg1,const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3427 | { |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3428 | #if !USE_WAND_METHODS |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3429 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3430 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3431 | i; |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3432 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3433 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3434 | assert(cli_wand != (MagickCLI *) NULL); |
| 3435 | assert(cli_wand->signature == WandSignature); |
| 3436 | assert(cli_wand->wand.signature == WandSignature); |
| 3437 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3438 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3439 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3440 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3441 | #if !USE_WAND_METHODS |
| 3442 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3443 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3444 | n=GetImageListLength(cli_wand->wand.images); |
| 3445 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3446 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3447 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3448 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3449 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3450 | break; |
| 3451 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3452 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3453 | assert( i == n ); |
| 3454 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3455 | #else |
| 3456 | MagickResetIterator(&cli_wand->wand); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3457 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3458 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3459 | MagickResetIterator(&cli_wand->wand); |
| 3460 | #endif |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3461 | return(MagickTrue); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3462 | } |
| 3463 | |
| 3464 | /* |
| 3465 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3466 | % % |
| 3467 | % % |
| 3468 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3469 | + 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] | 3470 | % % |
| 3471 | % % |
| 3472 | % % |
| 3473 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3474 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3475 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3476 | % entire image list as a whole. The result is often a complete replacment |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3477 | % of the image list with a completely new list, or with just a single image |
| 3478 | % result. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3479 | % |
| 3480 | % The format of the MogrifyImage method is: |
| 3481 | % |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3482 | % MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, |
| 3483 | % const char *option,const char *arg1,const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3484 | % |
| 3485 | % A description of each parameter follows: |
| 3486 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3487 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3488 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3489 | % o option: The option string for the operation |
| 3490 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3491 | % o arg1, arg2: optional argument strings to the operation |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3492 | % arg2 is currently not used |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3493 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3494 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3495 | WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, |
| 3496 | const char *option,const char *arg1n,const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3497 | { |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 3498 | const char /* For percent escape interpretImageProperties() */ |
| 3499 | *arg1, |
| 3500 | *arg2; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3501 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3502 | Image |
| 3503 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3504 | |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 3505 | MagickStatusType |
| 3506 | status; |
| 3507 | |
| 3508 | ssize_t |
| 3509 | parse; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3510 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3511 | #define _image_info (cli_wand->wand.image_info) |
| 3512 | #define _images (cli_wand->wand.images) |
| 3513 | #define _exception (cli_wand->wand.exception) |
| 3514 | #define _draw_info (cli_wand->draw_info) |
| 3515 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3516 | #define _process_flags (cli_wand->process_flags) |
| 3517 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3518 | #define IfNormalOp (*option=='-') |
| 3519 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3520 | #define normal_op IsMagickTrue(IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3521 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3522 | assert(cli_wand != (MagickCLI *) NULL); |
| 3523 | assert(cli_wand->signature == WandSignature); |
| 3524 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3525 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3526 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3527 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3528 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3529 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 3530 | arg1 = arg1n; |
| 3531 | arg2 = arg2n; |
| 3532 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 3533 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 3534 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 3535 | /* Interpret Percent escapes in argument 1 */ |
| 3536 | if (arg1n != (char *) NULL) { |
| 3537 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 3538 | if (arg1 == (char *) NULL) { |
| 3539 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3540 | arg1=arg1n; /* use the given argument as is */ |
| 3541 | } |
| 3542 | } |
| 3543 | if (arg2n != (char *) NULL) { |
| 3544 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 3545 | if (arg2 == (char *) NULL) { |
| 3546 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3547 | arg2=arg2n; /* use the given argument as is */ |
| 3548 | } |
| 3549 | } |
| 3550 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 3551 | #undef _process_flags |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3552 | #undef _option_type |
| 3553 | |
| 3554 | #if 0 |
| 3555 | (void) FormatLocaleFile(stderr, |
| 3556 | "CLIListOperatorImages: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); |
| 3557 | #endif |
| 3558 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3559 | status=MagickTrue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3560 | new_images=NewImageList(); |
| 3561 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3562 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3563 | { |
| 3564 | case 'a': |
| 3565 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3566 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3567 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3568 | new_images=AppendImages(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3569 | break; |
| 3570 | } |
cristy | 52ad9e9 | 2013-02-08 23:23:29 +0000 | [diff] [blame] | 3571 | if (LocaleCompare("average",option+1) == 0) |
| 3572 | { |
| 3573 | CLIWandWarnReplaced("-evaluate-sequence Mean"); |
| 3574 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
| 3575 | break; |
| 3576 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3577 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3578 | } |
| 3579 | case 'c': |
| 3580 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3581 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3582 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3583 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3584 | break; |
| 3585 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3586 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3587 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3588 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3589 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3590 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3591 | /* FUTURE - make this a compose option, and thus can be used |
| 3592 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3593 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3594 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3595 | new_images=RemoveFirstImageFromList(&_images); |
| 3596 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3597 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3598 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3599 | break; |
cristy | e52fb5e | 2012-04-06 23:30:20 +0000 | [diff] [blame] | 3600 | (void) ClutImage(new_images,clut_image,new_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3601 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3602 | break; |
| 3603 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3604 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3605 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3606 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3607 | break; |
| 3608 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3609 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3610 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3611 | /* FUTURE - this may be replaced by a 'channel' method */ |
cristy | 46f354c | 2012-07-04 13:31:29 +0000 | [diff] [blame] | 3612 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
cristy | 8448a0d | 2013-02-15 18:20:53 +0000 | [diff] [blame] | 3613 | if (parse < 0) |
| 3614 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace",option, |
| 3615 | arg1); |
cristy | 46f354c | 2012-07-04 13:31:29 +0000 | [diff] [blame] | 3616 | new_images=CombineImages(_images,(ColorspaceType) parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3617 | break; |
| 3618 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3619 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3620 | { |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3621 | CompositeOperator |
| 3622 | compose; |
| 3623 | |
| 3624 | const char* |
| 3625 | value; |
| 3626 | |
| 3627 | MagickBooleanType |
| 3628 | clip_to_self; |
| 3629 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3630 | Image |
| 3631 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3632 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3633 | |
| 3634 | RectangleInfo |
| 3635 | geometry; |
| 3636 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3637 | /* Compose value from "-compose" option only */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3638 | value=GetImageOption(_image_info,"compose"); |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3639 | if (value == (const char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3640 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3641 | else |
| 3642 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 3643 | MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3644 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3645 | /* Get "clip-to-self" expert setting (false is normal) */ |
cristy | ca0e82c | 2012-04-10 11:53:24 +0000 | [diff] [blame] | 3646 | value=GetImageOption(_image_info,"compose:clip-to-self"); |
| 3647 | if (value == (const char *) NULL) |
| 3648 | clip_to_self=MagickTrue; |
| 3649 | else |
| 3650 | clip_to_self=IsStringTrue(GetImageOption(_image_info, |
| 3651 | "compose:clip-to-self")); /* if this is true */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3652 | value=GetImageOption(_image_info,"compose:outside-overlay"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3653 | if (value != (const char *) NULL) { /* or this false */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3654 | /* FUTURE: depreciate warning for "compose:outside-overlay"*/ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3655 | clip_to_self= IsMagickFalse(IsStringNotFalse(value)); |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3656 | } |
| 3657 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3658 | new_images=RemoveFirstImageFromList(&_images); |
| 3659 | source_image=RemoveFirstImageFromList(&_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3660 | if (source_image == (Image *) NULL) |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3661 | break; /* FUTURE - produce Exception, rather than silent fail */ |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3662 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3663 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3664 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3665 | source_image->geometry,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3666 | SetGeometry(source_image,&geometry); |
| 3667 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3668 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3669 | new_images->gravity, &geometry); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3670 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3671 | if (mask_image != (Image *) NULL) |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3672 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3673 | if ((compose == DisplaceCompositeOp) || |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3674 | (compose == DistortCompositeOp)) |
| 3675 | status&=CompositeImage(source_image,mask_image, |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3676 | CopyGreenCompositeOp,MagickTrue,0,0,_exception); |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3677 | else |
cristy | 15007e8 | 2013-02-17 18:46:40 +0000 | [diff] [blame] | 3678 | { |
| 3679 | Image |
| 3680 | *image; |
| 3681 | |
| 3682 | RectangleInfo |
| 3683 | source_geometry; |
| 3684 | |
| 3685 | source_geometry.width=mask_image->columns; |
| 3686 | source_geometry.height=mask_image->rows; |
| 3687 | source_geometry.x=(-geometry.x); |
| 3688 | source_geometry.y=(-geometry.y); |
| 3689 | geometry.x=0; |
| 3690 | geometry.y=0; |
| 3691 | image=ExtentImage(source_image,&source_geometry,_exception); |
| 3692 | if (image != (Image *) NULL) |
| 3693 | { |
| 3694 | source_image=DestroyImage(source_image); |
| 3695 | source_image=image; |
| 3696 | } |
| 3697 | status&=CompositeImage(source_image,mask_image, |
| 3698 | IntensityCompositeOp,MagickTrue,0,0,_exception); |
| 3699 | } |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3700 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3701 | } |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3702 | status&=CompositeImage(new_images,source_image,compose,clip_to_self, |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3703 | geometry.x,geometry.y,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3704 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3705 | break; |
| 3706 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3707 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3708 | } |
| 3709 | case 'd': |
| 3710 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3711 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3712 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3713 | CLIWandWarnReplaced("-layer CompareAny"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3714 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3715 | break; |
| 3716 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3717 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3718 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3719 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3720 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3721 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3722 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3723 | break; |
| 3724 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3725 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3726 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3727 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3728 | { |
| 3729 | const char |
| 3730 | *p; |
| 3731 | |
| 3732 | size_t |
| 3733 | number_duplicates; |
| 3734 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3735 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3736 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3737 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3738 | number_duplicates=(size_t) StringToLong(arg1); |
| 3739 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3740 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3741 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3742 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3743 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3744 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3745 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3746 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3747 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3748 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3749 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3750 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3751 | break; |
| 3752 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3753 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3754 | } |
| 3755 | case 'e': |
| 3756 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3757 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3758 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3759 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3760 | if ( parse < 0 ) |
| 3761 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3762 | option,arg1); |
| 3763 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
| 3764 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3765 | break; |
| 3766 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3767 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3768 | } |
| 3769 | case 'f': |
| 3770 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3771 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3772 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3773 | new_images=ForwardFourierTransformImage(_images,normal_op,_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("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3777 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3778 | /* REDIRECTED to use -layers flatten instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3779 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3780 | break; |
| 3781 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3782 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3783 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3784 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3785 | break; |
| 3786 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3787 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3788 | } |
| 3789 | case 'h': |
| 3790 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3791 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3792 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3793 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3794 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3795 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3796 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3797 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3798 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3799 | new_images=RemoveFirstImageFromList(&_images); |
| 3800 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3801 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3802 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3803 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3804 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3805 | break; |
| 3806 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3807 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3808 | } |
| 3809 | case 'i': |
| 3810 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3811 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3812 | { |
| 3813 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3814 | *magnitude_image, |
| 3815 | *phase_image; |
| 3816 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3817 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3818 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3819 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3820 | if (phase_image == (Image *) NULL) |
| 3821 | break; |
| 3822 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3823 | normal_op,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3824 | magnitude_image=DestroyImage(magnitude_image); |
| 3825 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3826 | break; |
| 3827 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3828 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3829 | { |
| 3830 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3831 | *insert_image, |
| 3832 | *index_image; |
| 3833 | |
| 3834 | ssize_t |
| 3835 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3836 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3837 | if (IfNormalOp && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3838 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3839 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3840 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3841 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3842 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3843 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3844 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3845 | PrependImageToList(&_images,insert_image); |
| 3846 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3847 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3848 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3849 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3850 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3851 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3852 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3853 | InsertImageInList(&index_image,insert_image); |
| 3854 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3855 | _images=GetFirstImageInList(index_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 'l': |
| 3861 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3862 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3863 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3864 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3865 | if ( parse < 0 ) |
| 3866 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3867 | option,arg1); |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3868 | switch ((LayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3869 | { |
| 3870 | case CoalesceLayer: |
| 3871 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3872 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3873 | break; |
| 3874 | } |
| 3875 | case CompareAnyLayer: |
| 3876 | case CompareClearLayer: |
| 3877 | case CompareOverlayLayer: |
| 3878 | default: |
| 3879 | { |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3880 | new_images=CompareImagesLayers(_images,(LayerMethod) parse, |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3881 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3882 | break; |
| 3883 | } |
| 3884 | case MergeLayer: |
| 3885 | case FlattenLayer: |
| 3886 | case MosaicLayer: |
| 3887 | case TrimBoundsLayer: |
| 3888 | { |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3889 | new_images=MergeImageLayers(_images,(LayerMethod) parse, |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3890 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3891 | break; |
| 3892 | } |
| 3893 | case DisposeLayer: |
| 3894 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3895 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3896 | break; |
| 3897 | } |
| 3898 | case OptimizeImageLayer: |
| 3899 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3900 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3901 | break; |
| 3902 | } |
| 3903 | case OptimizePlusLayer: |
| 3904 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3905 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3906 | break; |
| 3907 | } |
| 3908 | case OptimizeTransLayer: |
| 3909 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3910 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3911 | break; |
| 3912 | } |
| 3913 | case RemoveDupsLayer: |
| 3914 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3915 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3916 | break; |
| 3917 | } |
| 3918 | case RemoveZeroLayer: |
| 3919 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3920 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3921 | break; |
| 3922 | } |
| 3923 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3924 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3925 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3926 | if (new_images == (Image *) NULL) |
| 3927 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3928 | _images=DestroyImageList(_images); |
| 3929 | _images=OptimizeImageLayers(new_images,_exception); |
| 3930 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3931 | break; |
| 3932 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3933 | OptimizeImageTransparency(_images,_exception); |
| 3934 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 3935 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3936 | break; |
| 3937 | } |
| 3938 | case CompositeLayer: |
| 3939 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3940 | Image |
| 3941 | *source; |
| 3942 | |
| 3943 | RectangleInfo |
| 3944 | geometry; |
| 3945 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3946 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3947 | compose; |
| 3948 | |
| 3949 | const char* |
| 3950 | value; |
| 3951 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3952 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3953 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3954 | if (value != (const char *) NULL) |
| 3955 | compose=(CompositeOperator) ParseCommandOption( |
| 3956 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3957 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3958 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3959 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3960 | while (source != (Image *) NULL) |
| 3961 | { |
| 3962 | source=GetNextImageInList(source); |
| 3963 | if ((source != (Image *) NULL) && |
| 3964 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 3965 | break; |
| 3966 | } |
| 3967 | if (source != (Image *) NULL) |
| 3968 | { |
| 3969 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 3970 | (GetNextImageInList(source) == (Image *) NULL)) |
| 3971 | source=(Image *) NULL; |
| 3972 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3973 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3974 | source=SplitImageList(source->previous); |
| 3975 | DeleteImageFromList(&source); |
| 3976 | } |
| 3977 | } |
| 3978 | if (source == (Image *) NULL) |
| 3979 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3980 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3981 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3982 | break; |
| 3983 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3984 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3985 | SetGeometry(_images,&geometry); |
| 3986 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3987 | geometry.width=source->page.width != 0 ? |
| 3988 | source->page.width : source->columns; |
| 3989 | geometry.height=source->page.height != 0 ? |
| 3990 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3991 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 3992 | _images->page.width : _images->columns, |
| 3993 | _images->page.height != 0 ? _images->page.height : |
| 3994 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3995 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3996 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3997 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 3998 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3999 | source=DestroyImageList(source); |
| 4000 | break; |
| 4001 | } |
| 4002 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4003 | break; |
| 4004 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4005 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4006 | } |
| 4007 | case 'm': |
| 4008 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4009 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4010 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4011 | CLIWandWarnReplaced("+remap"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4012 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4013 | break; |
| 4014 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4015 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4016 | { |
| 4017 | Image |
| 4018 | *morph_image; |
| 4019 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4020 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 4021 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4022 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4023 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4024 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4025 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4026 | _images=DestroyImageList(_images); |
| 4027 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4028 | break; |
| 4029 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4030 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4031 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4032 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 4033 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4034 | break; |
| 4035 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4036 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4037 | } |
| 4038 | case 'p': |
| 4039 | { |
cristy | 02016cf | 2012-11-13 01:14:41 +0000 | [diff] [blame] | 4040 | if (LocaleCompare("poly",option+1) == 0) |
| 4041 | { |
| 4042 | double |
| 4043 | *args; |
| 4044 | |
| 4045 | ssize_t |
| 4046 | count; |
| 4047 | |
| 4048 | /* convert argument string into an array of doubles */ |
| 4049 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
| 4050 | if (args == (double *)NULL ) |
| 4051 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 4052 | new_images=PolynomialImage(_images,count >> 1,args,_exception); |
| 4053 | args=(double *) RelinquishMagickMemory(args); |
| 4054 | break; |
| 4055 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4056 | if (LocaleCompare("print",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4057 | { |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4058 | (void) FormatLocaleFile(stdout,"%s",arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4059 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4060 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4061 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4062 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 4063 | /* FUTURE: better parsing using ScriptToken() from string ??? */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4064 | char |
| 4065 | **arguments; |
| 4066 | |
| 4067 | int |
| 4068 | j, |
| 4069 | number_arguments; |
| 4070 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4071 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4072 | if (arguments == (char **) NULL) |
| 4073 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4074 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4075 | { |
| 4076 | char |
| 4077 | breaker, |
| 4078 | quote, |
| 4079 | *token; |
| 4080 | |
| 4081 | const char |
| 4082 | *arguments; |
| 4083 | |
| 4084 | int |
| 4085 | next, |
| 4086 | status; |
| 4087 | |
| 4088 | size_t |
| 4089 | length; |
| 4090 | |
| 4091 | TokenInfo |
| 4092 | *token_info; |
| 4093 | |
| 4094 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4095 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4096 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4097 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4098 | token=(char *) NULL; |
| 4099 | if (~length >= (MaxTextExtent-1)) |
| 4100 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4101 | sizeof(*token)); |
| 4102 | if (token == (char *) NULL) |
| 4103 | break; |
| 4104 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4105 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4106 | token_info=AcquireTokenInfo(); |
| 4107 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4108 | "\"",'\0',&breaker,&next,"e); |
| 4109 | token_info=DestroyTokenInfo(token_info); |
| 4110 | if (status == 0) |
| 4111 | { |
| 4112 | const char |
| 4113 | *argv; |
| 4114 | |
| 4115 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4116 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4117 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4118 | } |
| 4119 | token=DestroyString(token); |
| 4120 | break; |
| 4121 | } |
| 4122 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4123 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4124 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4125 | for (j=0; j < number_arguments; j++) |
| 4126 | arguments[j]=DestroyString(arguments[j]); |
| 4127 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4128 | break; |
| 4129 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4130 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4131 | } |
| 4132 | case 'r': |
| 4133 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4134 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4135 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4136 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4137 | break; |
| 4138 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4139 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4140 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4141 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4142 | break; |
| 4143 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4144 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4145 | } |
| 4146 | case 's': |
| 4147 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4148 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4149 | { |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4150 | /* FUTURE: this option needs more work to make better */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4151 | ssize_t |
| 4152 | offset; |
| 4153 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4154 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 4155 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4156 | offset=(ssize_t) StringToLong(arg1); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4157 | new_images=SmushImages(_images,normal_op,offset,_exception); |
| 4158 | break; |
| 4159 | } |
| 4160 | if (LocaleCompare("subimage",option+1) == 0) |
| 4161 | { |
| 4162 | Image |
| 4163 | *base_image, |
| 4164 | *compare_image; |
| 4165 | |
| 4166 | const char * |
| 4167 | value; |
| 4168 | |
| 4169 | MetricType |
| 4170 | metric; |
| 4171 | |
| 4172 | double |
| 4173 | similarity; |
| 4174 | |
| 4175 | RectangleInfo |
| 4176 | offset; |
| 4177 | |
| 4178 | base_image=GetImageFromList(_images,0); |
| 4179 | compare_image=GetImageFromList(_images,1); |
| 4180 | |
| 4181 | /* Comparision Metric */ |
| 4182 | metric=UndefinedMetric; |
| 4183 | value=GetImageOption(_image_info,"metric"); |
| 4184 | if (value != (const char *) NULL) |
| 4185 | metric=(MetricType) ParseCommandOption(MagickMetricOptions, |
| 4186 | MagickFalse,value); |
| 4187 | |
| 4188 | new_images=SimilarityImage(base_image,compare_image,metric, |
| 4189 | &offset,&similarity,_exception); |
| 4190 | |
| 4191 | if ( new_images != (Image *)NULL ) { |
| 4192 | char |
| 4193 | result[MaxTextExtent]; |
| 4194 | |
| 4195 | (void) FormatLocaleString(result,MaxTextExtent,"%lf",similarity); |
| 4196 | (void) SetImageProperty(new_images,"subimage:similarity",result, |
| 4197 | _exception); |
| 4198 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4199 | (long) offset.x); |
| 4200 | (void) SetImageProperty(new_images,"subimage:x",result, |
| 4201 | _exception); |
| 4202 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4203 | (long) offset.y); |
| 4204 | (void) SetImageProperty(new_images,"subimage:y",result, |
| 4205 | _exception); |
| 4206 | (void) FormatLocaleString(result,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 4207 | (unsigned long) offset.width,(unsigned long) offset.height, |
| 4208 | (long) offset.x,(long) offset.y); |
| 4209 | (void) SetImageProperty(new_images,"subimage:offset",result, |
| 4210 | _exception); |
| 4211 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4212 | break; |
| 4213 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4214 | if (LocaleCompare("swap",option+1) == 0) { |
| 4215 | Image |
| 4216 | *p, |
| 4217 | *q, |
| 4218 | *swap; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4219 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4220 | ssize_t |
| 4221 | index, |
| 4222 | swap_index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4223 | |
cristy | 6b36c94 | 2013-02-17 00:36:24 +0000 | [diff] [blame] | 4224 | index=(-1); |
| 4225 | swap_index=(-2); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4226 | if (IfNormalOp) { |
| 4227 | GeometryInfo |
| 4228 | geometry_info; |
| 4229 | |
| 4230 | MagickStatusType |
| 4231 | flags; |
| 4232 | |
| 4233 | swap_index=(-1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4234 | flags=ParseGeometry(arg1,&geometry_info); |
cristy | 90fbd1c | 2013-02-17 00:35:35 +0000 | [diff] [blame] | 4235 | if ((flags & RhoValue) == 0) |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 4236 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4237 | index=(ssize_t) geometry_info.rho; |
| 4238 | if ((flags & SigmaValue) != 0) |
| 4239 | swap_index=(ssize_t) geometry_info.sigma; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4240 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4241 | p=GetImageFromList(_images,index); |
| 4242 | q=GetImageFromList(_images,swap_index); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4243 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) { |
| 4244 | if (IfNormalOp) |
| 4245 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1) |
| 4246 | else |
| 4247 | CLIWandExceptionBreak(OptionError,"TwoOrMoreImagesRequired",option); |
| 4248 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4249 | if (p == q) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4250 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4251 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4252 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
| 4253 | ReplaceImageInList(&q,swap); |
| 4254 | _images=GetFirstImageInList(q); |
| 4255 | break; |
| 4256 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4257 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4258 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4259 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4260 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4261 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4262 | |
| 4263 | /* clean up percent escape interpreted strings */ |
| 4264 | if (arg1 != arg1n ) |
| 4265 | arg1=DestroyString((char *)arg1); |
| 4266 | if (arg2 != arg2n ) |
| 4267 | arg2=DestroyString((char *)arg2); |
| 4268 | |
| 4269 | /* if new image list generated, replace existing image list */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4270 | if (new_images == (Image *) NULL) |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 4271 | return(status); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4272 | _images=DestroyImageList(_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4273 | _images=GetFirstImageInList(new_images); |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 4274 | return(status); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4275 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4276 | #undef _image_info |
| 4277 | #undef _images |
| 4278 | #undef _exception |
| 4279 | #undef _draw_info |
| 4280 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4281 | #undef IfNormalOp |
| 4282 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4283 | #undef normal_op |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4284 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4285 | |
| 4286 | /* |
| 4287 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4288 | % % |
| 4289 | % % |
| 4290 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4291 | + C L I N o I m a g e O p e r a t i o n s % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4292 | % % |
| 4293 | % % |
| 4294 | % % |
| 4295 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4296 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4297 | % CLINoImageOperator() Applies operations that may not actually need images |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4298 | % in an image list. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4299 | % |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4300 | % The classic operators of this type is "-read", which actually creates |
| 4301 | % images even when no images are present. Or image stack operators, which |
| 4302 | % can be applied (push or pop) to an empty image list. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4303 | % |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4304 | % Note that these operators may involve other special 'option' prefix |
| 4305 | % characters other than '-' or '+', namely parenthesis and braces. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4306 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4307 | % The format of the CLINoImageOption method is: |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4308 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4309 | % void CLINoImageOption(MagickCLI *cli_wand,const char *option, |
| 4310 | % const char *arg1, const char *arg2) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4311 | % |
| 4312 | % A description of each parameter follows: |
| 4313 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4314 | % o cli_wand: the main CLI Wand to use. (sometimes not required) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4315 | % |
| 4316 | % o option: The special option (with any switch char) to process |
| 4317 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4318 | % o arg1 & arg2: Argument for option, if required |
| 4319 | % Currently arg2 is not used. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4320 | % |
| 4321 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 4322 | WandPrivate void CLINoImageOperator(MagickCLI *cli_wand, |
| 4323 | const char *option,const char *arg1,const char *arg2) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4324 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4325 | #if 0 |
| 4326 | const char /* For percent escape interpretImageProperties() */ |
| 4327 | *arg1, |
| 4328 | *arg2; |
| 4329 | #endif |
| 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 | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4343 | #if 0 |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4344 | Not able to be used as their may not be any images! |
| 4345 | Also the only option that may have arguments that can be percent escaped is |
| 4346 | "-clone". |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4347 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4348 | #define _process_flags (cli_wand->process_flags) |
| 4349 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
| 4350 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 4351 | arg1 = arg1n; |
| 4352 | arg2 = arg2n; |
| 4353 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 4354 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 4355 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 4356 | /* Interpret Percent escapes in argument 1 */ |
| 4357 | if (arg1n != (char *) NULL) { |
| 4358 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 4359 | if (arg1 == (char *) NULL) { |
| 4360 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 4361 | arg1=arg1n; /* use the given argument as is */ |
| 4362 | } |
| 4363 | } |
| 4364 | if (arg2n != (char *) NULL) { |
| 4365 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4366 | if (arg2 == (char *) NULL) { |
| 4367 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 4368 | arg2=arg2n; /* use the given argument as is */ |
| 4369 | } |
| 4370 | } |
| 4371 | } |
| 4372 | #undef _process_flags |
| 4373 | #undef _option_type |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4374 | #endif |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4375 | |
| 4376 | do { /* break to exit code */ |
| 4377 | /* |
| 4378 | No-op options (ignore these) |
| 4379 | */ |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4380 | if (LocaleCompare("noop",option+1) == 0) /* zero argument */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4381 | break; |
| 4382 | if (LocaleCompare("sans",option+1) == 0) /* one argument */ |
| 4383 | break; |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4384 | if (LocaleCompare("sans0",option+1) == 0) /* zero argument */ |
| 4385 | break; |
| 4386 | if (LocaleCompare("sans1",option+1) == 0) /* one argument */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4387 | break; |
| 4388 | if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ |
| 4389 | break; |
| 4390 | /* |
| 4391 | Image Reading |
| 4392 | */ |
| 4393 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
| 4394 | ( LocaleCompare("--",option) == 0 ) ) { |
| 4395 | /* Do Glob filename Expansion for 'arg1' then read all images. |
| 4396 | * |
| 4397 | * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring |
| 4398 | * (but attaching to the filenames in the generated argument list) any |
| 4399 | * [...] read modifiers that may be present. |
| 4400 | * |
| 4401 | * For example: It will expand '*.gif[20x20]' into a list such as |
| 4402 | * 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]' |
| 4403 | * |
| 4404 | * NOTE: In IMv6 this was done globally across all images. This |
| 4405 | * meant you could include IM options in '@filename' lists, but you |
| 4406 | * could not include comments. Doing it only for image read makes |
| 4407 | * it far more secure. |
| 4408 | * |
| 4409 | * Note: arguments do not have percent escapes expanded for security |
| 4410 | * reasons. |
| 4411 | */ |
| 4412 | int argc; |
| 4413 | char **argv; |
| 4414 | ssize_t i; |
| 4415 | |
| 4416 | argc = 1; |
| 4417 | argv = (char **) &arg1; |
| 4418 | |
| 4419 | /* Expand 'glob' expressions in the given filename. |
| 4420 | Expansion handles any 'coder:' prefix, or read modifiers attached |
| 4421 | to the filename, including them in the resulting expanded list. |
| 4422 | */ |
| 4423 | if (IfMagickFalse( ExpandFilenames(&argc,&argv) )) |
| 4424 | CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed", |
| 4425 | option,GetExceptionMessage(errno)); |
| 4426 | |
| 4427 | /* loop over expanded filename list, and read then all in */ |
| 4428 | for (i=0; i<argc; i++) { |
| 4429 | Image * |
| 4430 | new_images; |
| 4431 | if (IfMagickTrue(_image_info->ping)) |
| 4432 | new_images=PingImages(_image_info,argv[i],_exception); |
| 4433 | else |
| 4434 | new_images=ReadImages(_image_info,argv[i],_exception); |
| 4435 | AppendImageToList(&_images, new_images); |
| 4436 | } |
| 4437 | argv=DestroyStringList(argv); /* Destroy the Expanded Filename list */ |
| 4438 | break; |
| 4439 | } |
| 4440 | /* |
| 4441 | Image Writing |
| 4442 | Note: Writing a empty image list is valid in specific cases |
| 4443 | */ |
| 4444 | if (LocaleCompare("write",option+1) == 0) { |
| 4445 | /* Note: arguments do not have percent escapes expanded */ |
| 4446 | char |
| 4447 | key[MaxTextExtent]; |
| 4448 | |
| 4449 | Image |
| 4450 | *write_images; |
| 4451 | |
| 4452 | ImageInfo |
| 4453 | *write_info; |
| 4454 | |
| 4455 | /* Need images, unless a "null:" output coder is used */ |
| 4456 | if ( cli_wand->wand.images == (Image *) NULL ) { |
| 4457 | if ( LocaleCompare(arg1,"null:") == 0 ) |
| 4458 | break; |
| 4459 | CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1); |
| 4460 | } |
| 4461 | |
| 4462 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
| 4463 | (void) DeleteImageRegistry(key); |
| 4464 | write_images=_images; |
| 4465 | if (IfPlusOp) |
| 4466 | write_images=CloneImageList(_images,_exception); |
| 4467 | write_info=CloneImageInfo(_image_info); |
| 4468 | (void) WriteImages(write_info,write_images,arg1,_exception); |
| 4469 | write_info=DestroyImageInfo(write_info); |
| 4470 | if (IfPlusOp) |
| 4471 | write_images=DestroyImageList(write_images); |
| 4472 | break; |
| 4473 | } |
| 4474 | /* |
| 4475 | Parenthesis and Brace operations |
| 4476 | */ |
| 4477 | if (LocaleCompare("(",option) == 0) { |
| 4478 | /* stack 'push' images */ |
| 4479 | Stack |
| 4480 | *node; |
| 4481 | |
| 4482 | size_t |
| 4483 | size; |
| 4484 | |
| 4485 | size=0; |
| 4486 | node=cli_wand->image_list_stack; |
| 4487 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4488 | size++; |
| 4489 | if ( size >= MAX_STACK_DEPTH ) |
| 4490 | CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option); |
| 4491 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4492 | if (node == (Stack *) NULL) |
| 4493 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 4494 | "MemoryAllocationFailed",option); |
| 4495 | node->data = (void *)cli_wand->wand.images; |
| 4496 | cli_wand->wand.images = NewImageList(); |
| 4497 | node->next = cli_wand->image_list_stack; |
| 4498 | cli_wand->image_list_stack = node; |
| 4499 | |
| 4500 | /* handle respect-parenthesis */ |
| 4501 | if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info, |
| 4502 | "respect-parenthesis")))) |
| 4503 | option="{"; /* fall-thru so as to push image settings too */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4504 | else |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4505 | break; |
| 4506 | /* fall thru to next if */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4507 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4508 | if (LocaleCompare("{",option) == 0) { |
| 4509 | /* stack 'push' of image_info settings */ |
| 4510 | Stack |
| 4511 | *node; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4512 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4513 | size_t |
| 4514 | size; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4515 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4516 | size=0; |
| 4517 | node=cli_wand->image_info_stack; |
| 4518 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4519 | size++; |
| 4520 | if ( size >= MAX_STACK_DEPTH ) |
| 4521 | CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option); |
| 4522 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4523 | if (node == (Stack *) NULL) |
| 4524 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 4525 | "MemoryAllocationFailed",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4526 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4527 | node->data = (void *)cli_wand->wand.image_info; |
| 4528 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
| 4529 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
| 4530 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4531 | option); |
| 4532 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4533 | node = (Stack *)RelinquishMagickMemory(node); |
| 4534 | break; |
| 4535 | } |
| 4536 | |
| 4537 | node->next = cli_wand->image_info_stack; |
| 4538 | cli_wand->image_info_stack = node; |
| 4539 | |
| 4540 | break; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4541 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4542 | if (LocaleCompare(")",option) == 0) { |
| 4543 | /* pop images from stack */ |
| 4544 | Stack |
| 4545 | *node; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4546 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4547 | node = (Stack *)cli_wand->image_list_stack; |
| 4548 | if ( node == (Stack *)NULL) |
| 4549 | CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option); |
| 4550 | cli_wand->image_list_stack = node->next; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4551 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4552 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4553 | cli_wand->wand.images= (Image *)node->data; |
| 4554 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4555 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4556 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
| 4557 | node = cli_wand->image_info_stack; |
| 4558 | if ( node != (Stack *)NULL) |
| 4559 | { |
| 4560 | if (IfMagickTrue(IsStringTrue(GetImageOption( |
| 4561 | cli_wand->wand.image_info,"respect-parenthesis")))) |
| 4562 | option="}"; /* fall-thru so as to pop image settings too */ |
| 4563 | else |
| 4564 | break; |
| 4565 | } |
| 4566 | else |
| 4567 | break; |
| 4568 | /* fall thru to next if */ |
| 4569 | } |
| 4570 | if (LocaleCompare("}",option) == 0) { |
| 4571 | /* pop image_info settings from stack */ |
| 4572 | Stack |
| 4573 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4574 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4575 | node = (Stack *)cli_wand->image_info_stack; |
| 4576 | if ( node == (Stack *)NULL) |
| 4577 | CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option); |
| 4578 | cli_wand->image_info_stack = node->next; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4579 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4580 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4581 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4582 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4583 | |
| 4584 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4585 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4586 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4587 | |
| 4588 | break; |
| 4589 | } |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4590 | if (LocaleCompare("set",option+1) == 0) |
| 4591 | { |
| 4592 | /* Note: arguments are not percent escapes expanded yet */ |
| 4593 | /* Some settings are applied to each image in memory in turn. |
| 4594 | While others only need to be applied once globally. |
| 4595 | */ |
| 4596 | char |
| 4597 | *value; |
| 4598 | |
| 4599 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 4600 | { |
| 4601 | if (IfPlusOp) |
| 4602 | { |
| 4603 | (void) DeleteImageRegistry(arg1+9); |
| 4604 | break; |
| 4605 | } |
| 4606 | value=InterpretImageProperties(_image_info,_images,arg2,_exception); |
| 4607 | if (value == (char *) NULL) |
| 4608 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 4609 | option); |
| 4610 | (void) SetImageRegistry(StringRegistryType,arg1+9,value,_exception); |
| 4611 | value=DestroyString(value); |
| 4612 | break; |
| 4613 | } |
| 4614 | if (LocaleNCompare(arg1,"option:",7) == 0) |
| 4615 | { |
| 4616 | /* delete equivelent artifact from all images (if any) */ |
| 4617 | MagickResetIterator(&cli_wand->wand); |
| 4618 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
| 4619 | (void) DeleteImageArtifact(_images,arg1+7); |
| 4620 | MagickResetIterator(&cli_wand->wand); |
| 4621 | /* now set/delete the global option as needed */ |
| 4622 | if (IfPlusOp) { |
| 4623 | (void) DeleteImageOption(_image_info,arg1+7); |
| 4624 | break; |
| 4625 | } |
| 4626 | value=InterpretImageProperties(_image_info,_images,arg2,_exception); |
| 4627 | if (value == (char *) NULL) |
| 4628 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
cristy | 1a78095 | 2013-02-10 17:15:30 +0000 | [diff] [blame] | 4629 | option); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4630 | (void) SetImageOption(_image_info,arg1+7,value); |
| 4631 | value=DestroyString(value); |
| 4632 | break; |
| 4633 | } |
| 4634 | if ( cli_wand->wand.images == (Image *) NULL ) |
| 4635 | CLIWandExceptArgBreak(OptionError,"NoImagesFound",option,arg1); |
| 4636 | MagickResetIterator(&cli_wand->wand); |
| 4637 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
| 4638 | { |
cristy | b3cc75d | 2013-02-05 14:47:44 +0000 | [diff] [blame] | 4639 | Image |
| 4640 | *next; |
| 4641 | |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4642 | if (IfPlusOp) { |
| 4643 | if (LocaleNCompare(arg1,"artifact:",9) == 0) |
| 4644 | (void) DeleteImageArtifact(_images,arg1+9); |
| 4645 | else if (LocaleNCompare(arg1,"property:",9) == 0) |
| 4646 | (void) DeleteImageProperty(_images,arg1+9); |
| 4647 | else |
| 4648 | (void) DeleteImageProperty(_images,arg1); |
| 4649 | break; |
| 4650 | } |
cristy | b3cc75d | 2013-02-05 14:47:44 +0000 | [diff] [blame] | 4651 | next=_images; |
| 4652 | for ( ; next != (Image *) NULL; next=GetNextImageInList(next)) |
| 4653 | { |
| 4654 | value=InterpretImageProperties(_image_info,next,arg2,_exception); |
| 4655 | if (value == (char *) NULL) |
| 4656 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 4657 | option); |
| 4658 | if (LocaleNCompare(arg1,"artifact:",9) == 0) |
| 4659 | (void) SetImageArtifact(next,arg1+9,value); |
| 4660 | else |
| 4661 | if (LocaleNCompare(arg1,"property:",9) == 0) |
| 4662 | (void) SetImageProperty(next,arg1+9,value,_exception); |
| 4663 | else |
| 4664 | (void) SetImageProperty(next,arg1,value,_exception); |
| 4665 | value=DestroyString(value); |
| 4666 | } |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4667 | break; |
| 4668 | } |
| 4669 | MagickResetIterator(&cli_wand->wand); |
| 4670 | break; |
| 4671 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4672 | if (LocaleCompare("clone",option+1) == 0) { |
| 4673 | Image |
| 4674 | *new_images; |
| 4675 | |
| 4676 | if (*option == '+') |
| 4677 | arg1="-1"; |
| 4678 | if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse))) |
| 4679 | CLIWandExceptionBreak(OptionError,"InvalidArgument",option); |
| 4680 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
| 4681 | CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); |
| 4682 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4683 | if (new_images == (Image *) NULL) |
| 4684 | CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); |
| 4685 | new_images=CloneImages(new_images,arg1,_exception); |
| 4686 | if (new_images == (Image *) NULL) |
| 4687 | CLIWandExceptionBreak(OptionError,"NoSuchImage",option); |
| 4688 | AppendImageToList(&_images,new_images); |
| 4689 | break; |
| 4690 | } |
| 4691 | /* |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4692 | Informational Operations. |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4693 | |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4694 | Note that these do not require either a cli-wand or images! |
| 4695 | Though currently a cli-wand much be provided regardless. |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4696 | */ |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4697 | if (LocaleCompare("version",option+1) == 0) |
| 4698 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 4699 | ListMagickVersion(stdout); |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4700 | break; |
| 4701 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4702 | if (LocaleCompare("list",option+1) == 0) { |
| 4703 | /* |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4704 | FUTURE: This 'switch' should really be part of MagickCore |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4705 | */ |
| 4706 | ssize_t |
| 4707 | list; |
| 4708 | |
| 4709 | list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); |
| 4710 | if ( list < 0 ) { |
| 4711 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
| 4712 | break; |
| 4713 | } |
| 4714 | switch (list) |
| 4715 | { |
| 4716 | case MagickCoderOptions: |
| 4717 | { |
| 4718 | (void) ListCoderInfo((FILE *) NULL,_exception); |
| 4719 | break; |
| 4720 | } |
| 4721 | case MagickColorOptions: |
| 4722 | { |
| 4723 | (void) ListColorInfo((FILE *) NULL,_exception); |
| 4724 | break; |
| 4725 | } |
| 4726 | case MagickConfigureOptions: |
| 4727 | { |
| 4728 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
| 4729 | break; |
| 4730 | } |
| 4731 | case MagickDelegateOptions: |
| 4732 | { |
| 4733 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
| 4734 | break; |
| 4735 | } |
| 4736 | case MagickFontOptions: |
| 4737 | { |
| 4738 | (void) ListTypeInfo((FILE *) NULL,_exception); |
| 4739 | break; |
| 4740 | } |
| 4741 | case MagickFormatOptions: |
| 4742 | (void) ListMagickInfo((FILE *) NULL,_exception); |
| 4743 | break; |
| 4744 | case MagickLocaleOptions: |
| 4745 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
| 4746 | break; |
| 4747 | case MagickLogOptions: |
| 4748 | (void) ListLogInfo((FILE *) NULL,_exception); |
| 4749 | break; |
| 4750 | case MagickMagicOptions: |
| 4751 | (void) ListMagicInfo((FILE *) NULL,_exception); |
| 4752 | break; |
| 4753 | case MagickMimeOptions: |
| 4754 | (void) ListMimeInfo((FILE *) NULL,_exception); |
| 4755 | break; |
| 4756 | case MagickModuleOptions: |
| 4757 | (void) ListModuleInfo((FILE *) NULL,_exception); |
| 4758 | break; |
| 4759 | case MagickPolicyOptions: |
| 4760 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
| 4761 | break; |
| 4762 | case MagickResourceOptions: |
| 4763 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
| 4764 | break; |
| 4765 | case MagickThresholdOptions: |
| 4766 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
| 4767 | break; |
| 4768 | default: |
| 4769 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
| 4770 | _exception); |
| 4771 | break; |
| 4772 | } |
| 4773 | break; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4774 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4775 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4776 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4777 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4778 | } while (0); /* break to exit code. */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4779 | |
| 4780 | #if 0 |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4781 | /* clean up percent escape interpreted strings */ |
| 4782 | if (arg1 != arg1n ) |
| 4783 | arg1=DestroyString((char *)arg1); |
| 4784 | if (arg2 != arg2n ) |
| 4785 | arg2=DestroyString((char *)arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4786 | #endif |
| 4787 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4788 | #undef _image_info |
| 4789 | #undef _images |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4790 | #undef _exception |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4791 | #undef IfNormalOp |
| 4792 | #undef IfPlusOp |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4793 | } |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4794 | |
| 4795 | /* |
| 4796 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4797 | % % |
| 4798 | % % |
| 4799 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4800 | + C L I O p t i o n % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4801 | % % |
| 4802 | % % |
| 4803 | % % |
| 4804 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4805 | % |
| 4806 | % CLIOption() Processes the given option using the given CLI Magick Wand. |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4807 | % The option arguments can be variable in number, though at this time no more |
| 4808 | % that two is actually used by any option (this may change). Excess options |
| 4809 | % are simply ignored. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4810 | % |
| 4811 | % If the cli_wand->command pointer is non-null, then it is assumed that the |
| 4812 | % option has already been search for up from the CommandOptions[] table in |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4813 | % "MagickCore/options.c" using GetCommandOptionInfo(). If not set this |
| 4814 | % routine will do the lookup instead. The pointer is reset afterward. |
| 4815 | % |
| 4816 | % This action allows the caller to lookup and pre-handle any 'special' |
| 4817 | % options, (such as implicit reads) before calling this general option |
| 4818 | % handler to deal with 'standard' command line options. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4819 | % |
| 4820 | % The format of the CLIOption method is: |
| 4821 | % |
| 4822 | % void CLIOption(MagickCLI *cli_wand,const char *option, ...) |
| 4823 | % |
| 4824 | % A description of each parameter follows: |
| 4825 | % |
| 4826 | % o cli_wand: the main CLI Wand to use. |
| 4827 | % |
| 4828 | % o option: The special option (with any switch char) to process |
| 4829 | % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4830 | % o args: any required arguments for an option (variable number) |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4831 | % |
| 4832 | % Example Usage... |
| 4833 | % |
| 4834 | % CLIoption(cli_wand,"-read","rose:"); |
| 4835 | % CLIoption(cli_wand,"-virtual-pixel","transparent"); |
| 4836 | % CLIoption(cli_wand,"-distort","SRT:","30"); |
| 4837 | % CLIoption(cli_wand,"-write","rotated_rose.png"); |
| 4838 | % |
| 4839 | */ |
| 4840 | WandExport void CLIOption(MagickCLI *cli_wand,const char *option,...) |
| 4841 | { |
| 4842 | const char |
| 4843 | *arg1, |
| 4844 | *arg2; |
| 4845 | |
| 4846 | CommandOptionFlags |
| 4847 | option_type; |
| 4848 | |
| 4849 | assert(cli_wand != (MagickCLI *) NULL); |
| 4850 | assert(cli_wand->signature == WandSignature); |
| 4851 | assert(cli_wand->wand.signature == WandSignature); |
| 4852 | if (IfMagickTrue(cli_wand->wand.debug)) |
| 4853 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4854 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4855 | do { /* Break Code Block for error handling */ |
| 4856 | |
| 4857 | /* get information about option */ |
| 4858 | if ( cli_wand->command == (const OptionInfo *) NULL ) |
| 4859 | cli_wand->command = GetCommandOptionInfo(option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4860 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4861 | (void) FormatLocaleFile(stderr, "CLIOption \"%s\" matched \"%s\"\n", |
| 4862 | option, cli_wand->command->mnemonic ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4863 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4864 | option_type=(CommandOptionFlags) cli_wand->command->flags; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4865 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4866 | if ( option_type == UndefinedOptionFlag ) |
| 4867 | CLIWandExceptionReturn(OptionFatalError,"UnrecognizedOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4868 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4869 | assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4870 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4871 | /* depreciated options */ |
| 4872 | if ( (option_type & DeprecateOptionFlag) != 0 ) |
| 4873 | CLIWandExceptionBreak(OptionError,"DeprecatedOptionNoCode",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4874 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4875 | /* options that this module does not handle */ |
| 4876 | if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) |
| 4877 | CLIWandExceptionBreak(OptionFatalError,"InvalidUseOfOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4878 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4879 | /* Get argument strings from VarArgs |
| 4880 | How can you determine arguments is enough was supplied? */ |
| 4881 | { size_t |
| 4882 | count = cli_wand->command->type; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4883 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4884 | va_list |
| 4885 | operands; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4886 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4887 | va_start(operands,option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4888 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4889 | arg1=arg2=NULL; |
| 4890 | if ( count >= 1 ) |
| 4891 | arg1=(const char *) va_arg(operands, const char *); |
| 4892 | if ( count >= 2 ) |
| 4893 | arg2=(const char *) va_arg(operands, const char *); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4894 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4895 | va_end(operands); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4896 | |
anthony | 52cb3df | 2012-04-24 03:29:32 +0000 | [diff] [blame] | 4897 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4898 | (void) FormatLocaleFile(stderr, |
| 4899 | "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n", |
| 4900 | option,(long) count,option_type,arg1,arg2); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4901 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4902 | } |
| 4903 | |
| 4904 | /* |
| 4905 | Call the appropriate option handler |
| 4906 | */ |
| 4907 | |
| 4908 | /* FUTURE: this is temporary - get 'settings' to handle distribution of |
| 4909 | settings to images attributes,proprieties,artifacts */ |
| 4910 | if ( cli_wand->wand.images != (Image *)NULL ) |
| 4911 | SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, |
| 4912 | cli_wand->wand.exception); |
| 4913 | |
| 4914 | if ( (option_type & SettingOptionFlags) != 0 ) { |
| 4915 | CLISettingOptionInfo(cli_wand, option, arg1, arg2); |
| 4916 | // FUTURE: Sync Specific Settings into Image Properities (not global) |
| 4917 | } |
| 4918 | |
| 4919 | /* Operators that do not need images - read, write, stack, clone */ |
| 4920 | if ( (option_type & NoImageOperatorFlag) != 0) |
| 4921 | CLINoImageOperator(cli_wand, option, arg1, arg2); |
| 4922 | |
| 4923 | /* FUTURE: The not a setting part below is a temporary hack due to |
| 4924 | * some options being both a Setting and a Simple operator. |
| 4925 | * Specifically -monitor, -depth, and -colorspace */ |
| 4926 | if ( cli_wand->wand.images == (Image *)NULL ) |
| 4927 | if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) && |
| 4928 | ((option_type & SettingOptionFlags) == 0 )) /* temp hack */ |
| 4929 | CLIWandExceptionBreak(OptionError,"NoImagesFound",option); |
| 4930 | |
| 4931 | /* Operators work on single images, and needs a loop over the images */ |
| 4932 | if ( (option_type & SimpleOperatorFlag) != 0) |
| 4933 | CLISimpleOperatorImages(cli_wand, option, arg1, arg2); |
| 4934 | |
| 4935 | /* Operators that work on the image list as a whole */ |
| 4936 | if ( (option_type & ListOperatorFlag) != 0 ) |
| 4937 | CLIListOperatorImages(cli_wand, option, arg1, arg2); |
| 4938 | |
| 4939 | } while (0); /* end Break code block */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4940 | |
| 4941 | cli_wand->command = (const OptionInfo *) NULL; /* prevent re-use later */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4942 | } |