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, |
cristy | ab94359 | 2013-03-29 16:47:23 +0000 | [diff] [blame] | 171 | const SparseColorMethod method,const char *arguments,ExceptionInfo *exception) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 172 | { |
| 173 | char |
| 174 | token[MaxTextExtent]; |
| 175 | |
| 176 | const char |
| 177 | *p; |
| 178 | |
| 179 | double |
| 180 | *sparse_arguments; |
| 181 | |
| 182 | Image |
| 183 | *sparse_image; |
| 184 | |
| 185 | PixelInfo |
| 186 | color; |
| 187 | |
| 188 | MagickBooleanType |
| 189 | error; |
| 190 | |
| 191 | register size_t |
| 192 | x; |
| 193 | |
| 194 | size_t |
| 195 | number_arguments, |
| 196 | number_colors; |
| 197 | |
| 198 | assert(image != (Image *) NULL); |
| 199 | assert(image->signature == MagickSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 200 | if (IfMagickTrue(image->debug)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 201 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 202 | assert(exception != (ExceptionInfo *) NULL); |
| 203 | assert(exception->signature == MagickSignature); |
| 204 | /* |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 205 | Limit channels according to image |
| 206 | add up number of values needed per color. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 207 | */ |
| 208 | number_colors=0; |
| 209 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 210 | number_colors++; |
| 211 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 212 | number_colors++; |
| 213 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 214 | number_colors++; |
| 215 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 216 | (image->colorspace == CMYKColorspace)) |
| 217 | number_colors++; |
| 218 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 219 | image->alpha_trait == BlendPixelTrait) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 220 | number_colors++; |
| 221 | |
| 222 | /* |
| 223 | Read string, to determine number of arguments needed, |
| 224 | */ |
| 225 | p=arguments; |
| 226 | x=0; |
| 227 | while( *p != '\0' ) |
| 228 | { |
| 229 | GetMagickToken(p,&p,token); |
| 230 | if ( token[0] == ',' ) continue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 231 | if ( isalpha((int) token[0]) || token[0] == '#' ) |
| 232 | x += number_colors; /* color argument found */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 233 | else |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 234 | x++; /* floating point argument */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 235 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 236 | /* control points and color values */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 237 | error = IsMagickTrue( x % (2+number_colors) ); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 238 | number_arguments=x; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 239 | if ( IfMagickTrue(error) ) { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 240 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 241 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 242 | "Invalid number of Arguments"); |
| 243 | return( (Image *)NULL); |
| 244 | } |
| 245 | |
| 246 | /* Allocate and fill in the floating point arguments */ |
| 247 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 248 | sizeof(*sparse_arguments)); |
| 249 | if (sparse_arguments == (double *) NULL) { |
| 250 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 251 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 252 | return( (Image *)NULL); |
| 253 | } |
| 254 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 255 | sizeof(*sparse_arguments)); |
| 256 | p=arguments; |
| 257 | x=0; |
| 258 | while( *p != '\0' && x < number_arguments ) { |
| 259 | /* X coordinate */ |
| 260 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 261 | if ( token[0] == '\0' ) break; |
| 262 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 263 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 264 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 265 | "Color found, instead of X-coord"); |
| 266 | error = MagickTrue; |
| 267 | break; |
| 268 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 269 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 270 | /* Y coordinate */ |
| 271 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 272 | if ( token[0] == '\0' ) break; |
| 273 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 274 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 275 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 276 | "Color found, instead of Y-coord"); |
| 277 | error = MagickTrue; |
| 278 | break; |
| 279 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 280 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 281 | /* color name or function given in string argument */ |
| 282 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 283 | if ( token[0] == '\0' ) break; |
| 284 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 285 | /* Color string given */ |
| 286 | (void) QueryColorCompliance(token,AllCompliance,&color, |
| 287 | exception); |
| 288 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 289 | sparse_arguments[x++] = QuantumScale*color.red; |
| 290 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 291 | sparse_arguments[x++] = QuantumScale*color.green; |
| 292 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 293 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 294 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 295 | (image->colorspace == CMYKColorspace)) |
| 296 | sparse_arguments[x++] = QuantumScale*color.black; |
| 297 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 298 | image->alpha_trait == BlendPixelTrait) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 299 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 300 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 301 | else { |
| 302 | /* Colors given as a set of floating point values - experimental */ |
| 303 | /* NB: token contains the first floating point value to use! */ |
| 304 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 305 | { |
| 306 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 307 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 308 | break; |
| 309 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 310 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 311 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 312 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 313 | { |
| 314 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 315 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 316 | break; |
| 317 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 318 | token[0] = ','; /* used this token - get another */ |
| 319 | } |
| 320 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 321 | { |
| 322 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 323 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 324 | break; |
| 325 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 326 | token[0] = ','; /* used this token - get another */ |
| 327 | } |
| 328 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 329 | (image->colorspace == CMYKColorspace)) |
| 330 | { |
| 331 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 332 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 333 | break; |
| 334 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 335 | token[0] = ','; /* used this token - get another */ |
| 336 | } |
| 337 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 338 | image->alpha_trait == BlendPixelTrait) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 339 | { |
| 340 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 341 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 342 | break; |
| 343 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 344 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | } |
| 348 | if ( number_arguments != x && !error ) { |
| 349 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 350 | "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 351 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 352 | return( (Image *)NULL); |
| 353 | } |
| 354 | if ( error ) |
| 355 | return( (Image *)NULL); |
| 356 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 357 | /* Call the Sparse Color Interpolation function with the parsed arguments */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 358 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 359 | exception); |
| 360 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 361 | return( sparse_image ); |
| 362 | } |
| 363 | |
| 364 | /* |
| 365 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 366 | % % |
| 367 | % % |
| 368 | % % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 369 | % 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] | 370 | % % |
| 371 | % % |
| 372 | % % |
| 373 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 374 | % |
| 375 | % CLISettingOptionInfo() applies a single settings option into a CLI wand |
| 376 | % holding the image_info, draw_info, quantize_info structures that will be |
| 377 | % used when processing the images. |
| 378 | % |
| 379 | % These options do no require images to be present in the CLI wand for them |
| 380 | % to be able to be set, in which case they will generally be applied to image |
| 381 | % that are read in later |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 382 | % |
| 383 | % Options handled by this function are listed in CommandOptions[] of |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 384 | % "option.c" that is one of "SettingOptionFlags" option flags. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 385 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 386 | % The format of the CLISettingOptionInfo method is: |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 387 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 388 | % void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 389 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 390 | % |
| 391 | % A description of each parameter follows: |
| 392 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 393 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 394 | % |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 395 | % o option: The option string to be set |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 396 | % |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 397 | % o arg1, arg2: optional argument strings to the operation |
| 398 | % arg2 is currently only used by "-limit" |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 399 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 400 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 401 | WandPrivate void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 402 | const char *option,const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 403 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 404 | ssize_t |
| 405 | parse; /* option argument parsing (string to value table lookup) */ |
| 406 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 407 | const char /* percent escaped versions of the args */ |
| 408 | *arg1, |
| 409 | *arg2; |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 410 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 411 | #define _image_info (cli_wand->wand.image_info) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 412 | #define _image (cli_wand->wand.images) |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 413 | #define _exception (cli_wand->wand.exception) |
| 414 | #define _draw_info (cli_wand->draw_info) |
| 415 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 416 | #define IfSetOption (*option=='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 417 | #define ArgBoolean IsMagickTrue(IfSetOption) |
| 418 | #define ArgBooleanNot IsMagickFalse(IfSetOption) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 419 | #define ArgBooleanString (IfSetOption?"true":"false") |
| 420 | #define ArgOption(def) (IfSetOption?arg1:(const char *)(def)) |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 421 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 422 | assert(cli_wand != (MagickCLI *) NULL); |
| 423 | assert(cli_wand->signature == WandSignature); |
| 424 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 425 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 426 | if (IfMagickTrue(cli_wand->wand.debug)) |
| 427 | (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), |
| 428 | "- Setting Option: %s \"%s\" \"%s\"", option,arg1n,arg2n); |
| 429 | |
| 430 | arg1 = arg1n, |
| 431 | arg2 = arg2n; |
| 432 | |
| 433 | #if 1 |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 434 | #define _process_flags (cli_wand->process_flags) |
| 435 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
| 436 | /* Interpret Percent Escapes in Arguments - using first image */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 437 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 438 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 439 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 440 | /* Interpret Percent escapes in argument 1 */ |
| 441 | if (arg1n != (char *) NULL) { |
| 442 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 443 | if (arg1 == (char *) NULL) { |
| 444 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 445 | arg1=arg1n; /* use the given argument as is */ |
| 446 | } |
| 447 | } |
| 448 | if (arg2n != (char *) NULL) { |
| 449 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 450 | if (arg2 == (char *) NULL) { |
| 451 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 452 | arg2=arg2n; /* use the given argument as is */ |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | #undef _process_flags |
| 457 | #undef _option_type |
| 458 | #endif |
| 459 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 460 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 461 | { |
| 462 | case 'a': |
| 463 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 464 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 465 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 466 | _image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 467 | break; |
| 468 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 469 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 470 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 471 | CLIWandWarnReplaced("-draw 'affine ...'"); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 472 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 473 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 474 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 475 | GetAffineMatrix(&_draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 476 | break; |
| 477 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 478 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 479 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 480 | _image_info->antialias = |
| 481 | _draw_info->stroke_antialias = |
| 482 | _draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 483 | break; |
| 484 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 485 | if (LocaleCompare("attenuate",option+1) == 0) |
| 486 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 487 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 488 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 489 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 490 | break; |
| 491 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 492 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 493 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 494 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 495 | break; |
| 496 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 497 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 498 | } |
| 499 | case 'b': |
| 500 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 501 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 502 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 503 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 504 | _image_info only used directly for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 505 | SyncImageSettings() used to set per-image attribute. |
| 506 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 507 | FUTURE: if _image_info->background_color is not set then |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 508 | we should fall back to per-image background_color |
| 509 | |
| 510 | At this time -background will 'wipe out' the per-image |
| 511 | background color! |
| 512 | |
| 513 | Better error handling of QueryColorCompliance() needed. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 514 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 515 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 516 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 517 | &_image_info->background_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 518 | break; |
| 519 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 520 | if (LocaleCompare("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 521 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 522 | /* FUTURE: bias OBSOLETED, replaced by Artifact "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 523 | as it is actually rarely used except in direct convolve operations |
| 524 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 525 | |
| 526 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 527 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 528 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 529 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 530 | (void) SetImageOption(_image_info,"convolve:bias",ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 531 | break; |
| 532 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 533 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 534 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 535 | /* Used as a image chromaticity setting |
| 536 | SyncImageSettings() used to set per-image attribute. |
| 537 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 538 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 539 | break; |
| 540 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 541 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 542 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 543 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 544 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 545 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 546 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 547 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 548 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 549 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 550 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 551 | break; |
| 552 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 553 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 554 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 555 | /* FUTURE: both _image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 556 | SyncImageSettings() used to set per-image attribute. |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 557 | Better error checking of QueryColorCompliance(). |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 558 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 559 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 560 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 561 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 562 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 563 | &_image_info->border_color,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 564 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 565 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 566 | break; |
| 567 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 568 | (void) DeleteImageOption(_image_info,option+1); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 569 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 570 | &_image_info->border_color,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 571 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 572 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 573 | break; |
| 574 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 575 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 576 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 577 | CLIWandWarnReplaced("-undercolor"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 578 | CLISettingOptionInfo(cli_wand,"-undercolor",arg1, arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 579 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 580 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 581 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 582 | } |
| 583 | case 'c': |
| 584 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 585 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 586 | { |
| 587 | MagickSizeType |
| 588 | limit; |
| 589 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 590 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 591 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 592 | limit=MagickResourceInfinity; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 593 | if (LocaleCompare("unlimited",arg1) != 0) |
| 594 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 595 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 596 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 597 | break; |
| 598 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 599 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 600 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 601 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 602 | break; |
| 603 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 604 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 605 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 606 | arg1=ArgOption("default"); |
| 607 | parse=ParseChannelOption(arg1); |
| 608 | if (parse < 0) |
| 609 | CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType", |
| 610 | option,arg1); |
| 611 | _image_info->channel=(ChannelType) parse; |
| 612 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 613 | break; |
| 614 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 615 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 616 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 617 | /* Setting used for new images via AquireImage() |
| 618 | But also used as a SimpleImageOperator |
| 619 | Undefined colorspace means don't modify images on |
| 620 | read or as a operation */ |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 621 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 622 | ArgOption("undefined")); |
| 623 | if (parse < 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 624 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 625 | option,arg1); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 626 | _image_info->colorspace=(ColorspaceType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 627 | break; |
| 628 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 629 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 630 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 631 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 632 | break; |
| 633 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 634 | if (LocaleCompare("compose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 635 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 636 | /* FUTURE: _image_info should be used, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 637 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 638 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 639 | This setting should NOT be used to set image 'compose' |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 640 | "-layer" operators shoud use _image_info if defined otherwise |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 641 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 642 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 643 | parse = ParseCommandOption(MagickComposeOptions,MagickFalse, |
| 644 | ArgOption("undefined")); |
| 645 | if (parse < 0) |
| 646 | CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", |
| 647 | option,arg1); |
| 648 | _image_info->compose=(CompositeOperator) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 649 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 650 | break; |
| 651 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 652 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 653 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 654 | /* FUTURE: What should be used? _image_info or ImageOption ??? |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 655 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 656 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 657 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 658 | The coders appears to use _image_info, not Image_Option |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 659 | however the image attribute (for save) is set from the |
| 660 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 661 | |
| 662 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 663 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 664 | parse = ParseCommandOption(MagickCompressOptions,MagickFalse, |
| 665 | ArgOption("undefined")); |
| 666 | if (parse < 0) |
| 667 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", |
| 668 | option,arg1); |
| 669 | _image_info->compression=(CompressionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 670 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 671 | break; |
| 672 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 673 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 674 | } |
| 675 | case 'd': |
| 676 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 677 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 678 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 679 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 680 | arg1=ArgOption("none"); |
| 681 | parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); |
| 682 | if (parse < 0) |
| 683 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", |
| 684 | option,arg1); |
| 685 | (void) SetLogEventMask(arg1); |
| 686 | _image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 687 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 688 | break; |
| 689 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 690 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 691 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 692 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 693 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 694 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 695 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 696 | else |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 697 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 698 | break; |
| 699 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 700 | /* DefineImageOption() equals SetImageOption() but with '=' */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 701 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 702 | (void) DefineImageOption(_image_info,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 703 | else if (IsMagickFalse(DeleteImageOption(_image_info,arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 704 | CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 705 | break; |
| 706 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 707 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 708 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 709 | /* Only used for new images via AcquireImage() |
| 710 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 711 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 712 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 713 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 714 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 715 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 716 | break; |
| 717 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 718 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 719 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 720 | /* FUTURE: strings used in _image_info attr and _draw_info! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 721 | Basically as density can be in a XxY form! |
| 722 | |
| 723 | SyncImageSettings() used to set per-image attribute. |
| 724 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 725 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 726 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 727 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 728 | (void) CloneString(&_image_info->density,ArgOption(NULL)); |
| 729 | (void) CloneString(&_draw_info->density,_image_info->density); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 730 | break; |
| 731 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 732 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 733 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 734 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 735 | SyncImageSettings() used to set per-image attribute. |
| 736 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 737 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 738 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 739 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 740 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 741 | break; |
| 742 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 743 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 744 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 745 | /* Image Option is only used to set _draw_info */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 746 | arg1=ArgOption("undefined"); |
| 747 | parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); |
| 748 | if (parse < 0) |
| 749 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", |
| 750 | option,arg1); |
| 751 | _draw_info->direction=(DirectionType) parse; |
| 752 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 753 | break; |
| 754 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 755 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 756 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 757 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); |
| 758 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 759 | break; |
| 760 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 761 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 762 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 763 | /* only used in setting new images */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 764 | arg1=ArgOption("undefined"); |
| 765 | parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); |
| 766 | if (parse < 0) |
| 767 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", |
| 768 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 769 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 770 | break; |
| 771 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 772 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 773 | { |
| 774 | /* FUTURE: this is only used by CompareImages() which is used |
| 775 | only by the "compare" CLI program at this time. */ |
| 776 | arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD); |
| 777 | if (IfMagickFalse(IsGeometry(arg1))) |
| 778 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 779 | (void) SetImageOption(_image_info,option+1,arg1); |
| 780 | break; |
| 781 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 782 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 783 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 784 | /* _image_info attr (on/off), _quantize_info attr (on/off) |
| 785 | but also ImageInfo and _quantize_info method! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 786 | FUTURE: merge the duality of the dithering options |
| 787 | */ |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 788 | _image_info->dither = ArgBoolean; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 789 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); |
| 790 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 791 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 792 | if (_quantize_info->dither_method == NoDitherMethod) |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 793 | _image_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 794 | break; |
| 795 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 796 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 797 | } |
| 798 | case 'e': |
| 799 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 800 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 801 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 802 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); |
| 803 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 804 | break; |
| 805 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 806 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 807 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 808 | /* Both _image_info attr and ImageInfo */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 809 | arg1 = ArgOption("undefined"); |
| 810 | parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); |
| 811 | if (parse < 0) |
| 812 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", |
| 813 | option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 814 | /* FUTURE: check alloc/free of endian string! - remove? */ |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 815 | _image_info->endian=(EndianType) (*arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 816 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 817 | break; |
| 818 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 819 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 820 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 821 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 822 | break; |
| 823 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 824 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 825 | } |
| 826 | case 'f': |
| 827 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 828 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 829 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 830 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 831 | break; |
| 832 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 833 | if (LocaleCompare("features",option+1) == 0) |
| 834 | { |
| 835 | (void) SetImageOption(_image_info,"identify:features", |
| 836 | ArgBooleanString); |
| 837 | if (IfSetOption) |
| 838 | (void) SetImageArtifact(_image,"verbose","true"); |
| 839 | break; |
| 840 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 841 | if (LocaleCompare("fill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 842 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 843 | /* Set "fill" OR "fill-pattern" in _draw_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 844 | The original fill color is preserved if a fill-pattern is given. |
| 845 | That way it does not effect other operations that directly using |
| 846 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 847 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 848 | MagickBooleanType |
| 849 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 850 | |
| 851 | ExceptionInfo |
| 852 | *sans; |
| 853 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 854 | PixelInfo |
| 855 | color; |
| 856 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 857 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 858 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 859 | if (_draw_info->fill_pattern != (Image *) NULL) |
| 860 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 861 | |
| 862 | /* is it a color or a image? -- ignore exceptions */ |
| 863 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 864 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 865 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 866 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 867 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 868 | _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 869 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 870 | _draw_info->fill=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 871 | break; |
| 872 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 873 | if (LocaleCompare("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 874 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 875 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 876 | arg1 = ArgOption("undefined"); |
| 877 | parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); |
| 878 | if (parse < 0) |
| 879 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", |
| 880 | option,arg1); |
| 881 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 882 | break; |
| 883 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 884 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 885 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 886 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); |
| 887 | (void) CloneString(&_image_info->font,_draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 888 | break; |
| 889 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 890 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 891 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 892 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 893 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 894 | register const char |
| 895 | *q; |
| 896 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 897 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 898 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 899 | _image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 900 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 901 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 902 | break; |
| 903 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 904 | if (LocaleCompare("fuzz",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 905 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 906 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 907 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 908 | SyncImageSettings() used to set per-image attribute. |
| 909 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 910 | FUTURE: Can't find anything else using _image_info->fuzz directly! |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 911 | convert structure attribute to 'option' string |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 912 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 913 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 914 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 915 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 916 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 917 | QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 918 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 919 | break; |
| 920 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 921 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 922 | } |
| 923 | case 'g': |
| 924 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 925 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 926 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 927 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 928 | arg1 = ArgOption("none"); |
| 929 | parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); |
| 930 | if (parse < 0) |
| 931 | CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", |
| 932 | option,arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 933 | _draw_info->gravity=(GravityType) parse; |
anthony | e849097 | 2012-04-03 13:16:01 +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 | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 937 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 938 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 939 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 940 | SyncImageSettings() used to set per-image attribute. |
| 941 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 942 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 943 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 944 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 945 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 946 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 947 | break; |
| 948 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 949 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 950 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 951 | case 'h': |
| 952 | { |
| 953 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 954 | { |
| 955 | /* FUTURE: this is only used by CompareImages() which is used |
| 956 | only by the "compare" CLI program at this time. */ |
| 957 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 958 | break; |
| 959 | } |
| 960 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
| 961 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 962 | case 'i': |
| 963 | { |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 964 | if (LocaleCompare("intensity",option+1) == 0) |
| 965 | { |
| 966 | arg1 = ArgOption("undefined"); |
cristy | 8f84fdd | 2013-03-28 17:52:55 +0000 | [diff] [blame] | 967 | parse = ParseCommandOption(MagickPixelIntensityOptions,MagickFalse, |
| 968 | arg1); |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 969 | if (parse < 0) |
cristy | 8f84fdd | 2013-03-28 17:52:55 +0000 | [diff] [blame] | 970 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntensityType", |
| 971 | option,arg1); |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 972 | (void) SetImageOption(_image_info,option+1,arg1); |
| 973 | break; |
| 974 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 975 | if (LocaleCompare("intent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 976 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 977 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 978 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 979 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 980 | */ |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 981 | arg1 = ArgOption("undefined"); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 982 | parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); |
| 983 | if (parse < 0) |
| 984 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", |
| 985 | option,arg1); |
| 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("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 990 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 991 | /* _image_info is directly used by coders (so why an image setting?) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 992 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 993 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 994 | arg1 = ArgOption("undefined"); |
| 995 | parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); |
| 996 | if (parse < 0) |
| 997 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", |
| 998 | option,arg1); |
| 999 | _image_info->interlace=(InterlaceType) parse; |
| 1000 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1001 | break; |
| 1002 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1003 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1004 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1005 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1006 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1007 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1008 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1009 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1010 | break; |
| 1011 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1012 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1013 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1014 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1015 | arg1 = ArgOption("undefined"); |
| 1016 | parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); |
| 1017 | if (parse < 0) |
| 1018 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", |
| 1019 | option,arg1); |
| 1020 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1021 | break; |
| 1022 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1023 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1024 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1025 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1026 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1027 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1028 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1029 | break; |
| 1030 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1031 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1032 | } |
| 1033 | case 'k': |
| 1034 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1035 | if (LocaleCompare("kerning",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1036 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1037 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1038 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1039 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1040 | _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1041 | break; |
| 1042 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1043 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1044 | } |
| 1045 | case 'l': |
| 1046 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1047 | if (LocaleCompare("label",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1048 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1049 | /* only used for new images - not in SyncImageOptions() */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1050 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1051 | break; |
| 1052 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1053 | if (LocaleCompare("limit",option+1) == 0) |
| 1054 | { |
| 1055 | MagickSizeType |
| 1056 | limit; |
| 1057 | |
| 1058 | limit=MagickResourceInfinity; |
| 1059 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 1060 | if ( parse < 0 ) |
| 1061 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 1062 | option,arg1); |
| 1063 | if (LocaleCompare("unlimited",arg2) != 0) |
| 1064 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
| 1065 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
| 1066 | break; |
| 1067 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1068 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1069 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1070 | if (IfSetOption) { |
| 1071 | if ((strchr(arg1,'%') == (char *) NULL)) |
| 1072 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1073 | (void) SetLogFormat(arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1074 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1075 | break; |
| 1076 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1077 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1078 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1079 | /* FUTURE: this is only used by CompareImages() which is used |
| 1080 | only by the "compare" CLI program at this time. */ |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1081 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1082 | break; |
| 1083 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1084 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1085 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1086 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1087 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1088 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1089 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1090 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1091 | break; |
| 1092 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1093 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1094 | } |
| 1095 | case 'm': |
| 1096 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1097 | if (LocaleCompare("mattecolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1098 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1099 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1100 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1101 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1102 | &_image_info->matte_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1103 | break; |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1104 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1105 | if (LocaleCompare("metric",option+1) == 0) |
| 1106 | { |
| 1107 | /* FUTURE: this is only used by CompareImages() which is used |
| 1108 | only by the "compare" CLI program at this time. */ |
| 1109 | parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1); |
| 1110 | if ( parse < 0 ) |
| 1111 | CLIWandExceptArgBreak(OptionError,"UnrecognizedMetricType", |
| 1112 | option,arg1); |
| 1113 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1114 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1115 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1116 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1117 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1118 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1119 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1120 | break; |
| 1121 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1122 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1123 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1124 | /* Setting (used by some input coders!) -- why? |
| 1125 | Warning: This is also Special '-type' SimpleOperator |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1126 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1127 | _image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1128 | break; |
| 1129 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1130 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1131 | } |
| 1132 | case 'o': |
| 1133 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1134 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1135 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1136 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1137 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1138 | FUTURE: make set meta-data operator instead. |
| 1139 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1140 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1141 | parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
| 1142 | ArgOption("undefined")); |
| 1143 | if (parse < 0) |
| 1144 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", |
| 1145 | option,arg1); |
| 1146 | _image_info->orientation=(OrientationType)parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1147 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1148 | break; |
| 1149 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1150 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1151 | } |
| 1152 | case 'p': |
| 1153 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1154 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1155 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1156 | /* Only used for new images and image generators. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1157 | SyncImageSettings() used to set per-image attribute. ????? |
| 1158 | That last is WRONG!!!! |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1159 | FUTURE: adjust named 'page' sizes according density |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1160 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1161 | char |
| 1162 | *canonical_page, |
| 1163 | page[MaxTextExtent]; |
| 1164 | |
| 1165 | const char |
| 1166 | *image_option; |
| 1167 | |
| 1168 | MagickStatusType |
| 1169 | flags; |
| 1170 | |
| 1171 | RectangleInfo |
| 1172 | geometry; |
| 1173 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1174 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1175 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1176 | (void) DeleteImageOption(_image_info,option+1); |
| 1177 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1178 | break; |
| 1179 | } |
| 1180 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1181 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1182 | if (image_option != (const char *) NULL) |
| 1183 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1184 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1185 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1186 | canonical_page=DestroyString(canonical_page); |
| 1187 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1188 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1189 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1190 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1191 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1192 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1193 | (void) SetImageOption(_image_info,option+1,page); |
| 1194 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1195 | break; |
| 1196 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1197 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1198 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1199 | _image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1200 | break; |
| 1201 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1202 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1203 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1204 | if (IfSetOption) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1205 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1206 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1207 | _image_info->pointsize = |
| 1208 | _draw_info->pointsize = |
| 1209 | StringToDouble(arg1,(char **) NULL); |
| 1210 | } |
| 1211 | else { |
| 1212 | _image_info->pointsize=0.0; /* unset pointsize */ |
| 1213 | _draw_info->pointsize=12.0; |
| 1214 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1215 | break; |
| 1216 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1217 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1218 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1219 | arg1=ArgOption("-1"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1220 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1221 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1222 | (void) SetMagickPrecision(StringToInteger(arg1)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1223 | break; |
| 1224 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1225 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1226 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1227 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1228 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1229 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1230 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1231 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1232 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1233 | break; |
| 1234 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1235 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1236 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1237 | } |
| 1238 | case 'q': |
| 1239 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1240 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1241 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1242 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1243 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1244 | _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1) |
| 1245 | : UNDEFINED_COMPRESSION_QUALITY; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1246 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1247 | break; |
| 1248 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1249 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1250 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1251 | /* Just a set direct in _quantize_info */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1252 | arg1=ArgOption("undefined"); |
| 1253 | parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
| 1254 | if (parse < 0) |
| 1255 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 1256 | option,arg1); |
| 1257 | _quantize_info->colorspace=(ColorspaceType)parse; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1258 | break; |
| 1259 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1260 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1261 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1262 | /* FUTURE: if two -quiet is performed you can not do +quiet! |
| 1263 | This needs to be checked over thoughly. |
| 1264 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1265 | static WarningHandler |
| 1266 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1267 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1268 | WarningHandler |
| 1269 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1270 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1271 | if ( tmp != (WarningHandler) NULL) |
| 1272 | warning_handler = tmp; /* remember the old handler */ |
| 1273 | if (!IfSetOption) /* set the old handler */ |
| 1274 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1275 | break; |
| 1276 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1277 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1278 | } |
| 1279 | case 'r': |
| 1280 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1281 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1282 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1283 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1284 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1285 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1286 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1287 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1288 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1289 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1290 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1291 | break; |
| 1292 | } |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1293 | if (LocaleCompare("regard-warnings",option+1) == 0) |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 1294 | /* FUTURE: to be replaced by a 'fatal-level' type setting */ |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1295 | break; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1296 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1297 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1298 | /* _draw_info only setting */ |
| 1299 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1300 | break; |
| 1301 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1302 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
| 1303 | { |
| 1304 | /* link image and setting stacks - option is itself saved on stack! */ |
| 1305 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1306 | break; |
| 1307 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1308 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1309 | } |
| 1310 | case 's': |
| 1311 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1312 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1313 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1314 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1315 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1316 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1317 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1318 | break; |
| 1319 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1320 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1321 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1322 | /* SyncImageSettings() used to set this as a per-image attribute. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1323 | What ??? Why ???? |
| 1324 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1325 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1326 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1327 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1328 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1329 | break; |
| 1330 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1331 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1332 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1333 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1334 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame] | 1335 | SetRandomSecretKey( |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 1336 | IfSetOption ? (unsigned long) StringToUnsignedLong(arg1) |
| 1337 | : (unsigned long) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1338 | break; |
| 1339 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1340 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1341 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1342 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1343 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1344 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1345 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1346 | break; |
| 1347 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1348 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1349 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1350 | arg1=ArgOption("undefined"); |
| 1351 | parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1); |
| 1352 | if (parse < 0) |
| 1353 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStretchType", |
| 1354 | option,arg1); |
| 1355 | _draw_info->stretch=(StretchType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1356 | break; |
| 1357 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1358 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1359 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1360 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1361 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1362 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1363 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1364 | MagickBooleanType |
| 1365 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1366 | |
| 1367 | ExceptionInfo |
| 1368 | *sans; |
| 1369 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1370 | PixelInfo |
| 1371 | color; |
| 1372 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1373 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1374 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1375 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1376 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1377 | |
| 1378 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1379 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1380 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1381 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1382 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1383 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1384 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1385 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1386 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1387 | break; |
| 1388 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1389 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1390 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1391 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1392 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1393 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1394 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1395 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1396 | break; |
| 1397 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1398 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1399 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1400 | arg1=ArgOption("undefined"); |
| 1401 | parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1); |
| 1402 | if (parse < 0) |
| 1403 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStyleType", |
| 1404 | option,arg1); |
| 1405 | _draw_info->style=(StyleType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1406 | break; |
| 1407 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1408 | #if 0 |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1409 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 1410 | { |
| 1411 | /* FUTURE: this is only used by CompareImages() which is used |
| 1412 | only by the "compare" CLI program at this time. */ |
| 1413 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1414 | break; |
| 1415 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1416 | #endif |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1417 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1418 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1419 | /* FUTURE: syncronize to storage - but what does that mean? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1420 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1421 | break; |
| 1422 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1423 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1424 | } |
| 1425 | case 't': |
| 1426 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1427 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1428 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1429 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1430 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1431 | break; |
| 1432 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1433 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1434 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1435 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1436 | /* FUTURE: move _image_info string to option splay-tree |
| 1437 | Other than "montage" what uses "texture" ???? |
| 1438 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1439 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1440 | break; |
| 1441 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1442 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1443 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1444 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1445 | _draw_info->fill_pattern=IfSetOption |
| 1446 | ?GetImageCache(_image_info,arg1,_exception) |
| 1447 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1448 | break; |
| 1449 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1450 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1451 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1452 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1453 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1454 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1455 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1456 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1457 | break; |
| 1458 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1459 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1460 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1461 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1462 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1463 | SyncImageSettings() used to set per-image attribute. |
| 1464 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1465 | Note that +transparent-color, means fall-back to image |
| 1466 | attribute so ImageOption is deleted, not set to a default. |
| 1467 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1468 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1469 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1470 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1471 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1472 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1473 | break; |
| 1474 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1475 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1476 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1477 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1478 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1479 | break; |
| 1480 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1481 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1482 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1483 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1484 | parse=ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 1485 | ArgOption("undefined")); |
| 1486 | if (parse < 0) |
| 1487 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageType", |
| 1488 | option,arg1); |
| 1489 | _image_info->type=(ImageType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1490 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1491 | break; |
| 1492 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1493 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1494 | } |
| 1495 | case 'u': |
| 1496 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1497 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1498 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1499 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1500 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1501 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1502 | break; |
| 1503 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1504 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1505 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1506 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1507 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1508 | FUTURE: this probably should be part of the density setting |
| 1509 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1510 | parse=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
| 1511 | ArgOption("undefined")); |
| 1512 | if (parse < 0) |
| 1513 | CLIWandExceptArgBreak(OptionError,"UnrecognizedUnitsType", |
| 1514 | option,arg1); |
| 1515 | _image_info->units=(ResolutionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1516 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1517 | break; |
| 1518 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1519 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1520 | } |
| 1521 | case 'v': |
| 1522 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1523 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1524 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1525 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1526 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1527 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1528 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1529 | _image_info->verbose= ArgBoolean; |
| 1530 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1531 | break; |
| 1532 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1533 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1534 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1535 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1536 | Only used by coder FPX |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1537 | And it only tests existance, not its content! |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1538 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1539 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1540 | break; |
| 1541 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1542 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1543 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1544 | /* SyncImageSettings() used to set per-image attribute. |
| 1545 | This is VERY deep in the image caching structure. |
| 1546 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1547 | parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 1548 | ArgOption("undefined")); |
| 1549 | if (parse < 0) |
| 1550 | CLIWandExceptArgBreak(OptionError,"UnrecognizedVirtualPixelMethod", |
| 1551 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1552 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1553 | break; |
| 1554 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1555 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1556 | } |
| 1557 | case 'w': |
| 1558 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1559 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1560 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1561 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1562 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1563 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1564 | arg1=ArgOption("all"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1565 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1566 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1567 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1568 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1569 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1570 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1571 | if (_draw_info->weight <= 800) |
| 1572 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1573 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1574 | if (_draw_info->weight >= 100) |
| 1575 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1576 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1577 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1578 | break; |
| 1579 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1580 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1581 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1582 | /* Used as a image chromaticity setting |
| 1583 | SyncImageSettings() used to set per-image attribute. |
| 1584 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1585 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1586 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1587 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1588 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1589 | break; |
| 1590 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1591 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1592 | } |
| 1593 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1594 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1595 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1596 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1597 | /* clean up percent escape interpreted strings */ |
| 1598 | if (arg1 != arg1n ) |
| 1599 | arg1=DestroyString((char *)arg1); |
| 1600 | if (arg2 != arg2n ) |
| 1601 | arg2=DestroyString((char *)arg2); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1602 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1603 | #undef _image_info |
| 1604 | #undef _exception |
| 1605 | #undef _draw_info |
| 1606 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1607 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1608 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1609 | #undef ArgBooleanNot |
| 1610 | #undef ArgBooleanString |
| 1611 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1612 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1613 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | /* |
| 1617 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1618 | % % |
| 1619 | % % |
| 1620 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1621 | + 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] | 1622 | % % |
| 1623 | % % |
| 1624 | % % |
| 1625 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1626 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1627 | % CLISimpleOperatorImages() applys one simple image operation given to all |
| 1628 | % the images in the CLI wand, using any per-image or global settings that was |
| 1629 | % previously saved in the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1630 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1631 | % It is assumed that any such settings are up-to-date. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1632 | % |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 1633 | % The format of the WandSimpleOperatorImages method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1634 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1635 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1636 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1637 | % |
| 1638 | % A description of each parameter follows: |
| 1639 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1640 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1641 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1642 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1643 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1644 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1645 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1646 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1647 | |
| 1648 | /* |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1649 | CLISimpleOperatorImage() is an Internal subrountine to apply one simple |
| 1650 | image operation to the current image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1651 | |
| 1652 | The image in the list may be modified in three different ways... |
| 1653 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1654 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1655 | * one image replace by a list of images (-separate and -crop only!) |
| 1656 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1657 | In each case the result replaces the single original image in the list, as |
| 1658 | well as the pointer to the modified image (last image added if replaced by a |
| 1659 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1660 | |
| 1661 | As the image pointed to may be replaced, the first image in the list may |
| 1662 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1663 | return the Image pointer to the first image in list. |
| 1664 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 1665 | static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1666 | const char *option, const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1667 | { |
| 1668 | Image * |
| 1669 | new_image; |
| 1670 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1671 | GeometryInfo |
| 1672 | geometry_info; |
| 1673 | |
| 1674 | RectangleInfo |
| 1675 | geometry; |
| 1676 | |
| 1677 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1678 | flags; |
| 1679 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1680 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1681 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1682 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 1683 | const char /* percent escaped versions of the args */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1684 | *arg1, |
| 1685 | *arg2; |
| 1686 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 1687 | #define _image_info (cli_wand->wand.image_info) |
| 1688 | #define _image (cli_wand->wand.images) |
| 1689 | #define _exception (cli_wand->wand.exception) |
| 1690 | #define _draw_info (cli_wand->draw_info) |
| 1691 | #define _quantize_info (cli_wand->quantize_info) |
| 1692 | #define _process_flags (cli_wand->process_flags) |
| 1693 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
| 1694 | #define IfNormalOp (*option=='-') |
| 1695 | #define IfPlusOp (*option!='-') |
| 1696 | #define IsNormalOp IsMagickTrue(IfNormalOp) |
| 1697 | #define IsPlusOp IsMagickFalse(IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1698 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1699 | assert(cli_wand != (MagickCLI *) NULL); |
| 1700 | assert(cli_wand->signature == WandSignature); |
| 1701 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1702 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1703 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1704 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1705 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1706 | arg1 = arg1n, |
| 1707 | arg2 = arg2n; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 1708 | |
| 1709 | /* Interpret Percent Escapes in Arguments - using first image */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1710 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 1711 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 1712 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 1713 | /* Interpret Percent escapes in argument 1 */ |
| 1714 | if (arg1n != (char *) NULL) { |
| 1715 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 1716 | if (arg1 == (char *) NULL) { |
| 1717 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1718 | arg1=arg1n; /* use the given argument as is */ |
| 1719 | } |
| 1720 | } |
| 1721 | if (arg2n != (char *) NULL) { |
| 1722 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 1723 | if (arg2 == (char *) NULL) { |
| 1724 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1725 | arg2=arg2n; /* use the given argument as is */ |
| 1726 | } |
| 1727 | } |
| 1728 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1729 | #undef _process_flags |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1730 | #undef _option_type |
| 1731 | |
| 1732 | #if 0 |
| 1733 | (void) FormatLocaleFile(stderr, |
| 1734 | "CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); |
| 1735 | #endif |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1736 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1737 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1738 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1739 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1740 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1741 | { |
| 1742 | case 'a': |
| 1743 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1744 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1745 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1746 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1747 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1748 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1749 | if ((flags & SigmaValue) == 0) |
| 1750 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1751 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1752 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1753 | break; |
| 1754 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1755 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1756 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1757 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1758 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1759 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1760 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1761 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1762 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1763 | break; |
| 1764 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1765 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1766 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1767 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1768 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1769 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1770 | if ((flags & SigmaValue) == 0) |
| 1771 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1772 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1773 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1774 | break; |
| 1775 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1776 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1777 | { |
cristy | 288a353 | 2012-08-28 00:19:44 +0000 | [diff] [blame] | 1778 | parse=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1779 | if (parse < 0) |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 1780 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelOption", |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1781 | option,arg1); |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 1782 | (void) SetImageAlphaChannel(_image,(AlphaChannelOption)parse, |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1783 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1784 | break; |
| 1785 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1786 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1787 | { |
| 1788 | char |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1789 | geometry[MaxTextExtent]; |
| 1790 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1791 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1792 | flags=ParseGeometry(arg1,&geometry_info); |
cristy | 8592b05 | 2013-02-07 01:24:54 +0000 | [diff] [blame] | 1793 | if (flags == 0) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1794 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1795 | if ((flags & SigmaValue) == 0) |
| 1796 | geometry_info.sigma=geometry_info.rho; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1797 | (void) CloneString(&_draw_info->text,arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1798 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1799 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1800 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1801 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1802 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1803 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1804 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1805 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1806 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1807 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1808 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1809 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1810 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1811 | break; |
| 1812 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1813 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1814 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1815 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1816 | break; |
| 1817 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1818 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1819 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1820 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1821 | break; |
| 1822 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1823 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1824 | { |
cristy | fa5f6c7 | 2013-01-01 14:37:35 +0000 | [diff] [blame] | 1825 | new_image=AutoOrientImage(_image,_image->orientation,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1826 | break; |
| 1827 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1828 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1829 | } |
| 1830 | case 'b': |
| 1831 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1832 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1833 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1834 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1835 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1836 | (void) BlackThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1837 | break; |
| 1838 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1839 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1840 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1841 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1842 | if (IfNormalOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1843 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1844 | if ((flags & RhoValue) == 0) |
| 1845 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1846 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1847 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1848 | break; |
| 1849 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1850 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1851 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1852 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1853 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1854 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1855 | if ((flags & SigmaValue) == 0) |
| 1856 | geometry_info.sigma=1.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1857 | new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1858 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1859 | break; |
| 1860 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1861 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1862 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1863 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1864 | compose; |
| 1865 | |
| 1866 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1867 | value; |
| 1868 | |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1869 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1870 | if ((flags & (WidthValue | HeightValue)) == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1871 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1872 | compose=OverCompositeOp; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1873 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1874 | if (value != (const char *) NULL) |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1875 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1876 | MagickFalse,value); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1877 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1878 | break; |
| 1879 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1880 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1881 | { |
| 1882 | double |
| 1883 | brightness, |
| 1884 | contrast; |
| 1885 | |
| 1886 | GeometryInfo |
| 1887 | geometry_info; |
| 1888 | |
| 1889 | MagickStatusType |
| 1890 | flags; |
| 1891 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1892 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1893 | if ((flags & RhoValue) == 0) |
| 1894 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1895 | brightness=geometry_info.rho; |
| 1896 | contrast=0.0; |
| 1897 | if ((flags & SigmaValue) != 0) |
| 1898 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1899 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1900 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1901 | break; |
| 1902 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1903 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1904 | } |
| 1905 | case 'c': |
| 1906 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1907 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1908 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1909 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1910 | char |
| 1911 | *color_correction_collection; |
| 1912 | |
| 1913 | /* |
| 1914 | Color correct with a color decision list. |
| 1915 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1916 | color_correction_collection=FileToString(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1917 | if (color_correction_collection == (char *) NULL) |
| 1918 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1919 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 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("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1924 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1925 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1926 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1927 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1928 | if ((flags & SigmaValue) == 0) |
| 1929 | geometry_info.sigma=1.0; |
| 1930 | if ((flags & XiValue) == 0) |
| 1931 | geometry_info.xi=1.0; |
cristy | ee3f752 | 2012-12-21 19:27:44 +0000 | [diff] [blame] | 1932 | new_image=CharcoalImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1933 | _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("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1937 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1938 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1939 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1940 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 1941 | new_image=ChopImage(_image,&geometry,_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("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1945 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1946 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1947 | break; |
| 1948 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1949 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1950 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1951 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1952 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1953 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1954 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1955 | break; |
| 1956 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1957 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1958 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1959 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1960 | CacheView |
| 1961 | *mask_view; |
| 1962 | |
| 1963 | Image |
| 1964 | *mask_image; |
| 1965 | |
| 1966 | register Quantum |
| 1967 | *restrict q; |
| 1968 | |
| 1969 | register ssize_t |
| 1970 | x; |
| 1971 | |
| 1972 | ssize_t |
| 1973 | y; |
| 1974 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1975 | if (IfPlusOp) { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1976 | /* use "+clip-mask" Remove the write mask for -clip-path */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1977 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1978 | break; |
| 1979 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1980 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1981 | if (mask_image == (Image *) NULL) |
| 1982 | break; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1983 | if (IfMagickFalse(SetImageStorageClass(mask_image,DirectClass,_exception))) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1984 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1985 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1986 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
cristy | 46ff267 | 2012-12-14 15:32:26 +0000 | [diff] [blame] | 1987 | mask_view=AcquireAuthenticCacheView(mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1988 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1989 | { |
| 1990 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1991 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1992 | if (q == (Quantum *) NULL) |
| 1993 | break; |
| 1994 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1995 | { |
cristy | dc2d327 | 2013-02-12 14:00:44 +0000 | [diff] [blame] | 1996 | if (mask_image->alpha_trait != BlendPixelTrait) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1997 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
cristy | 81ac797 | 2013-03-31 19:25:23 +0000 | [diff] [blame] | 1998 | SetPixelGray(mask_image,GetPixelAlpha(mask_image,q),q); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1999 | q+=GetPixelChannels(mask_image); |
| 2000 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2001 | if (IfMagickFalse(SyncCacheViewAuthenticPixels(mask_view,_exception))) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2002 | break; |
| 2003 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2004 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2005 | mask_view=DestroyCacheView(mask_view); |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 2006 | mask_image->alpha_trait=BlendPixelTrait; |
cristy | 81ac797 | 2013-03-31 19:25:23 +0000 | [diff] [blame] | 2007 | (void) SetImageColorspace(_image,GRAYColorspace,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2008 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2009 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2010 | break; |
| 2011 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2012 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2013 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 2014 | (void) ClipImagePath(_image,arg1,IsNormalOp,_exception); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2015 | /* Note: Use "+clip-mask" remove the write mask added */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2016 | break; |
| 2017 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2018 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2019 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2020 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2021 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2022 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2023 | break; |
| 2024 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2025 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2026 | { |
| 2027 | KernelInfo |
| 2028 | *kernel; |
| 2029 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2030 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2031 | if (kernel == (KernelInfo *) NULL) |
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 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2034 | kernel=DestroyKernelInfo(kernel); |
| 2035 | break; |
| 2036 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2037 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2038 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2039 | /* Reduce the number of colors in the image. |
| 2040 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2041 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2042 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2043 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2044 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2045 | if ((_image->storage_class == DirectClass) || |
| 2046 | _image->colors > _quantize_info->number_colors) |
| 2047 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2048 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2049 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2050 | break; |
| 2051 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2052 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2053 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2054 | /* WARNING: this is both a image_info setting (already done) |
| 2055 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2056 | |
| 2057 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2058 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2059 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2060 | Note that +colorspace sets "undefined" or no effect on |
| 2061 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2062 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2063 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2064 | (void) TransformImageColorspace(_image, |
cristy | e0b9b8f | 2013-03-28 12:39:39 +0000 | [diff] [blame] | 2065 | IfNormalOp ? _image_info->colorspace : sRGBColorspace, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2066 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2067 | break; |
| 2068 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2069 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2070 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 2071 | CLIWandWarnReplaced(IfNormalOp?"-level":"+level"); |
| 2072 | (void) ContrastImage(_image,IsNormalOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2073 | break; |
| 2074 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2075 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2076 | { |
| 2077 | double |
| 2078 | black_point, |
| 2079 | white_point; |
| 2080 | |
| 2081 | MagickStatusType |
| 2082 | flags; |
| 2083 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2084 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2085 | if ((flags & RhoValue) == 0) |
| 2086 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2087 | black_point=geometry_info.rho; |
| 2088 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2089 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2090 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2091 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2092 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2093 | } |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2094 | white_point=(double) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2095 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2096 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2097 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2098 | break; |
| 2099 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2100 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2101 | { |
| 2102 | KernelInfo |
| 2103 | *kernel_info; |
| 2104 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2105 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2106 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2107 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | a12d8ba | 2012-04-29 16:33:41 +0000 | [diff] [blame] | 2108 | new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info, |
| 2109 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2110 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2111 | break; |
| 2112 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2113 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2114 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2115 | /* WARNING: This can generate multiple images! */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2116 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2117 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2118 | new_image=CropImageToTiles(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2119 | break; |
| 2120 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2121 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2122 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2123 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2124 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2125 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2126 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2127 | break; |
| 2128 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2129 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2130 | } |
| 2131 | case 'd': |
| 2132 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2133 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2134 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2135 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2136 | StringInfo |
| 2137 | *passkey; |
| 2138 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2139 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2140 | if (passkey == (StringInfo *) NULL) |
| 2141 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2142 | |
| 2143 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2144 | passkey=DestroyStringInfo(passkey); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2145 | break; |
| 2146 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2147 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2148 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2149 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2150 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2151 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2152 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2153 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2154 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2155 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2156 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2157 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2158 | break; |
| 2159 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2160 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2161 | { |
| 2162 | double |
| 2163 | threshold; |
| 2164 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2165 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2166 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2167 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2168 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2169 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2170 | else |
| 2171 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2172 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2173 | break; |
| 2174 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2175 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2176 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2177 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2178 | break; |
| 2179 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2180 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2181 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2182 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2183 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2184 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2185 | ssize_t |
| 2186 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2187 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2188 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2189 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2190 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2191 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2192 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2193 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2194 | double |
| 2195 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2196 | /* Special Case - Argument is actually a resize geometry! |
| 2197 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2198 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2199 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2200 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2201 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2202 | option,arg2); |
| 2203 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2204 | resize_args[0]=(double) geometry.width; |
| 2205 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2206 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2207 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2208 | break; |
| 2209 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2210 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2211 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2212 | if (args == (double *)NULL ) |
| 2213 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2214 | |
| 2215 | new_image=DistortImage(_image,(DistortImageMethod) parse,count,args, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 2216 | IsPlusOp,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2217 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2218 | break; |
| 2219 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2220 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2221 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2222 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2223 | (void) DrawImage(_image,_draw_info,_exception); |
| 2224 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2225 | break; |
| 2226 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2227 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2228 | } |
| 2229 | case 'e': |
| 2230 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2231 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2232 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2233 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2234 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2235 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | 9dc4c51 | 2013-03-24 01:38:00 +0000 | [diff] [blame] | 2236 | new_image=EdgeImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2237 | break; |
| 2238 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2239 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2240 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2241 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2242 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2243 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2244 | if ((flags & SigmaValue) == 0) |
| 2245 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2246 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2247 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2248 | break; |
| 2249 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2250 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2251 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2252 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2253 | StringInfo |
| 2254 | *passkey; |
| 2255 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2256 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2257 | if (passkey != (StringInfo *) NULL) |
| 2258 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2259 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2260 | passkey=DestroyStringInfo(passkey); |
| 2261 | } |
| 2262 | break; |
| 2263 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2264 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2265 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2266 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2267 | break; |
| 2268 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2269 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2270 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2271 | (void) EqualizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2272 | break; |
| 2273 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2274 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2275 | { |
| 2276 | double |
| 2277 | constant; |
| 2278 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2279 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2280 | if ( parse < 0 ) |
| 2281 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2282 | option,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2283 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2284 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2285 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2286 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2287 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2288 | break; |
| 2289 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2290 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2291 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2292 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2293 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2294 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2295 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2296 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2297 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2298 | geometry.height=_image->rows; |
| 2299 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2300 | break; |
| 2301 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2302 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2303 | } |
| 2304 | case 'f': |
| 2305 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2306 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2307 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2308 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2309 | break; |
| 2310 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2311 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2312 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2313 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2314 | break; |
| 2315 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2316 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2317 | { |
| 2318 | PixelInfo |
| 2319 | target; |
| 2320 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2321 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2322 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2323 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2324 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2325 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 2326 | geometry.y,IsPlusOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2327 | break; |
| 2328 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2329 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2330 | { |
| 2331 | FrameInfo |
| 2332 | frame_info; |
| 2333 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2334 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2335 | compose; |
| 2336 | |
| 2337 | const char* |
| 2338 | value; |
| 2339 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2340 | value=GetImageOption(_image_info,"compose"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2341 | compose=OverCompositeOp; /* use Over not _image->compose */ |
cristy | 4b89261 | 2012-08-03 19:31:31 +0000 | [diff] [blame] | 2342 | if (value != (const char *) NULL) |
| 2343 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 2344 | MagickFalse,value); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2345 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2346 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2347 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2348 | frame_info.width=geometry.width; |
| 2349 | frame_info.height=geometry.height; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2350 | frame_info.outer_bevel=geometry.x; |
| 2351 | frame_info.inner_bevel=geometry.y; |
| 2352 | frame_info.x=(ssize_t) frame_info.width; |
| 2353 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2354 | frame_info.width=_image->columns+2*frame_info.width; |
| 2355 | frame_info.height=_image->rows+2*frame_info.height; |
| 2356 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2357 | break; |
| 2358 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2359 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2360 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2361 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2362 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2363 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2364 | ssize_t |
| 2365 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2366 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2367 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2368 | if ( parse < 0 ) |
| 2369 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2370 | option,arg1); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2371 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2372 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2373 | if (args == (double *)NULL ) |
| 2374 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2375 | |
| 2376 | (void) FunctionImage(_image,(MagickFunction)parse,count,args, |
| 2377 | _exception); |
| 2378 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2379 | break; |
| 2380 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2381 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2382 | } |
| 2383 | case 'g': |
| 2384 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2385 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2386 | { |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2387 | double |
| 2388 | constant; |
| 2389 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2390 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2391 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2392 | constant=StringToDouble(arg1,(char **) NULL); |
| 2393 | #if 0 |
| 2394 | /* Using Gamma, via a cache */ |
| 2395 | if (IfPlusOp) |
cristy | 3e3ec3a | 2012-11-03 23:11:06 +0000 | [diff] [blame] | 2396 | constant=PerceptibleReciprocal(constant); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2397 | (void) GammaImage(_image,constant,_exception); |
| 2398 | #else |
| 2399 | /* Using Evaluate POW, direct update of values - more accurite */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2400 | if (IfNormalOp) |
cristy | 3e3ec3a | 2012-11-03 23:11:06 +0000 | [diff] [blame] | 2401 | constant=PerceptibleReciprocal(constant); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2402 | (void) EvaluateImage(_image,PowEvaluateOperator,constant,_exception); |
| 2403 | #endif |
| 2404 | /* Set gamma setting -- Old meaning of "+gamma" |
| 2405 | * _image->gamma=StringToDouble(arg1,(char **) NULL); |
| 2406 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2407 | break; |
| 2408 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2409 | if (LocaleCompare("gaussian-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2410 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2411 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2412 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2413 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2414 | if ((flags & SigmaValue) == 0) |
| 2415 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2416 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2417 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2418 | break; |
| 2419 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2420 | if (LocaleCompare("gaussian",option+1) == 0) |
| 2421 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2422 | CLIWandWarnReplaced("-gaussian-blur"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2423 | CLISimpleOperatorImage(cli_wand,"-gaussian-blur",arg1,NULL); |
| 2424 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2425 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2426 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2427 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2428 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2429 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2430 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2431 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2432 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2433 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2434 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2435 | if (_image->geometry != (char *) NULL) |
| 2436 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2437 | break; |
| 2438 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2439 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2440 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2441 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2442 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2443 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2444 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2445 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2446 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2447 | break; |
| 2448 | } |
cristy | ab94359 | 2013-03-29 16:47:23 +0000 | [diff] [blame] | 2449 | if (LocaleCompare("grayscale",option+1) == 0) |
cristy | e0b9b8f | 2013-03-28 12:39:39 +0000 | [diff] [blame] | 2450 | { |
cristy | ab94359 | 2013-03-29 16:47:23 +0000 | [diff] [blame] | 2451 | parse=ParseCommandOption(MagickPixelIntensityOptions, |
cristy | e0b9b8f | 2013-03-28 12:39:39 +0000 | [diff] [blame] | 2452 | MagickFalse,arg1); |
cristy | ab94359 | 2013-03-29 16:47:23 +0000 | [diff] [blame] | 2453 | if (parse < 0) |
| 2454 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntensityMethod", |
| 2455 | option,arg1); |
| 2456 | (void) GrayscaleImage(_image,(PixelIntensityMethod) parse,_exception); |
cristy | e0b9b8f | 2013-03-28 12:39:39 +0000 | [diff] [blame] | 2457 | break; |
| 2458 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2459 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2460 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2461 | case 'i': |
| 2462 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2463 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2464 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2465 | const char |
| 2466 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2467 | *text; |
| 2468 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2469 | format=GetImageOption(_image_info,"format"); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2470 | if (format == (char *) NULL) { |
| 2471 | (void) IdentifyImage(_image,stdout,_image_info->verbose,_exception); |
| 2472 | break; |
| 2473 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2474 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2475 | if (text == (char *) NULL) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2476 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 2477 | option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2478 | (void) fputs(text,stdout); |
| 2479 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2480 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2481 | break; |
| 2482 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2483 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2484 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2485 | flags=ParseGeometry(arg1,&geometry_info); |
| 2486 | if ((flags & RhoValue) == 0) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2487 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2488 | new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate, |
| 2489 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2490 | break; |
| 2491 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2492 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2493 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2494 | /* FUTURE: New to IMv7 |
| 2495 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2496 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2497 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2498 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2499 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2500 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2501 | break; |
| 2502 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2503 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2504 | } |
| 2505 | case 'l': |
| 2506 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2507 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2508 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2509 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2510 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2511 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | b5c691e | 2012-09-14 17:12:40 +0000 | [diff] [blame] | 2512 | if ((flags & SigmaValue) == 0) |
| 2513 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2514 | if ((flags & PercentValue) != 0) |
| 2515 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2516 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2517 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2518 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2519 | break; |
| 2520 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2521 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2522 | { |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2523 | double |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2524 | black_point, |
| 2525 | gamma, |
| 2526 | white_point; |
| 2527 | |
| 2528 | MagickStatusType |
| 2529 | flags; |
| 2530 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2531 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2532 | if ((flags & RhoValue) == 0) |
| 2533 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2534 | black_point=geometry_info.rho; |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2535 | white_point=(double) QuantumRange; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2536 | if ((flags & SigmaValue) != 0) |
| 2537 | white_point=geometry_info.sigma; |
| 2538 | gamma=1.0; |
| 2539 | if ((flags & XiValue) != 0) |
| 2540 | gamma=geometry_info.xi; |
| 2541 | if ((flags & PercentValue) != 0) |
| 2542 | { |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2543 | black_point*=(double) (QuantumRange/100.0); |
| 2544 | white_point*=(double) (QuantumRange/100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2545 | } |
| 2546 | if ((flags & SigmaValue) == 0) |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2547 | white_point=(double) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2548 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2549 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2550 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2551 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2552 | break; |
| 2553 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2554 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2555 | { |
| 2556 | char |
| 2557 | token[MaxTextExtent]; |
| 2558 | |
| 2559 | const char |
| 2560 | *p; |
| 2561 | |
| 2562 | PixelInfo |
| 2563 | black_point, |
| 2564 | white_point; |
| 2565 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2566 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2567 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2568 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2569 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2570 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2571 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2572 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2573 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2574 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2575 | GetMagickToken(p,&p,token); |
| 2576 | if (*token == '\0') |
| 2577 | white_point=black_point; /* set everything to that color */ |
| 2578 | else |
| 2579 | { |
| 2580 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2581 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2582 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2583 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2584 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2585 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2586 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2587 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2588 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2589 | (void) LevelImageColors(_image,&black_point,&white_point, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 2590 | IsPlusOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2591 | break; |
| 2592 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2593 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2594 | { |
| 2595 | double |
| 2596 | black_point, |
| 2597 | white_point; |
| 2598 | |
| 2599 | MagickStatusType |
| 2600 | flags; |
| 2601 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2602 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2603 | if ((flags & RhoValue) == 0) |
| 2604 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2605 | black_point=geometry_info.rho; |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2606 | white_point=(double) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2607 | if ((flags & SigmaValue) != 0) |
| 2608 | white_point=geometry_info.sigma; |
| 2609 | if ((flags & PercentValue) != 0) |
| 2610 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2611 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2612 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2613 | } |
| 2614 | if ((flags & SigmaValue) == 0) |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2615 | white_point=(double) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2616 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2617 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2618 | break; |
| 2619 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2620 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2621 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2622 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2623 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2624 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2625 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2626 | if ((flags & XValue) == 0) |
| 2627 | geometry.x=1; |
| 2628 | if ((flags & YValue) == 0) |
| 2629 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2630 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2631 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2632 | break; |
| 2633 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2634 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2635 | } |
| 2636 | case 'm': |
| 2637 | { |
cristy | 7220ee4 | 2013-04-14 01:30:34 +0000 | [diff] [blame] | 2638 | if (LocaleCompare("magnify",option+1) == 0) |
| 2639 | { |
| 2640 | new_image=MagnifyImage(_image,_exception); |
| 2641 | break; |
| 2642 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2643 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2644 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2645 | CLIWandWarnReplaced("-remap"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2646 | CLISimpleOperatorImage(cli_wand,"-remap",NULL,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2647 | break; |
| 2648 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2649 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2650 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2651 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2652 | Image |
| 2653 | *mask; |
| 2654 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2655 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2656 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2657 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2658 | break; |
| 2659 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2660 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2661 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2662 | if (mask == (Image *) NULL) |
| 2663 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2664 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2665 | mask=DestroyImage(mask); |
| 2666 | break; |
| 2667 | } |
cristy | 52ad9e9 | 2013-02-08 23:23:29 +0000 | [diff] [blame] | 2668 | if (LocaleCompare("matte",option+1) == 0) |
| 2669 | { |
| 2670 | CLIWandWarnReplaced(IfNormalOp?"-alpha Set":"-alpha Off"); |
| 2671 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2672 | DeactivateAlphaChannel, _exception); |
| 2673 | break; |
| 2674 | } |
| 2675 | if (LocaleCompare("median",option+1) == 0) |
| 2676 | { |
| 2677 | CLIWandWarnReplaced("-statistic Median"); |
| 2678 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2679 | break; |
| 2680 | } |
| 2681 | if (LocaleCompare("mode",option+1) == 0) |
| 2682 | { |
| 2683 | /* FUTURE: note this is also a special "montage" option */ |
| 2684 | CLIWandWarnReplaced("-statistic Mode"); |
| 2685 | CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1); |
| 2686 | break; |
| 2687 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2688 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2689 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2690 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2691 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2692 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2693 | break; |
| 2694 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2695 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2696 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2697 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2698 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2699 | break; |
| 2700 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2701 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2702 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2703 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2704 | break; |
| 2705 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2706 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2707 | { |
| 2708 | char |
| 2709 | token[MaxTextExtent]; |
| 2710 | |
| 2711 | const char |
| 2712 | *p; |
| 2713 | |
| 2714 | KernelInfo |
| 2715 | *kernel; |
| 2716 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2717 | ssize_t |
| 2718 | iterations; |
| 2719 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2720 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2721 | GetMagickToken(p,&p,token); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2722 | parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
| 2723 | if ( parse < 0 ) |
| 2724 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2725 | option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2726 | iterations=1L; |
| 2727 | GetMagickToken(p,&p,token); |
| 2728 | if ((*p == ':') || (*p == ',')) |
| 2729 | GetMagickToken(p,&p,token); |
| 2730 | if ((*p != '\0')) |
| 2731 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2732 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2733 | if (kernel == (KernelInfo *) NULL) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2734 | CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel", |
| 2735 | option,arg2); |
| 2736 | new_image=MorphologyImage(_image,(MorphologyMethod)parse, |
| 2737 | iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2738 | kernel=DestroyKernelInfo(kernel); |
| 2739 | break; |
| 2740 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2741 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2742 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2743 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2744 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2745 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2746 | if ((flags & SigmaValue) == 0) |
| 2747 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2748 | new_image=MotionBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2749 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2750 | break; |
| 2751 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2752 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2753 | } |
| 2754 | case 'n': |
| 2755 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2756 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2757 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 2758 | (void) NegateImage(_image, IsPlusOp, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2759 | break; |
| 2760 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2761 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2762 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2763 | double |
| 2764 | attenuate; |
| 2765 | |
| 2766 | const char* |
| 2767 | value; |
| 2768 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2769 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2770 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2771 | CLIWandWarnReplaced("-statistic NonPeak"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2772 | CLISimpleOperatorImage(cli_wand,"-statistic","NonPeak",arg1); |
| 2773 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2774 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2775 | parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1); |
| 2776 | if ( parse < 0 ) |
| 2777 | CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType", |
| 2778 | option,arg1); |
| 2779 | attenuate=1.0; |
| 2780 | value=GetImageOption(_image_info,"attenuate"); |
| 2781 | if (value != (const char *) NULL) |
| 2782 | attenuate=StringToDouble(value,(char **) NULL); |
| 2783 | new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate, |
| 2784 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2785 | break; |
| 2786 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2787 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2788 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2789 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2790 | break; |
| 2791 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2792 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2793 | } |
| 2794 | case 'o': |
| 2795 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2796 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2797 | { |
| 2798 | PixelInfo |
| 2799 | target; |
| 2800 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2801 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 2802 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,IsPlusOp, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2803 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2804 | break; |
| 2805 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2806 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2807 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2808 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2809 | break; |
| 2810 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2811 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2812 | } |
| 2813 | case 'p': |
| 2814 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2815 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2816 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2817 | flags=ParseGeometry(arg1,&geometry_info); |
| 2818 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2819 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2820 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2821 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2822 | break; |
| 2823 | } |
cristy | 7884a93 | 2012-11-04 14:33:51 +0000 | [diff] [blame] | 2824 | if (LocaleCompare("perceptible",option+1) == 0) |
| 2825 | { |
| 2826 | (void) PerceptibleImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2827 | _exception); |
| 2828 | break; |
| 2829 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2830 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2831 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2832 | const char |
| 2833 | *caption; |
| 2834 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2835 | double |
| 2836 | angle; |
| 2837 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2838 | if (IfPlusOp) { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2839 | RandomInfo |
| 2840 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2841 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2842 | random_info=AcquireRandomInfo(); |
| 2843 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2844 | random_info=DestroyRandomInfo(random_info); |
| 2845 | } |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2846 | else { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2847 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2848 | if ((flags & RhoValue) == 0) |
| 2849 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2850 | angle=geometry_info.rho; |
| 2851 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2852 | caption=GetImageProperty(_image,"caption",_exception); |
| 2853 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 2854 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2855 | break; |
| 2856 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2857 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2858 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2859 | flags=ParseGeometry(arg1,&geometry_info); |
| 2860 | if ((flags & RhoValue) == 0) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2861 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2862 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 2863 | _quantize_info->dither_method,_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("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2867 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2868 | /* FUTURE: should be a 'Genesis' option? |
| 2869 | Option however is also in WandSettingOptionInfo() |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2870 | Why??? |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2871 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2872 | parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1); |
| 2873 | if ( parse < 0 ) |
| 2874 | CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType", |
| 2875 | option,arg1); |
| 2876 | new_image=PreviewImage(_image,(PreviewType)parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2877 | break; |
| 2878 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2879 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2880 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2881 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2882 | const char |
| 2883 | *name; |
| 2884 | |
| 2885 | const StringInfo |
| 2886 | *profile; |
| 2887 | |
| 2888 | Image |
| 2889 | *profile_image; |
| 2890 | |
| 2891 | ImageInfo |
| 2892 | *profile_info; |
| 2893 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2894 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2895 | { /* Remove a profile from the _image. */ |
| 2896 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 2897 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2898 | break; |
| 2899 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2900 | /* Associate a profile with the _image. */ |
| 2901 | profile_info=CloneImageInfo(_image_info); |
| 2902 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2903 | if (profile != (StringInfo *) NULL) |
| 2904 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2905 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2906 | profile_info=DestroyImageInfo(profile_info); |
| 2907 | if (profile_image == (Image *) NULL) |
| 2908 | { |
| 2909 | StringInfo |
| 2910 | *profile; |
| 2911 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2912 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2913 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2914 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2915 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2916 | if (profile != (StringInfo *) NULL) |
| 2917 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2918 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2919 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2920 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2921 | profile=DestroyStringInfo(profile); |
| 2922 | } |
| 2923 | profile_info=DestroyImageInfo(profile_info); |
| 2924 | break; |
| 2925 | } |
| 2926 | ResetImageProfileIterator(profile_image); |
| 2927 | name=GetNextImageProfile(profile_image); |
| 2928 | while (name != (const char *) NULL) |
| 2929 | { |
| 2930 | profile=GetImageProfile(profile_image,name); |
| 2931 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2932 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 2933 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2934 | name=GetNextImageProfile(profile_image); |
| 2935 | } |
| 2936 | profile_image=DestroyImage(profile_image); |
| 2937 | break; |
| 2938 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2939 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2940 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2941 | case 'r': |
| 2942 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2943 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2944 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2945 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2946 | if ((flags & RhoValue) == 0) |
| 2947 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2948 | new_image=RadialBlurImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2949 | break; |
| 2950 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2951 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2952 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2953 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2954 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2955 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 2956 | (void) RaiseImage(_image,&geometry,IsNormalOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2957 | break; |
| 2958 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2959 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2960 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2961 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2962 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2963 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2964 | break; |
| 2965 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2966 | if (LocaleCompare("recolor",option+1) == 0) |
| 2967 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2968 | CLIWandWarnReplaced("-color-matrix"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2969 | CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL); |
| 2970 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2971 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2972 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2973 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2974 | Image |
| 2975 | *remap_image; |
| 2976 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2977 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2978 | if (remap_image == (Image *) NULL) |
| 2979 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2980 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2981 | remap_image=DestroyImage(remap_image); |
| 2982 | break; |
| 2983 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2984 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2985 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2986 | if (IfNormalOp) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2987 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2988 | if (IfMagickFalse(IsGeometry(arg1))) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2989 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 2990 | arg1); |
| 2991 | (void) ResetImagePage(_image,arg1); |
| 2992 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2993 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2994 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2995 | break; |
| 2996 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2997 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2998 | { |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 2999 | /* FUTURE: Roll into a resize special operation */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3000 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3001 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3002 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3003 | if ((flags & SigmaValue) == 0) |
| 3004 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3005 | new_image=ResampleImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3006 | geometry_info.sigma,_image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3007 | break; |
| 3008 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3009 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3010 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3011 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3012 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3013 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3014 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3015 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3016 | break; |
| 3017 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3018 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3019 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3020 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3021 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3022 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3023 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3024 | break; |
| 3025 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3026 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3027 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3028 | flags=ParseGeometry(arg1,&geometry_info); |
| 3029 | if ((flags & RhoValue) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3030 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | ad255a0 | 2012-04-19 15:02:01 +0000 | [diff] [blame] | 3031 | if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows)) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3032 | break; |
| 3033 | if ((flags & LessValue) != 0 && (_image->columns >= _image->rows)) |
| 3034 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3035 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3036 | break; |
| 3037 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3038 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3039 | } |
| 3040 | case 's': |
| 3041 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3042 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3043 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3044 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3045 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3046 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3047 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3048 | new_image=SampleImage(_image,geometry.width,geometry.height, |
| 3049 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3050 | break; |
| 3051 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3052 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3053 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3054 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3055 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3056 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3057 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3058 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3059 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3060 | break; |
| 3061 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3062 | if (LocaleCompare("segment",option+1) == 0) |
| 3063 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3064 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3065 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3066 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3067 | if ((flags & SigmaValue) == 0) |
| 3068 | geometry_info.sigma=1.0; |
| 3069 | (void) SegmentImage(_image,_image->colorspace, |
| 3070 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3071 | _exception); |
| 3072 | break; |
| 3073 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3074 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3075 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3076 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3077 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3078 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3079 | if ((flags & SigmaValue) == 0) |
| 3080 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3081 | if ((flags & PercentValue) != 0) |
| 3082 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3083 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3084 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3085 | break; |
| 3086 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3087 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3088 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3089 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3090 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3091 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3092 | break; |
| 3093 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3094 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3095 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3096 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3097 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3098 | new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1, |
| 3099 | (double) QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3100 | break; |
| 3101 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3102 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3103 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3104 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3105 | if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0)) |
| 3106 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3107 | new_image=ShadeImage(_image,IsNormalOp,geometry_info.rho, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3108 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3109 | break; |
| 3110 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3111 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3112 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3113 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3114 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3115 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3116 | if ((flags & SigmaValue) == 0) |
| 3117 | geometry_info.sigma=1.0; |
| 3118 | if ((flags & XiValue) == 0) |
| 3119 | geometry_info.xi=4.0; |
| 3120 | if ((flags & PsiValue) == 0) |
| 3121 | geometry_info.psi=4.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3122 | new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3123 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3124 | ceil(geometry_info.psi-0.5),_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("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3128 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3129 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3130 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3131 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3132 | if ((flags & SigmaValue) == 0) |
| 3133 | geometry_info.sigma=1.0; |
| 3134 | if ((flags & XiValue) == 0) |
| 3135 | geometry_info.xi=0.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3136 | new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3137 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3138 | break; |
| 3139 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3140 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3141 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3142 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3143 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3144 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3145 | new_image=ShaveImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3146 | break; |
| 3147 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3148 | if (LocaleCompare("shear",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3149 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3150 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3151 | if ((flags & RhoValue) == 0) |
| 3152 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3153 | if ((flags & SigmaValue) == 0) |
| 3154 | geometry_info.sigma=geometry_info.rho; |
cristy | 4b89261 | 2012-08-03 19:31:31 +0000 | [diff] [blame] | 3155 | new_image=ShearImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3156 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3157 | break; |
| 3158 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3159 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3160 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3161 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3162 | if ((flags & RhoValue) == 0) |
| 3163 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3164 | if ((flags & SigmaValue) == 0) |
| 3165 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3166 | if ((flags & PercentValue) != 0) |
| 3167 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3168 | 100.0; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3169 | (void) SigmoidalContrastImage(_image,IsNormalOp,geometry_info.rho, |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 3170 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3171 | break; |
| 3172 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3173 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3174 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3175 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3176 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3177 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3178 | if ((flags & SigmaValue) == 0) |
| 3179 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3180 | new_image=SketchImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3181 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3182 | break; |
| 3183 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3184 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3185 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3186 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3187 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3188 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3189 | QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3190 | break; |
| 3191 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3192 | if (LocaleCompare("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3193 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3194 | parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1); |
| 3195 | if ( parse < 0 ) |
| 3196 | CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod", |
| 3197 | option,arg1); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3198 | new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2, |
| 3199 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3200 | break; |
| 3201 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3202 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3203 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3204 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3205 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3206 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3207 | new_image=SpliceImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3208 | break; |
| 3209 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3210 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3211 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3212 | flags=ParseGeometry(arg1,&geometry_info); |
| 3213 | if ((flags & RhoValue) == 0) |
| 3214 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3215 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3216 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3217 | break; |
| 3218 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3219 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3220 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3221 | parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1); |
| 3222 | if ( parse < 0 ) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3223 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStatisticType", |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3224 | option,arg1); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3225 | flags=ParseGeometry(arg2,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3226 | if ((flags & RhoValue) == 0) |
| 3227 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3228 | if ((flags & SigmaValue) == 0) |
| 3229 | geometry_info.sigma=geometry_info.rho; |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3230 | new_image=StatisticImage(_image,(StatisticType)parse, |
| 3231 | (size_t) geometry_info.rho,(size_t) geometry_info.sigma, |
| 3232 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3233 | break; |
| 3234 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3235 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3236 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3237 | (void) StripImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3238 | break; |
| 3239 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3240 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3241 | { |
cristy | 898c604 | 2012-06-24 00:36:34 +0000 | [diff] [blame] | 3242 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3243 | if ((flags & RhoValue) == 0) |
cristy | 898c604 | 2012-06-24 00:36:34 +0000 | [diff] [blame] | 3244 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3245 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3246 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3247 | break; |
| 3248 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3249 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3250 | } |
| 3251 | case 't': |
| 3252 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3253 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3254 | { |
| 3255 | double |
| 3256 | threshold; |
| 3257 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3258 | threshold=(double) QuantumRange/2; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3259 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3260 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3261 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3262 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3263 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3264 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3265 | break; |
| 3266 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3267 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3268 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3269 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3270 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3271 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3272 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3273 | _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("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3277 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3278 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3279 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3280 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3281 | break; |
| 3282 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3283 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3284 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3285 | CLIWandWarnReplaced("+distort AffineProjection"); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3286 | new_image=AffineTransformImage(_image,&_draw_info->affine,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3287 | break; |
| 3288 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3289 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3290 | { |
| 3291 | PixelInfo |
| 3292 | target; |
| 3293 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3294 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3295 | (void) TransparentPaintImage(_image,&target,(Quantum) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3296 | TransparentAlpha,IsPlusOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3297 | break; |
| 3298 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3299 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3300 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3301 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3302 | break; |
| 3303 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3304 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3305 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3306 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3307 | break; |
| 3308 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3309 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3310 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3311 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3312 | break; |
| 3313 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3314 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3315 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3316 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3317 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3318 | break; |
| 3319 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3320 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3321 | } |
| 3322 | case 'u': |
| 3323 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3324 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3325 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3326 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? |
| 3327 | Option is not documented, bt appears to be for "identify". |
| 3328 | We may need a identify specific verbose! |
| 3329 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3330 | if (IsPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3331 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3332 | break; |
| 3333 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3334 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3335 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3336 | break; |
| 3337 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3338 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3339 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3340 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3341 | break; |
| 3342 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3343 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3344 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3345 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3346 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3347 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3348 | if ((flags & SigmaValue) == 0) |
| 3349 | geometry_info.sigma=1.0; |
| 3350 | if ((flags & XiValue) == 0) |
| 3351 | geometry_info.xi=1.0; |
| 3352 | if ((flags & PsiValue) == 0) |
| 3353 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3354 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
cristy | 3afd401 | 2013-03-25 11:30:44 +0000 | [diff] [blame] | 3355 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3356 | break; |
| 3357 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3358 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3359 | } |
| 3360 | case 'v': |
| 3361 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3362 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3363 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3364 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3365 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3366 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3367 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3368 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3369 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3370 | break; |
| 3371 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3372 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3373 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3374 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3375 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3376 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3377 | if ((flags & SigmaValue) == 0) |
| 3378 | geometry_info.sigma=1.0; |
| 3379 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3380 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3381 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3382 | geometry_info.psi=0.1*_image->rows; |
| 3383 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3384 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3385 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3386 | break; |
| 3387 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3388 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3389 | } |
| 3390 | case 'w': |
| 3391 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3392 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3393 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3394 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3395 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3396 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3397 | if ((flags & SigmaValue) == 0) |
| 3398 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3399 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3400 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3401 | break; |
| 3402 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3403 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3404 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3405 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3406 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3407 | (void) WhiteThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3408 | break; |
| 3409 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3410 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3411 | } |
| 3412 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3413 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3414 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3415 | /* clean up percent escape interpreted strings */ |
| 3416 | if (arg1 != arg1n ) |
| 3417 | arg1=DestroyString((char *)arg1); |
| 3418 | if (arg2 != arg2n ) |
| 3419 | arg2=DestroyString((char *)arg2); |
| 3420 | |
| 3421 | /* Replace current image with any image that was generated |
| 3422 | and set image point to last image (so image->next is correct) */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3423 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3424 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3425 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3426 | return(MagickTrue); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3427 | #undef _image_info |
| 3428 | #undef _draw_info |
| 3429 | #undef _quantize_info |
| 3430 | #undef _image |
| 3431 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3432 | #undef IfNormalOp |
| 3433 | #undef IfPlusOp |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3434 | #undef IsNormalOp |
| 3435 | #undef IsPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3436 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3437 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3438 | WandPrivate MagickBooleanType CLISimpleOperatorImages(MagickCLI *cli_wand, |
| 3439 | const char *option,const char *arg1,const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3440 | { |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3441 | #if !USE_WAND_METHODS |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3442 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3443 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3444 | i; |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3445 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3446 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3447 | assert(cli_wand != (MagickCLI *) NULL); |
| 3448 | assert(cli_wand->signature == WandSignature); |
| 3449 | assert(cli_wand->wand.signature == WandSignature); |
| 3450 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3451 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3452 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3453 | (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), |
| 3454 | "- Simple Operator: %s \"%s\" \"%s\"", option,arg1,arg2); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3455 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3456 | #if !USE_WAND_METHODS |
| 3457 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3458 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3459 | n=GetImageListLength(cli_wand->wand.images); |
| 3460 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3461 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3462 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3463 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3464 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3465 | break; |
| 3466 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3467 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3468 | assert( i == n ); |
| 3469 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3470 | #else |
| 3471 | MagickResetIterator(&cli_wand->wand); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3472 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3473 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3474 | MagickResetIterator(&cli_wand->wand); |
| 3475 | #endif |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3476 | return(MagickTrue); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3477 | } |
| 3478 | |
| 3479 | /* |
| 3480 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3481 | % % |
| 3482 | % % |
| 3483 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3484 | + 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] | 3485 | % % |
| 3486 | % % |
| 3487 | % % |
| 3488 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3489 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3490 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3491 | % entire image list as a whole. The result is often a complete replacment |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3492 | % of the image list with a completely new list, or with just a single image |
| 3493 | % result. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3494 | % |
| 3495 | % The format of the MogrifyImage method is: |
| 3496 | % |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3497 | % MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, |
| 3498 | % const char *option,const char *arg1,const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3499 | % |
| 3500 | % A description of each parameter follows: |
| 3501 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3502 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3503 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3504 | % o option: The option string for the operation |
| 3505 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3506 | % o arg1, arg2: optional argument strings to the operation |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3507 | % arg2 is currently not used |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3508 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3509 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3510 | WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, |
| 3511 | const char *option,const char *arg1n,const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3512 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3513 | const char /* percent escaped versions of the args */ |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 3514 | *arg1, |
| 3515 | *arg2; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3516 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3517 | Image |
| 3518 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3519 | |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 3520 | MagickStatusType |
| 3521 | status; |
| 3522 | |
| 3523 | ssize_t |
| 3524 | parse; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3525 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3526 | #define _image_info (cli_wand->wand.image_info) |
| 3527 | #define _images (cli_wand->wand.images) |
| 3528 | #define _exception (cli_wand->wand.exception) |
| 3529 | #define _draw_info (cli_wand->draw_info) |
| 3530 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3531 | #define _process_flags (cli_wand->process_flags) |
| 3532 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3533 | #define IfNormalOp (*option=='-') |
| 3534 | #define IfPlusOp (*option!='-') |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3535 | #define IsNormalOp IsMagickTrue(IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3536 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3537 | assert(cli_wand != (MagickCLI *) NULL); |
| 3538 | assert(cli_wand->signature == WandSignature); |
| 3539 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3540 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3541 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3542 | if (IfMagickTrue(cli_wand->wand.debug)) |
| 3543 | (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), |
| 3544 | "- List Operator: %s \"%s\" \"%s\"", option,arg1n,arg2n); |
| 3545 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3546 | arg1 = arg1n; |
| 3547 | arg2 = arg2n; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3548 | |
| 3549 | /* Interpret Percent Escapes in Arguments - using first image */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3550 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 3551 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 3552 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 3553 | /* Interpret Percent escapes in argument 1 */ |
| 3554 | if (arg1n != (char *) NULL) { |
| 3555 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 3556 | if (arg1 == (char *) NULL) { |
| 3557 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3558 | arg1=arg1n; /* use the given argument as is */ |
| 3559 | } |
| 3560 | } |
| 3561 | if (arg2n != (char *) NULL) { |
| 3562 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 3563 | if (arg2 == (char *) NULL) { |
| 3564 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3565 | arg2=arg2n; /* use the given argument as is */ |
| 3566 | } |
| 3567 | } |
| 3568 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 3569 | #undef _process_flags |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3570 | #undef _option_type |
| 3571 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3572 | status=MagickTrue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3573 | new_images=NewImageList(); |
| 3574 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3575 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3576 | { |
| 3577 | case 'a': |
| 3578 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3579 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3580 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3581 | new_images=AppendImages(_images,IsNormalOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3582 | break; |
| 3583 | } |
cristy | 52ad9e9 | 2013-02-08 23:23:29 +0000 | [diff] [blame] | 3584 | if (LocaleCompare("average",option+1) == 0) |
| 3585 | { |
| 3586 | CLIWandWarnReplaced("-evaluate-sequence Mean"); |
| 3587 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
| 3588 | break; |
| 3589 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3590 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3591 | } |
| 3592 | case 'c': |
| 3593 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3594 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3595 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3596 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3597 | break; |
| 3598 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3599 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3600 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3601 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3602 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3603 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3604 | /* FUTURE - make this a compose option, and thus can be used |
| 3605 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3606 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3607 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3608 | new_images=RemoveFirstImageFromList(&_images); |
| 3609 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3610 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3611 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3612 | break; |
cristy | e52fb5e | 2012-04-06 23:30:20 +0000 | [diff] [blame] | 3613 | (void) ClutImage(new_images,clut_image,new_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3614 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3615 | break; |
| 3616 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3617 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3618 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3619 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3620 | break; |
| 3621 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3622 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3623 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3624 | /* FUTURE - this may be replaced by a 'channel' method */ |
cristy | 46f354c | 2012-07-04 13:31:29 +0000 | [diff] [blame] | 3625 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
cristy | 8448a0d | 2013-02-15 18:20:53 +0000 | [diff] [blame] | 3626 | if (parse < 0) |
| 3627 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace",option, |
| 3628 | arg1); |
cristy | 46f354c | 2012-07-04 13:31:29 +0000 | [diff] [blame] | 3629 | new_images=CombineImages(_images,(ColorspaceType) parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3630 | break; |
| 3631 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3632 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3633 | { |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3634 | CompositeOperator |
| 3635 | compose; |
| 3636 | |
| 3637 | const char* |
| 3638 | value; |
| 3639 | |
| 3640 | MagickBooleanType |
| 3641 | clip_to_self; |
| 3642 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3643 | Image |
| 3644 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3645 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3646 | |
| 3647 | RectangleInfo |
| 3648 | geometry; |
| 3649 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3650 | /* Compose value from "-compose" option only */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3651 | value=GetImageOption(_image_info,"compose"); |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3652 | if (value == (const char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3653 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3654 | else |
| 3655 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 3656 | MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3657 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3658 | /* Get "clip-to-self" expert setting (false is normal) */ |
cristy | ca0e82c | 2012-04-10 11:53:24 +0000 | [diff] [blame] | 3659 | value=GetImageOption(_image_info,"compose:clip-to-self"); |
| 3660 | if (value == (const char *) NULL) |
| 3661 | clip_to_self=MagickTrue; |
| 3662 | else |
| 3663 | clip_to_self=IsStringTrue(GetImageOption(_image_info, |
| 3664 | "compose:clip-to-self")); /* if this is true */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3665 | value=GetImageOption(_image_info,"compose:outside-overlay"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3666 | if (value != (const char *) NULL) { /* or this false */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3667 | /* FUTURE: depreciate warning for "compose:outside-overlay"*/ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3668 | clip_to_self= IsMagickFalse(IsStringNotFalse(value)); |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3669 | } |
| 3670 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3671 | new_images=RemoveFirstImageFromList(&_images); |
| 3672 | source_image=RemoveFirstImageFromList(&_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3673 | if (source_image == (Image *) NULL) |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3674 | break; /* FUTURE - produce Exception, rather than silent fail */ |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3675 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3676 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3677 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3678 | source_image->geometry,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3679 | SetGeometry(source_image,&geometry); |
| 3680 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3681 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3682 | new_images->gravity, &geometry); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3683 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3684 | if (mask_image != (Image *) NULL) |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3685 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3686 | if ((compose == DisplaceCompositeOp) || |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3687 | (compose == DistortCompositeOp)) |
| 3688 | status&=CompositeImage(source_image,mask_image, |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3689 | CopyGreenCompositeOp,MagickTrue,0,0,_exception); |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3690 | else |
cristy | 15007e8 | 2013-02-17 18:46:40 +0000 | [diff] [blame] | 3691 | { |
| 3692 | Image |
| 3693 | *image; |
| 3694 | |
| 3695 | RectangleInfo |
| 3696 | source_geometry; |
| 3697 | |
| 3698 | source_geometry.width=mask_image->columns; |
| 3699 | source_geometry.height=mask_image->rows; |
| 3700 | source_geometry.x=(-geometry.x); |
| 3701 | source_geometry.y=(-geometry.y); |
| 3702 | geometry.x=0; |
| 3703 | geometry.y=0; |
| 3704 | image=ExtentImage(source_image,&source_geometry,_exception); |
| 3705 | if (image != (Image *) NULL) |
| 3706 | { |
| 3707 | source_image=DestroyImage(source_image); |
| 3708 | source_image=image; |
| 3709 | } |
| 3710 | status&=CompositeImage(source_image,mask_image, |
| 3711 | IntensityCompositeOp,MagickTrue,0,0,_exception); |
| 3712 | } |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3713 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3714 | } |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3715 | status&=CompositeImage(new_images,source_image,compose,clip_to_self, |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3716 | geometry.x,geometry.y,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3717 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3718 | break; |
| 3719 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3720 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3721 | } |
| 3722 | case 'd': |
| 3723 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3724 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3725 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3726 | CLIWandWarnReplaced("-layer CompareAny"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3727 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3728 | break; |
| 3729 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3730 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3731 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3732 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3733 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3734 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3735 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3736 | break; |
| 3737 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3738 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3739 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3740 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3741 | { |
| 3742 | const char |
| 3743 | *p; |
| 3744 | |
| 3745 | size_t |
| 3746 | number_duplicates; |
| 3747 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3748 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3749 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3750 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3751 | number_duplicates=(size_t) StringToLong(arg1); |
| 3752 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3753 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3754 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3755 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3756 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3757 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3758 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3759 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3760 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3761 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3762 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3763 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3764 | break; |
| 3765 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3766 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3767 | } |
| 3768 | case 'e': |
| 3769 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3770 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3771 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3772 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3773 | if ( parse < 0 ) |
| 3774 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3775 | option,arg1); |
| 3776 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
| 3777 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3778 | break; |
| 3779 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3780 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3781 | } |
| 3782 | case 'f': |
| 3783 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3784 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3785 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3786 | new_images=ForwardFourierTransformImage(_images,IsNormalOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3787 | break; |
| 3788 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3789 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3790 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3791 | /* REDIRECTED to use -layers flatten instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3792 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3793 | break; |
| 3794 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3795 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3796 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3797 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3798 | break; |
| 3799 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3800 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3801 | } |
| 3802 | case 'h': |
| 3803 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3804 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3805 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3806 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3807 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3808 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3809 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3810 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3811 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3812 | new_images=RemoveFirstImageFromList(&_images); |
| 3813 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3814 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3815 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3816 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3817 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3818 | break; |
| 3819 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3820 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3821 | } |
| 3822 | case 'i': |
| 3823 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3824 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3825 | { |
| 3826 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3827 | *magnitude_image, |
| 3828 | *phase_image; |
| 3829 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3830 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3831 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3832 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3833 | if (phase_image == (Image *) NULL) |
| 3834 | break; |
| 3835 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 3836 | IsNormalOp,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3837 | magnitude_image=DestroyImage(magnitude_image); |
| 3838 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3839 | break; |
| 3840 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3841 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3842 | { |
| 3843 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3844 | *insert_image, |
| 3845 | *index_image; |
| 3846 | |
| 3847 | ssize_t |
| 3848 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3849 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3850 | if (IfNormalOp && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3851 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3852 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3853 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3854 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3855 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3856 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3857 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3858 | PrependImageToList(&_images,insert_image); |
| 3859 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3860 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3861 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3862 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3863 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3864 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3865 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3866 | InsertImageInList(&index_image,insert_image); |
| 3867 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3868 | _images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3869 | break; |
| 3870 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3871 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3872 | } |
| 3873 | case 'l': |
| 3874 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3875 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3876 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3877 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3878 | if ( parse < 0 ) |
| 3879 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3880 | option,arg1); |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3881 | switch ((LayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3882 | { |
| 3883 | case CoalesceLayer: |
| 3884 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3885 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3886 | break; |
| 3887 | } |
| 3888 | case CompareAnyLayer: |
| 3889 | case CompareClearLayer: |
| 3890 | case CompareOverlayLayer: |
| 3891 | default: |
| 3892 | { |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3893 | new_images=CompareImagesLayers(_images,(LayerMethod) parse, |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3894 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3895 | break; |
| 3896 | } |
| 3897 | case MergeLayer: |
| 3898 | case FlattenLayer: |
| 3899 | case MosaicLayer: |
| 3900 | case TrimBoundsLayer: |
| 3901 | { |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3902 | new_images=MergeImageLayers(_images,(LayerMethod) parse, |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3903 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3904 | break; |
| 3905 | } |
| 3906 | case DisposeLayer: |
| 3907 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3908 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3909 | break; |
| 3910 | } |
| 3911 | case OptimizeImageLayer: |
| 3912 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3913 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3914 | break; |
| 3915 | } |
| 3916 | case OptimizePlusLayer: |
| 3917 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3918 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3919 | break; |
| 3920 | } |
| 3921 | case OptimizeTransLayer: |
| 3922 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3923 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3924 | break; |
| 3925 | } |
| 3926 | case RemoveDupsLayer: |
| 3927 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3928 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3929 | break; |
| 3930 | } |
| 3931 | case RemoveZeroLayer: |
| 3932 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3933 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3934 | break; |
| 3935 | } |
| 3936 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3937 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3938 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3939 | if (new_images == (Image *) NULL) |
| 3940 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3941 | _images=DestroyImageList(_images); |
| 3942 | _images=OptimizeImageLayers(new_images,_exception); |
| 3943 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3944 | break; |
| 3945 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3946 | OptimizeImageTransparency(_images,_exception); |
| 3947 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 3948 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3949 | break; |
| 3950 | } |
| 3951 | case CompositeLayer: |
| 3952 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3953 | Image |
| 3954 | *source; |
| 3955 | |
| 3956 | RectangleInfo |
| 3957 | geometry; |
| 3958 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3959 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3960 | compose; |
| 3961 | |
| 3962 | const char* |
| 3963 | value; |
| 3964 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3965 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3966 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3967 | if (value != (const char *) NULL) |
| 3968 | compose=(CompositeOperator) ParseCommandOption( |
| 3969 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3970 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3971 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3972 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3973 | while (source != (Image *) NULL) |
| 3974 | { |
| 3975 | source=GetNextImageInList(source); |
| 3976 | if ((source != (Image *) NULL) && |
| 3977 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 3978 | break; |
| 3979 | } |
| 3980 | if (source != (Image *) NULL) |
| 3981 | { |
| 3982 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 3983 | (GetNextImageInList(source) == (Image *) NULL)) |
| 3984 | source=(Image *) NULL; |
| 3985 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3986 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3987 | source=SplitImageList(source->previous); |
| 3988 | DeleteImageFromList(&source); |
| 3989 | } |
| 3990 | } |
| 3991 | if (source == (Image *) NULL) |
| 3992 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3993 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3994 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3995 | break; |
| 3996 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3997 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3998 | SetGeometry(_images,&geometry); |
| 3999 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4000 | geometry.width=source->page.width != 0 ? |
| 4001 | source->page.width : source->columns; |
| 4002 | geometry.height=source->page.height != 0 ? |
| 4003 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4004 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 4005 | _images->page.width : _images->columns, |
| 4006 | _images->page.height != 0 ? _images->page.height : |
| 4007 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4008 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4009 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4010 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 4011 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4012 | source=DestroyImageList(source); |
| 4013 | break; |
| 4014 | } |
| 4015 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4016 | break; |
| 4017 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4018 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4019 | } |
| 4020 | case 'm': |
| 4021 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4022 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4023 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4024 | CLIWandWarnReplaced("+remap"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4025 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4026 | break; |
| 4027 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4028 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4029 | { |
| 4030 | Image |
| 4031 | *morph_image; |
| 4032 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4033 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 4034 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4035 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4036 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4037 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4038 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4039 | _images=DestroyImageList(_images); |
| 4040 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4041 | break; |
| 4042 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4043 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4044 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4045 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 4046 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4047 | break; |
| 4048 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4049 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4050 | } |
| 4051 | case 'p': |
| 4052 | { |
cristy | 02016cf | 2012-11-13 01:14:41 +0000 | [diff] [blame] | 4053 | if (LocaleCompare("poly",option+1) == 0) |
| 4054 | { |
| 4055 | double |
| 4056 | *args; |
| 4057 | |
| 4058 | ssize_t |
| 4059 | count; |
| 4060 | |
| 4061 | /* convert argument string into an array of doubles */ |
| 4062 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
| 4063 | if (args == (double *)NULL ) |
| 4064 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 4065 | new_images=PolynomialImage(_images,count >> 1,args,_exception); |
| 4066 | args=(double *) RelinquishMagickMemory(args); |
| 4067 | break; |
| 4068 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4069 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4070 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 4071 | /* FUTURE: better parsing using ScriptToken() from string ??? */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4072 | char |
| 4073 | **arguments; |
| 4074 | |
| 4075 | int |
| 4076 | j, |
| 4077 | number_arguments; |
| 4078 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4079 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4080 | if (arguments == (char **) NULL) |
| 4081 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4082 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4083 | { |
| 4084 | char |
| 4085 | breaker, |
| 4086 | quote, |
| 4087 | *token; |
| 4088 | |
| 4089 | const char |
| 4090 | *arguments; |
| 4091 | |
| 4092 | int |
| 4093 | next, |
| 4094 | status; |
| 4095 | |
| 4096 | size_t |
| 4097 | length; |
| 4098 | |
| 4099 | TokenInfo |
| 4100 | *token_info; |
| 4101 | |
| 4102 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4103 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4104 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4105 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4106 | token=(char *) NULL; |
| 4107 | if (~length >= (MaxTextExtent-1)) |
| 4108 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4109 | sizeof(*token)); |
| 4110 | if (token == (char *) NULL) |
| 4111 | break; |
| 4112 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4113 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4114 | token_info=AcquireTokenInfo(); |
| 4115 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4116 | "\"",'\0',&breaker,&next,"e); |
| 4117 | token_info=DestroyTokenInfo(token_info); |
| 4118 | if (status == 0) |
| 4119 | { |
| 4120 | const char |
| 4121 | *argv; |
| 4122 | |
| 4123 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4124 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4125 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4126 | } |
| 4127 | token=DestroyString(token); |
| 4128 | break; |
| 4129 | } |
| 4130 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4131 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4132 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4133 | for (j=0; j < number_arguments; j++) |
| 4134 | arguments[j]=DestroyString(arguments[j]); |
| 4135 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4136 | break; |
| 4137 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4138 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4139 | } |
| 4140 | case 'r': |
| 4141 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4142 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4143 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4144 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4145 | break; |
| 4146 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4147 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4148 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4149 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4150 | break; |
| 4151 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4152 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4153 | } |
| 4154 | case 's': |
| 4155 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4156 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4157 | { |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4158 | /* FUTURE: this option needs more work to make better */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4159 | ssize_t |
| 4160 | offset; |
| 4161 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4162 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 4163 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4164 | offset=(ssize_t) StringToLong(arg1); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4165 | new_images=SmushImages(_images,IsNormalOp,offset,_exception); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4166 | break; |
| 4167 | } |
| 4168 | if (LocaleCompare("subimage",option+1) == 0) |
| 4169 | { |
| 4170 | Image |
| 4171 | *base_image, |
| 4172 | *compare_image; |
| 4173 | |
| 4174 | const char * |
| 4175 | value; |
| 4176 | |
| 4177 | MetricType |
| 4178 | metric; |
| 4179 | |
| 4180 | double |
| 4181 | similarity; |
| 4182 | |
| 4183 | RectangleInfo |
| 4184 | offset; |
| 4185 | |
| 4186 | base_image=GetImageFromList(_images,0); |
| 4187 | compare_image=GetImageFromList(_images,1); |
| 4188 | |
| 4189 | /* Comparision Metric */ |
| 4190 | metric=UndefinedMetric; |
| 4191 | value=GetImageOption(_image_info,"metric"); |
| 4192 | if (value != (const char *) NULL) |
| 4193 | metric=(MetricType) ParseCommandOption(MagickMetricOptions, |
| 4194 | MagickFalse,value); |
| 4195 | |
cristy | 99fcec4 | 2013-03-15 21:37:59 +0000 | [diff] [blame] | 4196 | new_images=SimilarityImage(base_image,compare_image,metric,0.0, |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4197 | &offset,&similarity,_exception); |
| 4198 | |
| 4199 | if ( new_images != (Image *)NULL ) { |
| 4200 | char |
| 4201 | result[MaxTextExtent]; |
| 4202 | |
| 4203 | (void) FormatLocaleString(result,MaxTextExtent,"%lf",similarity); |
| 4204 | (void) SetImageProperty(new_images,"subimage:similarity",result, |
| 4205 | _exception); |
| 4206 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4207 | (long) offset.x); |
| 4208 | (void) SetImageProperty(new_images,"subimage:x",result, |
| 4209 | _exception); |
| 4210 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4211 | (long) offset.y); |
| 4212 | (void) SetImageProperty(new_images,"subimage:y",result, |
| 4213 | _exception); |
| 4214 | (void) FormatLocaleString(result,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 4215 | (unsigned long) offset.width,(unsigned long) offset.height, |
| 4216 | (long) offset.x,(long) offset.y); |
| 4217 | (void) SetImageProperty(new_images,"subimage:offset",result, |
| 4218 | _exception); |
| 4219 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4220 | break; |
| 4221 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4222 | if (LocaleCompare("swap",option+1) == 0) { |
| 4223 | Image |
| 4224 | *p, |
| 4225 | *q, |
| 4226 | *swap; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4227 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4228 | ssize_t |
| 4229 | index, |
| 4230 | swap_index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4231 | |
cristy | 6b36c94 | 2013-02-17 00:36:24 +0000 | [diff] [blame] | 4232 | index=(-1); |
| 4233 | swap_index=(-2); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4234 | if (IfNormalOp) { |
| 4235 | GeometryInfo |
| 4236 | geometry_info; |
| 4237 | |
| 4238 | MagickStatusType |
| 4239 | flags; |
| 4240 | |
| 4241 | swap_index=(-1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4242 | flags=ParseGeometry(arg1,&geometry_info); |
cristy | 90fbd1c | 2013-02-17 00:35:35 +0000 | [diff] [blame] | 4243 | if ((flags & RhoValue) == 0) |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 4244 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4245 | index=(ssize_t) geometry_info.rho; |
| 4246 | if ((flags & SigmaValue) != 0) |
| 4247 | swap_index=(ssize_t) geometry_info.sigma; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4248 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4249 | p=GetImageFromList(_images,index); |
| 4250 | q=GetImageFromList(_images,swap_index); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4251 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) { |
| 4252 | if (IfNormalOp) |
| 4253 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1) |
| 4254 | else |
| 4255 | CLIWandExceptionBreak(OptionError,"TwoOrMoreImagesRequired",option); |
| 4256 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4257 | if (p == q) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4258 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4259 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4260 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
| 4261 | ReplaceImageInList(&q,swap); |
| 4262 | _images=GetFirstImageInList(q); |
| 4263 | break; |
| 4264 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4265 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4266 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4267 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4268 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4269 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4270 | |
| 4271 | /* clean up percent escape interpreted strings */ |
| 4272 | if (arg1 != arg1n ) |
| 4273 | arg1=DestroyString((char *)arg1); |
| 4274 | if (arg2 != arg2n ) |
| 4275 | arg2=DestroyString((char *)arg2); |
| 4276 | |
| 4277 | /* if new image list generated, replace existing image list */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4278 | if (new_images == (Image *) NULL) |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 4279 | return(status); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4280 | _images=DestroyImageList(_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4281 | _images=GetFirstImageInList(new_images); |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 4282 | return(status); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4283 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4284 | #undef _image_info |
| 4285 | #undef _images |
| 4286 | #undef _exception |
| 4287 | #undef _draw_info |
| 4288 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4289 | #undef IfNormalOp |
| 4290 | #undef IfPlusOp |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4291 | #undef IsNormalOp |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4292 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4293 | |
| 4294 | /* |
| 4295 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4296 | % % |
| 4297 | % % |
| 4298 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4299 | + 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] | 4300 | % % |
| 4301 | % % |
| 4302 | % % |
| 4303 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4304 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4305 | % CLINoImageOperator() Applies operations that may not actually need images |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4306 | % in an image list. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4307 | % |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4308 | % The classic operators of this type is "-read", which actually creates |
| 4309 | % images even when no images are present. Or image stack operators, which |
| 4310 | % can be applied (push or pop) to an empty image list. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4311 | % |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4312 | % Note that these operators may involve other special 'option' prefix |
| 4313 | % characters other than '-' or '+', namely parenthesis and braces. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4314 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4315 | % The format of the CLINoImageOption method is: |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4316 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4317 | % void CLINoImageOption(MagickCLI *cli_wand,const char *option, |
| 4318 | % const char *arg1, const char *arg2) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4319 | % |
| 4320 | % A description of each parameter follows: |
| 4321 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4322 | % o cli_wand: the main CLI Wand to use. (sometimes not required) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4323 | % |
| 4324 | % o option: The special option (with any switch char) to process |
| 4325 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4326 | % o arg1 & arg2: Argument for option, if required |
| 4327 | % Currently arg2 is not used. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4328 | % |
| 4329 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 4330 | WandPrivate void CLINoImageOperator(MagickCLI *cli_wand, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4331 | const char *option,const char *arg1n,const char *arg2n) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4332 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4333 | const char /* percent escaped versions of the args */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4334 | *arg1, |
| 4335 | *arg2; |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4336 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4337 | #define _image_info (cli_wand->wand.image_info) |
| 4338 | #define _images (cli_wand->wand.images) |
| 4339 | #define _exception (cli_wand->wand.exception) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4340 | #define _process_flags (cli_wand->process_flags) |
| 4341 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4342 | #define IfNormalOp (*option=='-') |
| 4343 | #define IfPlusOp (*option!='-') |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4344 | |
| 4345 | assert(cli_wand != (MagickCLI *) NULL); |
| 4346 | assert(cli_wand->signature == WandSignature); |
| 4347 | assert(cli_wand->wand.signature == WandSignature); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4348 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4349 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4350 | (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), |
| 4351 | "- NoImage Operator: %s \"%s\" \"%s\"", option,arg1n,arg2n); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4352 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4353 | arg1 = arg1n; |
| 4354 | arg2 = arg2n; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4355 | |
| 4356 | /* Interpret Percent Escapes in Arguments - using first image */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4357 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 4358 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 4359 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 4360 | /* Interpret Percent escapes in argument 1 */ |
| 4361 | if (arg1n != (char *) NULL) { |
| 4362 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 4363 | if (arg1 == (char *) NULL) { |
| 4364 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 4365 | arg1=arg1n; /* use the given argument as is */ |
| 4366 | } |
| 4367 | } |
| 4368 | if (arg2n != (char *) NULL) { |
| 4369 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4370 | if (arg2 == (char *) NULL) { |
| 4371 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 4372 | arg2=arg2n; /* use the given argument as is */ |
| 4373 | } |
| 4374 | } |
| 4375 | } |
| 4376 | #undef _process_flags |
| 4377 | #undef _option_type |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4378 | |
| 4379 | do { /* break to exit code */ |
| 4380 | /* |
| 4381 | No-op options (ignore these) |
| 4382 | */ |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4383 | if (LocaleCompare("noop",option+1) == 0) /* zero argument */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4384 | break; |
| 4385 | if (LocaleCompare("sans",option+1) == 0) /* one argument */ |
| 4386 | break; |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4387 | if (LocaleCompare("sans0",option+1) == 0) /* zero argument */ |
| 4388 | break; |
| 4389 | if (LocaleCompare("sans1",option+1) == 0) /* one argument */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4390 | break; |
| 4391 | if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ |
| 4392 | break; |
| 4393 | /* |
| 4394 | Image Reading |
| 4395 | */ |
| 4396 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
| 4397 | ( LocaleCompare("--",option) == 0 ) ) { |
| 4398 | /* Do Glob filename Expansion for 'arg1' then read all images. |
| 4399 | * |
| 4400 | * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring |
| 4401 | * (but attaching to the filenames in the generated argument list) any |
| 4402 | * [...] read modifiers that may be present. |
| 4403 | * |
| 4404 | * For example: It will expand '*.gif[20x20]' into a list such as |
| 4405 | * 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]' |
| 4406 | * |
| 4407 | * NOTE: In IMv6 this was done globally across all images. This |
| 4408 | * meant you could include IM options in '@filename' lists, but you |
| 4409 | * could not include comments. Doing it only for image read makes |
| 4410 | * it far more secure. |
| 4411 | * |
| 4412 | * Note: arguments do not have percent escapes expanded for security |
| 4413 | * reasons. |
| 4414 | */ |
| 4415 | int argc; |
| 4416 | char **argv; |
| 4417 | ssize_t i; |
| 4418 | |
| 4419 | argc = 1; |
| 4420 | argv = (char **) &arg1; |
| 4421 | |
| 4422 | /* Expand 'glob' expressions in the given filename. |
| 4423 | Expansion handles any 'coder:' prefix, or read modifiers attached |
| 4424 | to the filename, including them in the resulting expanded list. |
| 4425 | */ |
| 4426 | if (IfMagickFalse( ExpandFilenames(&argc,&argv) )) |
| 4427 | CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed", |
| 4428 | option,GetExceptionMessage(errno)); |
| 4429 | |
| 4430 | /* loop over expanded filename list, and read then all in */ |
| 4431 | for (i=0; i<argc; i++) { |
| 4432 | Image * |
| 4433 | new_images; |
| 4434 | if (IfMagickTrue(_image_info->ping)) |
| 4435 | new_images=PingImages(_image_info,argv[i],_exception); |
| 4436 | else |
| 4437 | new_images=ReadImages(_image_info,argv[i],_exception); |
| 4438 | AppendImageToList(&_images, new_images); |
| 4439 | } |
| 4440 | argv=DestroyStringList(argv); /* Destroy the Expanded Filename list */ |
| 4441 | break; |
| 4442 | } |
| 4443 | /* |
| 4444 | Image Writing |
| 4445 | Note: Writing a empty image list is valid in specific cases |
| 4446 | */ |
| 4447 | if (LocaleCompare("write",option+1) == 0) { |
| 4448 | /* Note: arguments do not have percent escapes expanded */ |
| 4449 | char |
| 4450 | key[MaxTextExtent]; |
| 4451 | |
| 4452 | Image |
| 4453 | *write_images; |
| 4454 | |
| 4455 | ImageInfo |
| 4456 | *write_info; |
| 4457 | |
| 4458 | /* Need images, unless a "null:" output coder is used */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4459 | if ( _images == (Image *) NULL ) { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4460 | if ( LocaleCompare(arg1,"null:") == 0 ) |
| 4461 | break; |
| 4462 | CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1); |
| 4463 | } |
| 4464 | |
| 4465 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
| 4466 | (void) DeleteImageRegistry(key); |
| 4467 | write_images=_images; |
| 4468 | if (IfPlusOp) |
| 4469 | write_images=CloneImageList(_images,_exception); |
| 4470 | write_info=CloneImageInfo(_image_info); |
| 4471 | (void) WriteImages(write_info,write_images,arg1,_exception); |
| 4472 | write_info=DestroyImageInfo(write_info); |
| 4473 | if (IfPlusOp) |
| 4474 | write_images=DestroyImageList(write_images); |
| 4475 | break; |
| 4476 | } |
| 4477 | /* |
| 4478 | Parenthesis and Brace operations |
| 4479 | */ |
| 4480 | if (LocaleCompare("(",option) == 0) { |
| 4481 | /* stack 'push' images */ |
| 4482 | Stack |
| 4483 | *node; |
| 4484 | |
| 4485 | size_t |
| 4486 | size; |
| 4487 | |
| 4488 | size=0; |
| 4489 | node=cli_wand->image_list_stack; |
| 4490 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4491 | size++; |
| 4492 | if ( size >= MAX_STACK_DEPTH ) |
| 4493 | CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option); |
| 4494 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4495 | if (node == (Stack *) NULL) |
| 4496 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 4497 | "MemoryAllocationFailed",option); |
| 4498 | node->data = (void *)cli_wand->wand.images; |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4499 | node->next = cli_wand->image_list_stack; |
| 4500 | cli_wand->image_list_stack = node; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4501 | cli_wand->wand.images = NewImageList(); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4502 | |
| 4503 | /* handle respect-parenthesis */ |
| 4504 | if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info, |
| 4505 | "respect-parenthesis")))) |
| 4506 | option="{"; /* fall-thru so as to push image settings too */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4507 | else |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4508 | break; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4509 | /* fall thru to operation */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4510 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4511 | if (LocaleCompare("{",option) == 0) { |
| 4512 | /* stack 'push' of image_info settings */ |
| 4513 | Stack |
| 4514 | *node; |
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_t |
| 4517 | size; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4518 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4519 | size=0; |
| 4520 | node=cli_wand->image_info_stack; |
| 4521 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4522 | size++; |
| 4523 | if ( size >= MAX_STACK_DEPTH ) |
| 4524 | CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option); |
| 4525 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4526 | if (node == (Stack *) NULL) |
| 4527 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 4528 | "MemoryAllocationFailed",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4529 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4530 | node->data = (void *)cli_wand->wand.image_info; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4531 | node->next = cli_wand->image_info_stack; |
| 4532 | |
| 4533 | cli_wand->image_info_stack = node; |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4534 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
| 4535 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
| 4536 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4537 | option); |
| 4538 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4539 | node = (Stack *)RelinquishMagickMemory(node); |
| 4540 | break; |
| 4541 | } |
| 4542 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4543 | break; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4544 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4545 | if (LocaleCompare(")",option) == 0) { |
| 4546 | /* pop images from stack */ |
| 4547 | Stack |
| 4548 | *node; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4549 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4550 | node = (Stack *)cli_wand->image_list_stack; |
| 4551 | if ( node == (Stack *)NULL) |
| 4552 | CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option); |
| 4553 | cli_wand->image_list_stack = node->next; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4554 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4555 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4556 | cli_wand->wand.images= (Image *)node->data; |
| 4557 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4558 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4559 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
| 4560 | node = cli_wand->image_info_stack; |
| 4561 | if ( node != (Stack *)NULL) |
| 4562 | { |
| 4563 | if (IfMagickTrue(IsStringTrue(GetImageOption( |
| 4564 | cli_wand->wand.image_info,"respect-parenthesis")))) |
| 4565 | option="}"; /* fall-thru so as to pop image settings too */ |
| 4566 | else |
| 4567 | break; |
| 4568 | } |
| 4569 | else |
| 4570 | break; |
| 4571 | /* fall thru to next if */ |
| 4572 | } |
| 4573 | if (LocaleCompare("}",option) == 0) { |
| 4574 | /* pop image_info settings from stack */ |
| 4575 | Stack |
| 4576 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4577 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4578 | node = (Stack *)cli_wand->image_info_stack; |
| 4579 | if ( node == (Stack *)NULL) |
| 4580 | CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option); |
| 4581 | cli_wand->image_info_stack = node->next; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4582 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4583 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4584 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4585 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4586 | |
| 4587 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4588 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4589 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4590 | |
| 4591 | break; |
| 4592 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4593 | if (LocaleCompare("print",option+1) == 0) |
| 4594 | { |
| 4595 | (void) FormatLocaleFile(stdout,"%s",arg1); |
| 4596 | break; |
| 4597 | } |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4598 | if (LocaleCompare("set",option+1) == 0) |
| 4599 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4600 | /* Settings are applied to each image in memory in turn (if any). |
| 4601 | While a option: only need to be applied once globally. |
| 4602 | |
| 4603 | NOTE: rguments have not been automatically percent expaneded |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4604 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4605 | |
| 4606 | /* escape the 'key' once only, using first image. */ |
| 4607 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 4608 | if (arg1 == (char *) NULL) |
| 4609 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 4610 | option); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4611 | |
| 4612 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 4613 | { |
| 4614 | if (IfPlusOp) |
| 4615 | { |
| 4616 | (void) DeleteImageRegistry(arg1+9); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4617 | arg1=DestroyString((char *)arg1); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4618 | break; |
| 4619 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4620 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4621 | if (arg2 == (char *) NULL) { |
| 4622 | arg1=DestroyString((char *)arg1); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4623 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 4624 | option); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4625 | } |
| 4626 | (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception); |
| 4627 | arg1=DestroyString((char *)arg1); |
| 4628 | arg2=DestroyString((char *)arg2); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4629 | break; |
| 4630 | } |
| 4631 | if (LocaleNCompare(arg1,"option:",7) == 0) |
| 4632 | { |
| 4633 | /* delete equivelent artifact from all images (if any) */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4634 | if (_images != (Image *)NULL) |
| 4635 | { |
| 4636 | MagickResetIterator(&cli_wand->wand); |
| 4637 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
| 4638 | (void) DeleteImageArtifact(_images,arg1+7); |
| 4639 | MagickResetIterator(&cli_wand->wand); |
| 4640 | } |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4641 | /* now set/delete the global option as needed */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4642 | /* FUTURE: make escapes in a global 'option:' delayed */ |
| 4643 | arg2=(char *)NULL; |
| 4644 | if (IfNormalOp) |
| 4645 | { |
| 4646 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4647 | if (arg2 == (char *) NULL) |
| 4648 | CLIWandExceptionBreak(OptionWarning, |
| 4649 | "InterpretPropertyFailure",option); |
| 4650 | } |
| 4651 | (void) SetImageOption(_image_info,arg1+7,arg2); |
| 4652 | arg1=DestroyString((char *)arg1); |
| 4653 | arg2=DestroyString((char *)arg2); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4654 | break; |
| 4655 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4656 | /* Set Artifacts/Properties/Attributes all images (required) */ |
| 4657 | if ( _images == (Image *) NULL ) |
| 4658 | CLIWandExceptArgBreak(OptionWarning,"NoImageForProperty",option,arg1); |
| 4659 | |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4660 | MagickResetIterator(&cli_wand->wand); |
| 4661 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
| 4662 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4663 | arg2=(char *)NULL; |
| 4664 | if (IfNormalOp) |
| 4665 | { |
| 4666 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4667 | if (arg2 == (char *) NULL) |
| 4668 | CLIWandExceptionBreak(OptionWarning, |
| 4669 | "InterpretPropertyFailure",option); |
| 4670 | } |
| 4671 | if (LocaleNCompare(arg1,"artifact:",9) == 0) |
| 4672 | (void) SetImageArtifact(_images,arg1+9,arg2); |
| 4673 | else if (LocaleNCompare(arg1,"property:",9) == 0) |
| 4674 | (void) SetImageProperty(_images,arg1+9,arg2,_exception); |
| 4675 | else |
| 4676 | (void) SetImageProperty(_images,arg1,arg2,_exception); |
| 4677 | arg2=DestroyString((char *)arg2); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4678 | } |
| 4679 | MagickResetIterator(&cli_wand->wand); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4680 | arg1=DestroyString((char *)arg1); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4681 | break; |
| 4682 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4683 | if (LocaleCompare("clone",option+1) == 0) { |
| 4684 | Image |
| 4685 | *new_images; |
| 4686 | |
| 4687 | if (*option == '+') |
| 4688 | arg1="-1"; |
| 4689 | if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse))) |
| 4690 | CLIWandExceptionBreak(OptionError,"InvalidArgument",option); |
| 4691 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
| 4692 | CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); |
| 4693 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4694 | if (new_images == (Image *) NULL) |
| 4695 | CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); |
| 4696 | new_images=CloneImages(new_images,arg1,_exception); |
| 4697 | if (new_images == (Image *) NULL) |
| 4698 | CLIWandExceptionBreak(OptionError,"NoSuchImage",option); |
| 4699 | AppendImageToList(&_images,new_images); |
| 4700 | break; |
| 4701 | } |
| 4702 | /* |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4703 | Informational Operations. |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4704 | |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4705 | Note that these do not require either a cli-wand or images! |
| 4706 | Though currently a cli-wand much be provided regardless. |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4707 | */ |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4708 | if (LocaleCompare("version",option+1) == 0) |
| 4709 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 4710 | ListMagickVersion(stdout); |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4711 | break; |
| 4712 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4713 | if (LocaleCompare("list",option+1) == 0) { |
| 4714 | /* |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4715 | FUTURE: This 'switch' should really be part of MagickCore |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4716 | */ |
| 4717 | ssize_t |
| 4718 | list; |
| 4719 | |
| 4720 | list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); |
| 4721 | if ( list < 0 ) { |
| 4722 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
| 4723 | break; |
| 4724 | } |
| 4725 | switch (list) |
| 4726 | { |
| 4727 | case MagickCoderOptions: |
| 4728 | { |
| 4729 | (void) ListCoderInfo((FILE *) NULL,_exception); |
| 4730 | break; |
| 4731 | } |
| 4732 | case MagickColorOptions: |
| 4733 | { |
| 4734 | (void) ListColorInfo((FILE *) NULL,_exception); |
| 4735 | break; |
| 4736 | } |
| 4737 | case MagickConfigureOptions: |
| 4738 | { |
| 4739 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
| 4740 | break; |
| 4741 | } |
| 4742 | case MagickDelegateOptions: |
| 4743 | { |
| 4744 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
| 4745 | break; |
| 4746 | } |
| 4747 | case MagickFontOptions: |
| 4748 | { |
| 4749 | (void) ListTypeInfo((FILE *) NULL,_exception); |
| 4750 | break; |
| 4751 | } |
| 4752 | case MagickFormatOptions: |
| 4753 | (void) ListMagickInfo((FILE *) NULL,_exception); |
| 4754 | break; |
| 4755 | case MagickLocaleOptions: |
| 4756 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
| 4757 | break; |
| 4758 | case MagickLogOptions: |
| 4759 | (void) ListLogInfo((FILE *) NULL,_exception); |
| 4760 | break; |
| 4761 | case MagickMagicOptions: |
| 4762 | (void) ListMagicInfo((FILE *) NULL,_exception); |
| 4763 | break; |
| 4764 | case MagickMimeOptions: |
| 4765 | (void) ListMimeInfo((FILE *) NULL,_exception); |
| 4766 | break; |
| 4767 | case MagickModuleOptions: |
| 4768 | (void) ListModuleInfo((FILE *) NULL,_exception); |
| 4769 | break; |
| 4770 | case MagickPolicyOptions: |
| 4771 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
| 4772 | break; |
| 4773 | case MagickResourceOptions: |
| 4774 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
| 4775 | break; |
| 4776 | case MagickThresholdOptions: |
| 4777 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
| 4778 | break; |
| 4779 | default: |
| 4780 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
| 4781 | _exception); |
| 4782 | break; |
| 4783 | } |
| 4784 | break; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4785 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4786 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4787 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4788 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4789 | } while (0); /* break to exit code. */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4790 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4791 | /* clean up percent escape interpreted strings */ |
| 4792 | if (arg1 != arg1n ) |
| 4793 | arg1=DestroyString((char *)arg1); |
| 4794 | if (arg2 != arg2n ) |
| 4795 | arg2=DestroyString((char *)arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4796 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4797 | #undef _image_info |
| 4798 | #undef _images |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4799 | #undef _exception |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4800 | #undef IfNormalOp |
| 4801 | #undef IfPlusOp |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4802 | } |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4803 | |
| 4804 | /* |
| 4805 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4806 | % % |
| 4807 | % % |
| 4808 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4809 | + C L I O p t i o n % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4810 | % % |
| 4811 | % % |
| 4812 | % % |
| 4813 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4814 | % |
| 4815 | % CLIOption() Processes the given option using the given CLI Magick Wand. |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4816 | % The option arguments can be variable in number, though at this time no more |
| 4817 | % that two is actually used by any option (this may change). Excess options |
| 4818 | % are simply ignored. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4819 | % |
| 4820 | % If the cli_wand->command pointer is non-null, then it is assumed that the |
| 4821 | % option has already been search for up from the CommandOptions[] table in |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4822 | % "MagickCore/options.c" using GetCommandOptionInfo(). If not set this |
| 4823 | % routine will do the lookup instead. The pointer is reset afterward. |
| 4824 | % |
| 4825 | % This action allows the caller to lookup and pre-handle any 'special' |
| 4826 | % options, (such as implicit reads) before calling this general option |
| 4827 | % handler to deal with 'standard' command line options. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4828 | % |
| 4829 | % The format of the CLIOption method is: |
| 4830 | % |
| 4831 | % void CLIOption(MagickCLI *cli_wand,const char *option, ...) |
| 4832 | % |
| 4833 | % A description of each parameter follows: |
| 4834 | % |
| 4835 | % o cli_wand: the main CLI Wand to use. |
| 4836 | % |
| 4837 | % o option: The special option (with any switch char) to process |
| 4838 | % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4839 | % o args: any required arguments for an option (variable number) |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4840 | % |
| 4841 | % Example Usage... |
| 4842 | % |
| 4843 | % CLIoption(cli_wand,"-read","rose:"); |
| 4844 | % CLIoption(cli_wand,"-virtual-pixel","transparent"); |
| 4845 | % CLIoption(cli_wand,"-distort","SRT:","30"); |
| 4846 | % CLIoption(cli_wand,"-write","rotated_rose.png"); |
| 4847 | % |
| 4848 | */ |
| 4849 | WandExport void CLIOption(MagickCLI *cli_wand,const char *option,...) |
| 4850 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4851 | const char /* extracted option args from args */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4852 | *arg1, |
| 4853 | *arg2; |
| 4854 | |
| 4855 | CommandOptionFlags |
| 4856 | option_type; |
| 4857 | |
| 4858 | assert(cli_wand != (MagickCLI *) NULL); |
| 4859 | assert(cli_wand->signature == WandSignature); |
| 4860 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4861 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4862 | do { /* Break Code Block for error handling */ |
| 4863 | |
| 4864 | /* get information about option */ |
| 4865 | if ( cli_wand->command == (const OptionInfo *) NULL ) |
| 4866 | cli_wand->command = GetCommandOptionInfo(option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4867 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4868 | (void) FormatLocaleFile(stderr, "CLIOption \"%s\" matched \"%s\"\n", |
| 4869 | option, cli_wand->command->mnemonic ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4870 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4871 | option_type=(CommandOptionFlags) cli_wand->command->flags; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4872 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4873 | if ( option_type == UndefinedOptionFlag ) |
| 4874 | CLIWandExceptionReturn(OptionFatalError,"UnrecognizedOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4875 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4876 | assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4877 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4878 | /* depreciated options */ |
| 4879 | if ( (option_type & DeprecateOptionFlag) != 0 ) |
| 4880 | CLIWandExceptionBreak(OptionError,"DeprecatedOptionNoCode",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4881 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4882 | /* options that this module does not handle */ |
| 4883 | if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) |
| 4884 | CLIWandExceptionBreak(OptionFatalError,"InvalidUseOfOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4885 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4886 | /* Get argument strings from VarArgs |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4887 | How can you determine if enough arguments was supplied? |
| 4888 | What happens if not enough arguments were supplied? |
| 4889 | */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4890 | { size_t |
| 4891 | count = cli_wand->command->type; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4892 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4893 | va_list |
| 4894 | operands; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4895 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4896 | va_start(operands,option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4897 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4898 | arg1=arg2=NULL; |
| 4899 | if ( count >= 1 ) |
| 4900 | arg1=(const char *) va_arg(operands, const char *); |
| 4901 | if ( count >= 2 ) |
| 4902 | arg2=(const char *) va_arg(operands, const char *); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4903 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4904 | va_end(operands); |
anthony | 52cb3df | 2012-04-24 03:29:32 +0000 | [diff] [blame] | 4905 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4906 | (void) FormatLocaleFile(stderr, |
| 4907 | "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n", |
| 4908 | option,(long) count,option_type,arg1,arg2); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4909 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4910 | } |
| 4911 | |
| 4912 | /* |
| 4913 | Call the appropriate option handler |
| 4914 | */ |
| 4915 | |
| 4916 | /* FUTURE: this is temporary - get 'settings' to handle distribution of |
| 4917 | settings to images attributes,proprieties,artifacts */ |
| 4918 | if ( cli_wand->wand.images != (Image *)NULL ) |
| 4919 | SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, |
| 4920 | cli_wand->wand.exception); |
| 4921 | |
| 4922 | if ( (option_type & SettingOptionFlags) != 0 ) { |
| 4923 | CLISettingOptionInfo(cli_wand, option, arg1, arg2); |
| 4924 | // FUTURE: Sync Specific Settings into Image Properities (not global) |
| 4925 | } |
| 4926 | |
| 4927 | /* Operators that do not need images - read, write, stack, clone */ |
| 4928 | if ( (option_type & NoImageOperatorFlag) != 0) |
| 4929 | CLINoImageOperator(cli_wand, option, arg1, arg2); |
| 4930 | |
| 4931 | /* FUTURE: The not a setting part below is a temporary hack due to |
| 4932 | * some options being both a Setting and a Simple operator. |
| 4933 | * Specifically -monitor, -depth, and -colorspace */ |
| 4934 | if ( cli_wand->wand.images == (Image *)NULL ) |
| 4935 | if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) && |
| 4936 | ((option_type & SettingOptionFlags) == 0 )) /* temp hack */ |
| 4937 | CLIWandExceptionBreak(OptionError,"NoImagesFound",option); |
| 4938 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame^] | 4939 | /* Operators which loop of individual images, simply */ |
| 4940 | if ( (option_type & SimpleOperatorFlag) != 0 && |
| 4941 | cli_wand->wand.images != (Image *)NULL) /* temp hack */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4942 | CLISimpleOperatorImages(cli_wand, option, arg1, arg2); |
| 4943 | |
| 4944 | /* Operators that work on the image list as a whole */ |
| 4945 | if ( (option_type & ListOperatorFlag) != 0 ) |
| 4946 | CLIListOperatorImages(cli_wand, option, arg1, arg2); |
| 4947 | |
| 4948 | } while (0); /* end Break code block */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4949 | |
| 4950 | cli_wand->command = (const OptionInfo *) NULL; /* prevent re-use later */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4951 | } |