anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 6 | % OOO PPPP EEEE RRRR AA TTTTT III OOO N N % |
| 7 | % O O P P E R R A A T I O O NN N % |
| 8 | % O O PPPP EEE RRRR AAAA T I O O N N N % |
| 9 | % O O P E R R A A T I O O N NN % |
| 10 | % OOO P EEEE R RR A A T III OOO N N % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 11 | % % |
| 12 | % % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 13 | % CLI Magick Option Methods % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 14 | % % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 15 | % Dragon Computing % |
cristy | 9e58efd | 2012-01-30 14:27:34 +0000 | [diff] [blame] | 16 | % Anthony Thyssen % |
cristy | 0a0ca4f | 2011-09-28 01:15:28 +0000 | [diff] [blame] | 17 | % September 2011 % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 18 | % % |
| 19 | % % |
cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Apply the given options (settings, and simple, or sequence operations) to |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 37 | % the given image(s) according to the current "image_info", "draw_info", and |
| 38 | % "quantize_info" settings, stored in a special CLI Image Wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 39 | % |
| 40 | % The final goal is to allow the execution in a strict one option at a time |
| 41 | % manner that is needed for 'pipelining and file scripting' of options in |
| 42 | % IMv7. |
| 43 | % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 44 | % Anthony Thyssen, September 2011 |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 45 | */ |
| 46 | |
| 47 | /* |
| 48 | Include declarations. |
| 49 | */ |
| 50 | #include "MagickWand/studio.h" |
| 51 | #include "MagickWand/MagickWand.h" |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 52 | #include "MagickWand/magick-wand-private.h" |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 53 | #include "MagickWand/wand.h" |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 54 | #include "MagickWand/wandcli.h" |
| 55 | #include "MagickWand/wandcli-private.h" |
| 56 | #include "MagickWand/operation.h" |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 57 | #include "MagickCore/monitor-private.h" |
| 58 | #include "MagickCore/thread-private.h" |
| 59 | #include "MagickCore/string-private.h" |
| 60 | |
| 61 | /* |
| 62 | Define declarations. |
| 63 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 64 | #define USE_WAND_METHODS 0 |
| 65 | #define MAX_STACK_DEPTH 32 |
| 66 | #define UNDEFINED_COMPRESSION_QUALITY 0UL |
| 67 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 68 | /* FUTURE: why is this default so specific? */ |
| 69 | #define DEFAULT_DISSIMILARITY_THRESHOLD "0.31830988618379067154" |
| 70 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 71 | /* |
| 72 | Constant declaration. (temporary exports) |
| 73 | */ |
| 74 | static const char |
| 75 | BackgroundColor[] = "#fff", /* white */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 76 | BorderColor[] = "#dfdfdf", /* sRGB gray */ |
| 77 | MatteColor[] = "#bdbdbd"; /* slightly darker gray */ |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 78 | |
| 79 | /* For Debugging Geometry Input */ |
| 80 | #define ReportGeometry(flags,info) \ |
| 81 | (void) FormatLocaleFile(stderr, "Geometry = 0x%04X : %lg x %lg %+lg %+lg\n", \ |
| 82 | flags, info.rho, info.sigma, info.xi, info.psi ) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 83 | |
| 84 | /* |
| 85 | ** Function to report on the progress of image operations |
| 86 | */ |
| 87 | static MagickBooleanType MonitorProgress(const char *text, |
| 88 | const MagickOffsetType offset,const MagickSizeType extent, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 89 | void *wand_unused(cli_wandent_data)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 90 | { |
| 91 | char |
| 92 | message[MaxTextExtent], |
| 93 | tag[MaxTextExtent]; |
| 94 | |
| 95 | const char |
| 96 | *locale_message; |
| 97 | |
| 98 | register char |
| 99 | *p; |
| 100 | |
| 101 | if (extent < 2) |
| 102 | return(MagickTrue); |
| 103 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 104 | p=strrchr(tag,'/'); |
| 105 | if (p != (char *) NULL) |
| 106 | *p='\0'; |
| 107 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
| 108 | locale_message=GetLocaleMessage(message); |
| 109 | if (locale_message == message) |
| 110 | locale_message=tag; |
| 111 | if (p == (char *) NULL) |
| 112 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 113 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 114 | (100L*offset/(extent-1))); |
| 115 | else |
| 116 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
| 117 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 118 | (100L*offset/(extent-1))); |
| 119 | if (offset == (MagickOffsetType) (extent-1)) |
| 120 | (void) FormatLocaleFile(stderr,"\n"); |
| 121 | (void) fflush(stderr); |
| 122 | return(MagickTrue); |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | ** GetImageCache() will read an image into a image cache if not already |
| 127 | ** present then return the image that is in the cache under that filename. |
| 128 | */ |
| 129 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 130 | ExceptionInfo *exception) |
| 131 | { |
| 132 | char |
| 133 | key[MaxTextExtent]; |
| 134 | |
| 135 | ExceptionInfo |
| 136 | *sans_exception; |
| 137 | |
| 138 | Image |
| 139 | *image; |
| 140 | |
| 141 | ImageInfo |
| 142 | *read_info; |
| 143 | |
| 144 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
| 145 | sans_exception=AcquireExceptionInfo(); |
| 146 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 147 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 148 | if (image != (Image *) NULL) |
| 149 | return(image); |
| 150 | read_info=CloneImageInfo(image_info); |
| 151 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 152 | image=ReadImage(read_info,exception); |
| 153 | read_info=DestroyImageInfo(read_info); |
| 154 | if (image != (Image *) NULL) |
| 155 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 156 | return(image); |
| 157 | } |
| 158 | |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 159 | /* |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 160 | SparseColorOption() parse the complex -sparse-color argument into an |
| 161 | an array of floating point values than call SparseColorImage(). |
| 162 | Argument is a complex mix of floating-point pixel coodinates, and color |
| 163 | specifications (or direct floating point numbers). The number of floats |
| 164 | needed to represent a color varies depending on teh current channel |
| 165 | setting. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 166 | |
| 167 | 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] | 168 | */ |
| 169 | static Image *SparseColorOption(const Image *image, |
| 170 | const SparseColorMethod method,const char *arguments, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 171 | 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) && |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 219 | IfMagickTrue(image->matte)) |
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) && |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 298 | IfMagickTrue(image->matte)) |
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) && |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 338 | IfMagickTrue(image->matte)) |
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 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 401 | WandExport void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 402 | const char *option,const char *arg1, const char *arg2) |
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 | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 407 | assert(cli_wand != (MagickCLI *) NULL); |
| 408 | assert(cli_wand->signature == WandSignature); |
| 409 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 410 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 411 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 412 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 413 | #define _image_info (cli_wand->wand.image_info) |
| 414 | #define _exception (cli_wand->wand.exception) |
| 415 | #define _draw_info (cli_wand->draw_info) |
| 416 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 417 | #define IfSetOption (*option=='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 418 | #define ArgBoolean IsMagickTrue(IfSetOption) |
| 419 | #define ArgBooleanNot IsMagickFalse(IfSetOption) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 420 | #define ArgBooleanString (IfSetOption?"true":"false") |
| 421 | #define ArgOption(def) (IfSetOption?arg1:(const char *)(def)) |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 422 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 423 | #if 0 |
| 424 | Setting are not directly involved with images, so can not |
| 425 | interpret Percent Escapes in Arguments, At least not yet */ |
| 426 | |
| 427 | #define _process_flags (cli_wand->process_flags) |
| 428 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
| 429 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 430 | arg1 = arg1n, |
| 431 | arg2 = arg2n; |
| 432 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 433 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 434 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 435 | /* Interpret Percent escapes in argument 1 */ |
| 436 | if (arg1n != (char *) NULL) { |
| 437 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 438 | if (arg1 == (char *) NULL) { |
| 439 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 440 | arg1=arg1n; /* use the given argument as is */ |
| 441 | } |
| 442 | } |
| 443 | if (arg2n != (char *) NULL) { |
| 444 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 445 | if (arg2 == (char *) NULL) { |
| 446 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 447 | arg2=arg2n; /* use the given argument as is */ |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | #undef _process_flags |
| 452 | #undef _option_type |
| 453 | #endif |
| 454 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 455 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 456 | { |
| 457 | case 'a': |
| 458 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 459 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 460 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 461 | _image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 462 | break; |
| 463 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 464 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 465 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 466 | CLIWandWarnReplaced("-draw 'affine ...'"); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 467 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 468 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 469 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 470 | GetAffineMatrix(&_draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 471 | break; |
| 472 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 473 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 474 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 475 | _image_info->antialias = |
| 476 | _draw_info->stroke_antialias = |
| 477 | _draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 478 | break; |
| 479 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 480 | if (LocaleCompare("attenuate",option+1) == 0) |
| 481 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 482 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 483 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 484 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 485 | break; |
| 486 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 487 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 488 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 489 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 490 | break; |
| 491 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 492 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 493 | } |
| 494 | case 'b': |
| 495 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 496 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 497 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 498 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 499 | _image_info only used directly for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 500 | SyncImageSettings() used to set per-image attribute. |
| 501 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 502 | FUTURE: if _image_info->background_color is not set then |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 503 | we should fall back to per-image background_color |
| 504 | |
| 505 | At this time -background will 'wipe out' the per-image |
| 506 | background color! |
| 507 | |
| 508 | Better error handling of QueryColorCompliance() needed. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 509 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 510 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 511 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 512 | &_image_info->background_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 513 | break; |
| 514 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 515 | if (LocaleCompare("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 516 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 517 | /* FUTURE: bias OBSOLETED, replaced by Artifact "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 518 | as it is actually rarely used except in direct convolve operations |
| 519 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 520 | |
| 521 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 522 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 523 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 524 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 525 | (void) SetImageOption(_image_info,"convolve:bias",ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 526 | break; |
| 527 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 528 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 529 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 530 | /* Used as a image chromaticity setting |
| 531 | SyncImageSettings() used to set per-image attribute. |
| 532 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 533 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 534 | break; |
| 535 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 536 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 537 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 538 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 539 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 540 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 541 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 542 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 543 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 544 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 545 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 546 | break; |
| 547 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 548 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 549 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 550 | /* FUTURE: both _image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 551 | SyncImageSettings() used to set per-image attribute. |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 552 | Better error checking of QueryColorCompliance(). |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 553 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 554 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 555 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 556 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 557 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 558 | &_image_info->border_color,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 559 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 560 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 561 | break; |
| 562 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 563 | (void) DeleteImageOption(_image_info,option+1); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 564 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 565 | &_image_info->border_color,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 566 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 567 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 568 | break; |
| 569 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 570 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 571 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 572 | CLIWandWarnReplaced("-undercolor"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 573 | CLISettingOptionInfo(cli_wand,"-undercolor",arg1, arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 574 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 575 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 576 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 577 | } |
| 578 | case 'c': |
| 579 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 580 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 581 | { |
| 582 | MagickSizeType |
| 583 | limit; |
| 584 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 585 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 586 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 587 | limit=MagickResourceInfinity; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 588 | if (LocaleCompare("unlimited",arg1) != 0) |
| 589 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 590 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 591 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 592 | break; |
| 593 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 594 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 595 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 596 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 597 | break; |
| 598 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 599 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 600 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 601 | arg1=ArgOption("default"); |
| 602 | parse=ParseChannelOption(arg1); |
| 603 | if (parse < 0) |
| 604 | CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType", |
| 605 | option,arg1); |
| 606 | _image_info->channel=(ChannelType) parse; |
| 607 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 608 | break; |
| 609 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 610 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 611 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 612 | /* Setting used for new images via AquireImage() |
| 613 | But also used as a SimpleImageOperator |
| 614 | Undefined colorspace means don't modify images on |
| 615 | read or as a operation */ |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 616 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 617 | ArgOption("undefined")); |
| 618 | if (parse < 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 619 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 620 | option,arg1); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 621 | _image_info->colorspace=(ColorspaceType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 622 | break; |
| 623 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 624 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 625 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 626 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
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("compose",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 | /* FUTURE: _image_info should be used, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 632 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 633 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 634 | This setting should NOT be used to set image 'compose' |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 635 | "-layer" operators shoud use _image_info if defined otherwise |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 636 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 637 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 638 | parse = ParseCommandOption(MagickComposeOptions,MagickFalse, |
| 639 | ArgOption("undefined")); |
| 640 | if (parse < 0) |
| 641 | CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", |
| 642 | option,arg1); |
| 643 | _image_info->compose=(CompositeOperator) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 644 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 645 | break; |
| 646 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 647 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 648 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 649 | /* FUTURE: What should be used? _image_info or ImageOption ??? |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 650 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 651 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 652 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 653 | The coders appears to use _image_info, not Image_Option |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 654 | however the image attribute (for save) is set from the |
| 655 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 656 | |
| 657 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 658 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 659 | parse = ParseCommandOption(MagickCompressOptions,MagickFalse, |
| 660 | ArgOption("undefined")); |
| 661 | if (parse < 0) |
| 662 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", |
| 663 | option,arg1); |
| 664 | _image_info->compression=(CompressionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 665 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 666 | break; |
| 667 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 668 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 669 | } |
| 670 | case 'd': |
| 671 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 672 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 673 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 674 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 675 | arg1=ArgOption("none"); |
| 676 | parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); |
| 677 | if (parse < 0) |
| 678 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", |
| 679 | option,arg1); |
| 680 | (void) SetLogEventMask(arg1); |
| 681 | _image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 682 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 683 | break; |
| 684 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 685 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 686 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 687 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 688 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 689 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 690 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 691 | else |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 692 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 693 | break; |
| 694 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 695 | /* DefineImageOption() equals SetImageOption() but with '=' */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 696 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 697 | (void) DefineImageOption(_image_info,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 698 | else if (IsMagickFalse(DeleteImageOption(_image_info,arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 699 | CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 700 | break; |
| 701 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 702 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 703 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 704 | /* Only used for new images via AcquireImage() |
| 705 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 706 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 707 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 708 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 709 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 710 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 711 | break; |
| 712 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 713 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 714 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 715 | /* FUTURE: strings used in _image_info attr and _draw_info! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 716 | Basically as density can be in a XxY form! |
| 717 | |
| 718 | SyncImageSettings() used to set per-image attribute. |
| 719 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 720 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 721 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 722 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 723 | (void) CloneString(&_image_info->density,ArgOption(NULL)); |
| 724 | (void) CloneString(&_draw_info->density,_image_info->density); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 725 | break; |
| 726 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 727 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 728 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 729 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 730 | SyncImageSettings() used to set per-image attribute. |
| 731 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 732 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 733 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 734 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 735 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 736 | break; |
| 737 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 738 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 739 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 740 | /* Image Option is only used to set _draw_info */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 741 | arg1=ArgOption("undefined"); |
| 742 | parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); |
| 743 | if (parse < 0) |
| 744 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", |
| 745 | option,arg1); |
| 746 | _draw_info->direction=(DirectionType) parse; |
| 747 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 748 | break; |
| 749 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 750 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 751 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 752 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); |
| 753 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 754 | break; |
| 755 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 756 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 757 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 758 | /* only used in setting new images */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 759 | arg1=ArgOption("undefined"); |
| 760 | parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); |
| 761 | if (parse < 0) |
| 762 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", |
| 763 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 764 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 765 | break; |
| 766 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 767 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 768 | { |
| 769 | /* FUTURE: this is only used by CompareImages() which is used |
| 770 | only by the "compare" CLI program at this time. */ |
| 771 | arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD); |
| 772 | if (IfMagickFalse(IsGeometry(arg1))) |
| 773 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 774 | (void) SetImageOption(_image_info,option+1,arg1); |
| 775 | break; |
| 776 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 777 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 778 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 779 | /* _image_info attr (on/off), _quantize_info attr (on/off) |
| 780 | but also ImageInfo and _quantize_info method! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 781 | FUTURE: merge the duality of the dithering options |
| 782 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 783 | _image_info->dither = _quantize_info->dither = ArgBoolean; |
| 784 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); |
| 785 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 786 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 787 | if (_quantize_info->dither_method == NoDitherMethod) |
| 788 | _image_info->dither = _quantize_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 789 | break; |
| 790 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 791 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 792 | } |
| 793 | case 'e': |
| 794 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 795 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 796 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 797 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); |
| 798 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 799 | break; |
| 800 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 801 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 802 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 803 | /* Both _image_info attr and ImageInfo */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 804 | arg1 = ArgOption("undefined"); |
| 805 | parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); |
| 806 | if (parse < 0) |
| 807 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", |
| 808 | option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 809 | /* FUTURE: check alloc/free of endian string! - remove? */ |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 810 | _image_info->endian=(EndianType) (*arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 811 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 812 | break; |
| 813 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 814 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 815 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 816 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 817 | break; |
| 818 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 819 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 820 | } |
| 821 | case 'f': |
| 822 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 823 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 824 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 825 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 826 | break; |
| 827 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 828 | if (LocaleCompare("fill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 829 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 830 | /* Set "fill" OR "fill-pattern" in _draw_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 831 | The original fill color is preserved if a fill-pattern is given. |
| 832 | That way it does not effect other operations that directly using |
| 833 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 834 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 835 | MagickBooleanType |
| 836 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 837 | |
| 838 | ExceptionInfo |
| 839 | *sans; |
| 840 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 841 | PixelInfo |
| 842 | color; |
| 843 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 844 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 845 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 846 | if (_draw_info->fill_pattern != (Image *) NULL) |
| 847 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 848 | |
| 849 | /* is it a color or a image? -- ignore exceptions */ |
| 850 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 851 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 852 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 853 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 854 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 855 | _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 856 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 857 | _draw_info->fill=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 858 | break; |
| 859 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 860 | if (LocaleCompare("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 861 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 862 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 863 | arg1 = ArgOption("undefined"); |
| 864 | parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); |
| 865 | if (parse < 0) |
| 866 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", |
| 867 | option,arg1); |
| 868 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 869 | break; |
| 870 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 871 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 872 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 873 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); |
| 874 | (void) CloneString(&_image_info->font,_draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 875 | break; |
| 876 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 877 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 878 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 879 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 880 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 881 | register const char |
| 882 | *q; |
| 883 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 884 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 885 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 886 | _image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 887 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 888 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 889 | break; |
| 890 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 891 | if (LocaleCompare("fuzz",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 892 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 893 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 894 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 895 | SyncImageSettings() used to set per-image attribute. |
| 896 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 897 | FUTURE: Can't find anything else using _image_info->fuzz directly! |
| 898 | remove direct sttribute from image_info |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 899 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 900 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 901 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 902 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 903 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 904 | QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 905 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 906 | break; |
| 907 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 908 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 909 | } |
| 910 | case 'g': |
| 911 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 912 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 913 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 914 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 915 | arg1 = ArgOption("none"); |
| 916 | parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); |
| 917 | if (parse < 0) |
| 918 | CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", |
| 919 | option,arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 920 | _draw_info->gravity=(GravityType) parse; |
anthony | e849097 | 2012-04-03 13:16:01 +0000 | [diff] [blame] | 921 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 922 | break; |
| 923 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 924 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 925 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 926 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 927 | SyncImageSettings() used to set per-image attribute. |
| 928 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 929 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 930 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 931 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 932 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 933 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 934 | break; |
| 935 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 936 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 937 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 938 | case 'h': |
| 939 | { |
| 940 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 941 | { |
| 942 | /* FUTURE: this is only used by CompareImages() which is used |
| 943 | only by the "compare" CLI program at this time. */ |
| 944 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 945 | break; |
| 946 | } |
| 947 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
| 948 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 949 | case 'i': |
| 950 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 951 | if (LocaleCompare("intent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 952 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 953 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 954 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 955 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 956 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 957 | arg1 = ArgOption("indefined"); |
| 958 | parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); |
| 959 | if (parse < 0) |
| 960 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", |
| 961 | option,arg1); |
| 962 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 963 | break; |
| 964 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 965 | if (LocaleCompare("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 966 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 967 | /* _image_info is directly used by coders (so why an image setting?) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 968 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 969 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 970 | arg1 = ArgOption("undefined"); |
| 971 | parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); |
| 972 | if (parse < 0) |
| 973 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", |
| 974 | option,arg1); |
| 975 | _image_info->interlace=(InterlaceType) parse; |
| 976 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 977 | break; |
| 978 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 979 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 980 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 981 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 982 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 983 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 984 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 985 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 986 | break; |
| 987 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 988 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 989 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 990 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 991 | arg1 = ArgOption("undefined"); |
| 992 | parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); |
| 993 | if (parse < 0) |
| 994 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", |
| 995 | option,arg1); |
| 996 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 997 | break; |
| 998 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 999 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1000 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1001 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1002 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1003 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1004 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1005 | break; |
| 1006 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1007 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1008 | } |
| 1009 | case 'k': |
| 1010 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1011 | if (LocaleCompare("kerning",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1012 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1013 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1014 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1015 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1016 | _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1017 | break; |
| 1018 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1019 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1020 | } |
| 1021 | case 'l': |
| 1022 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1023 | if (LocaleCompare("label",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1024 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1025 | /* only used for new images - not in SyncImageOptions() */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1026 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1027 | break; |
| 1028 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1029 | if (LocaleCompare("limit",option+1) == 0) |
| 1030 | { |
| 1031 | MagickSizeType |
| 1032 | limit; |
| 1033 | |
| 1034 | limit=MagickResourceInfinity; |
| 1035 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 1036 | if ( parse < 0 ) |
| 1037 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 1038 | option,arg1); |
| 1039 | if (LocaleCompare("unlimited",arg2) != 0) |
| 1040 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
| 1041 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
| 1042 | break; |
| 1043 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1044 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1045 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1046 | if (IfSetOption) { |
| 1047 | if ((strchr(arg1,'%') == (char *) NULL)) |
| 1048 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1049 | (void) SetLogFormat(arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1050 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1051 | break; |
| 1052 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1053 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1054 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1055 | /* FUTURE: this is only used by CompareImages() which is used |
| 1056 | only by the "compare" CLI program at this time. */ |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1057 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1058 | break; |
| 1059 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1060 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1061 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1062 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1063 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1064 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1065 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1066 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1067 | break; |
| 1068 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1069 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1070 | } |
| 1071 | case 'm': |
| 1072 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1073 | if (LocaleCompare("mattecolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1074 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1075 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1076 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1077 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1078 | &_image_info->matte_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1079 | break; |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1080 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1081 | if (LocaleCompare("metric",option+1) == 0) |
| 1082 | { |
| 1083 | /* FUTURE: this is only used by CompareImages() which is used |
| 1084 | only by the "compare" CLI program at this time. */ |
| 1085 | parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1); |
| 1086 | if ( parse < 0 ) |
| 1087 | CLIWandExceptArgBreak(OptionError,"UnrecognizedMetricType", |
| 1088 | option,arg1); |
| 1089 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1090 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1091 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1092 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1093 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1094 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1095 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1096 | break; |
| 1097 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1098 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1099 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1100 | /* Setting (used by some input coders!) -- why? |
| 1101 | Warning: This is also Special '-type' SimpleOperator |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1102 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1103 | _image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1104 | break; |
| 1105 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1106 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1107 | } |
| 1108 | case 'o': |
| 1109 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1110 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1111 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1112 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1113 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1114 | FUTURE: make set meta-data operator instead. |
| 1115 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1116 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1117 | parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
| 1118 | ArgOption("undefined")); |
| 1119 | if (parse < 0) |
| 1120 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", |
| 1121 | option,arg1); |
| 1122 | _image_info->orientation=(OrientationType)parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1123 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1124 | break; |
| 1125 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1126 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1127 | } |
| 1128 | case 'p': |
| 1129 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1130 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1131 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1132 | /* Only used for new images and image generators. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1133 | SyncImageSettings() used to set per-image attribute. ????? |
| 1134 | That last is WRONG!!!! |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1135 | FUTURE: adjust named 'page' sizes according density |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1136 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1137 | char |
| 1138 | *canonical_page, |
| 1139 | page[MaxTextExtent]; |
| 1140 | |
| 1141 | const char |
| 1142 | *image_option; |
| 1143 | |
| 1144 | MagickStatusType |
| 1145 | flags; |
| 1146 | |
| 1147 | RectangleInfo |
| 1148 | geometry; |
| 1149 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1150 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1151 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1152 | (void) DeleteImageOption(_image_info,option+1); |
| 1153 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1154 | break; |
| 1155 | } |
| 1156 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1157 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1158 | if (image_option != (const char *) NULL) |
| 1159 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1160 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1161 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1162 | canonical_page=DestroyString(canonical_page); |
| 1163 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1164 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1165 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1166 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1167 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1168 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1169 | (void) SetImageOption(_image_info,option+1,page); |
| 1170 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1171 | break; |
| 1172 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1173 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1174 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1175 | _image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1176 | break; |
| 1177 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1178 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1179 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1180 | if (IfSetOption) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1181 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1182 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1183 | _image_info->pointsize = |
| 1184 | _draw_info->pointsize = |
| 1185 | StringToDouble(arg1,(char **) NULL); |
| 1186 | } |
| 1187 | else { |
| 1188 | _image_info->pointsize=0.0; /* unset pointsize */ |
| 1189 | _draw_info->pointsize=12.0; |
| 1190 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1191 | break; |
| 1192 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1193 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1194 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1195 | arg1=ArgOption("-1"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1196 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1197 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1198 | (void) SetMagickPrecision(StringToInteger(arg1)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1199 | break; |
| 1200 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1201 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1202 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1203 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1204 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1205 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1206 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1207 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1208 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1209 | break; |
| 1210 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1211 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1212 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1213 | } |
| 1214 | case 'q': |
| 1215 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1216 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1217 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1218 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1219 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1220 | _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1) |
| 1221 | : UNDEFINED_COMPRESSION_QUALITY; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1222 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1223 | break; |
| 1224 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1225 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1226 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1227 | /* Just a set direct in _quantize_info */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1228 | arg1=ArgOption("undefined"); |
| 1229 | parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
| 1230 | if (parse < 0) |
| 1231 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 1232 | option,arg1); |
| 1233 | _quantize_info->colorspace=(ColorspaceType)parse; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1234 | break; |
| 1235 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1236 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1237 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1238 | /* FUTURE: if two -quiet is performed you can not do +quiet! |
| 1239 | This needs to be checked over thoughly. |
| 1240 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1241 | static WarningHandler |
| 1242 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1243 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1244 | WarningHandler |
| 1245 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1246 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1247 | if ( tmp != (WarningHandler) NULL) |
| 1248 | warning_handler = tmp; /* remember the old handler */ |
| 1249 | if (!IfSetOption) /* set the old handler */ |
| 1250 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1251 | break; |
| 1252 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1253 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1254 | } |
| 1255 | case 'r': |
| 1256 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1257 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1258 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1259 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1260 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1261 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1262 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1263 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1264 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1265 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1266 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1267 | break; |
| 1268 | } |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1269 | if (LocaleCompare("regard-warnings",option+1) == 0) |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 1270 | /* FUTURE: to be replaced by a 'fatal-level' type setting */ |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1271 | break; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1272 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1273 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1274 | /* _draw_info only setting */ |
| 1275 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1276 | break; |
| 1277 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1278 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
| 1279 | { |
| 1280 | /* link image and setting stacks - option is itself saved on stack! */ |
| 1281 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1282 | break; |
| 1283 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1284 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1285 | } |
| 1286 | case 's': |
| 1287 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1288 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1289 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1290 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1291 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1292 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1293 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1294 | break; |
| 1295 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1296 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1297 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1298 | /* SyncImageSettings() used to set this as a per-image attribute. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1299 | What ??? Why ???? |
| 1300 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1301 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1302 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1303 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1304 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1305 | break; |
| 1306 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1307 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1308 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1309 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1310 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame] | 1311 | SetRandomSecretKey( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1312 | IfSetOption ? (size_t) StringToUnsignedLong(arg1) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1313 | : (size_t) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1314 | break; |
| 1315 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1316 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1317 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1318 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1319 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1320 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1321 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1322 | break; |
| 1323 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1324 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1325 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1326 | arg1=ArgOption("undefined"); |
| 1327 | parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1); |
| 1328 | if (parse < 0) |
| 1329 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStretchType", |
| 1330 | option,arg1); |
| 1331 | _draw_info->stretch=(StretchType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1332 | break; |
| 1333 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1334 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1335 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1336 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1337 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1338 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1339 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1340 | MagickBooleanType |
| 1341 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1342 | |
| 1343 | ExceptionInfo |
| 1344 | *sans; |
| 1345 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1346 | PixelInfo |
| 1347 | color; |
| 1348 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1349 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1350 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1351 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1352 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1353 | |
| 1354 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1355 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1356 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1357 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1358 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1359 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1360 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1361 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1362 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1363 | break; |
| 1364 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1365 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1366 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1367 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1368 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1369 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1370 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1371 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1372 | break; |
| 1373 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1374 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1375 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1376 | arg1=ArgOption("undefined"); |
| 1377 | parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1); |
| 1378 | if (parse < 0) |
| 1379 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStyleType", |
| 1380 | option,arg1); |
| 1381 | _draw_info->style=(StyleType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1382 | break; |
| 1383 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1384 | #if 0 |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1385 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 1386 | { |
| 1387 | /* FUTURE: this is only used by CompareImages() which is used |
| 1388 | only by the "compare" CLI program at this time. */ |
| 1389 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1390 | break; |
| 1391 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1392 | #endif |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1393 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1394 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1395 | /* FUTURE: syncronize to storage - but what does that mean? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1396 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1397 | break; |
| 1398 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1399 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1400 | } |
| 1401 | case 't': |
| 1402 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1403 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1404 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1405 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1406 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1407 | break; |
| 1408 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1409 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1410 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 1411 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1412 | /* FUTURE: move _image_info string to option splay-tree |
| 1413 | Other than "montage" what uses "texture" ???? |
| 1414 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1415 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1416 | break; |
| 1417 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1418 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1419 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 1420 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1421 | _draw_info->fill_pattern=IfSetOption |
| 1422 | ?GetImageCache(_image_info,arg1,_exception) |
| 1423 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1424 | break; |
| 1425 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1426 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1427 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1428 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1429 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1430 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1431 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1432 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1433 | break; |
| 1434 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1435 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1436 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1437 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1438 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1439 | SyncImageSettings() used to set per-image attribute. |
| 1440 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1441 | Note that +transparent-color, means fall-back to image |
| 1442 | attribute so ImageOption is deleted, not set to a default. |
| 1443 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1444 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1445 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1446 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1447 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1448 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1449 | break; |
| 1450 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1451 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1452 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1453 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1454 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1455 | break; |
| 1456 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1457 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1458 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1459 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1460 | parse=ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 1461 | ArgOption("undefined")); |
| 1462 | if (parse < 0) |
| 1463 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageType", |
| 1464 | option,arg1); |
| 1465 | _image_info->type=(ImageType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1466 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1467 | break; |
| 1468 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1469 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1470 | } |
| 1471 | case 'u': |
| 1472 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1473 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1474 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1475 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1476 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1477 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1478 | break; |
| 1479 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1480 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1481 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1482 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1483 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1484 | FUTURE: this probably should be part of the density setting |
| 1485 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1486 | parse=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
| 1487 | ArgOption("undefined")); |
| 1488 | if (parse < 0) |
| 1489 | CLIWandExceptArgBreak(OptionError,"UnrecognizedUnitsType", |
| 1490 | option,arg1); |
| 1491 | _image_info->units=(ResolutionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1492 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1493 | break; |
| 1494 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1495 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1496 | } |
| 1497 | case 'v': |
| 1498 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1499 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1500 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1501 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1502 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1503 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1504 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1505 | _image_info->verbose= ArgBoolean; |
| 1506 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1507 | break; |
| 1508 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1509 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1510 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1511 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1512 | Only used by coder FPX |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1513 | And it only tests existance, not its content! |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1514 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1515 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1516 | break; |
| 1517 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1518 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1519 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1520 | /* SyncImageSettings() used to set per-image attribute. |
| 1521 | This is VERY deep in the image caching structure. |
| 1522 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1523 | parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 1524 | ArgOption("undefined")); |
| 1525 | if (parse < 0) |
| 1526 | CLIWandExceptArgBreak(OptionError,"UnrecognizedVirtualPixelMethod", |
| 1527 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1528 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1529 | break; |
| 1530 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1531 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1532 | } |
| 1533 | case 'w': |
| 1534 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1535 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1536 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1537 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1538 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1539 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1540 | arg1=ArgOption("all"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1541 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1542 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1543 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1544 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1545 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1546 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1547 | if (_draw_info->weight <= 800) |
| 1548 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1549 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1550 | if (_draw_info->weight >= 100) |
| 1551 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1552 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1553 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1554 | break; |
| 1555 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1556 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1557 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1558 | /* Used as a image chromaticity setting |
| 1559 | SyncImageSettings() used to set per-image attribute. |
| 1560 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1561 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1562 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1563 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1564 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1565 | break; |
| 1566 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1567 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1568 | } |
| 1569 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1570 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1571 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1572 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 1573 | #if 0 |
| 1574 | /* clean up percent escape interpreted strings */ |
| 1575 | if (arg1 != arg1n ) |
| 1576 | arg1=DestroyString((char *)arg1); |
| 1577 | if (arg2 != arg2n ) |
| 1578 | arg2=DestroyString((char *)arg2); |
| 1579 | #endif |
| 1580 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1581 | #undef _image_info |
| 1582 | #undef _exception |
| 1583 | #undef _draw_info |
| 1584 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1585 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1586 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1587 | #undef ArgBooleanNot |
| 1588 | #undef ArgBooleanString |
| 1589 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1590 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1591 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1592 | } |
| 1593 | |
| 1594 | /* |
| 1595 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1596 | % % |
| 1597 | % % |
| 1598 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1599 | + 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] | 1600 | % % |
| 1601 | % % |
| 1602 | % % |
| 1603 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1604 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1605 | % WandSimpleOperatorImages() applys one simple image operation given to all |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1606 | % the images in the CLI wand, with the settings that was previously saved in |
| 1607 | % the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1608 | % |
| 1609 | % It is assumed that any per-image settings are up-to-date with respect to |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1610 | % extra settings that were already saved in the wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1611 | % |
anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1612 | % The format of the WandSimpleOperatorImage method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1613 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1614 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1615 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1616 | % |
| 1617 | % A description of each parameter follows: |
| 1618 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1619 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1620 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1621 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1622 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1623 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1624 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1625 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1626 | |
| 1627 | /* |
| 1628 | Internal subrountine to apply one simple image operation to the current |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1629 | image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1630 | |
| 1631 | The image in the list may be modified in three different ways... |
| 1632 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1633 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1634 | * one image replace by a list of images (-separate and -crop only!) |
| 1635 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1636 | In each case the result replaces the single original image in the list, as |
| 1637 | well as the pointer to the modified image (last image added if replaced by a |
| 1638 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1639 | |
| 1640 | As the image pointed to may be replaced, the first image in the list may |
| 1641 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1642 | return the Image pointer to the first image in list. |
| 1643 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1644 | static void CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1645 | const char *option, const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1646 | { |
| 1647 | Image * |
| 1648 | new_image; |
| 1649 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1650 | GeometryInfo |
| 1651 | geometry_info; |
| 1652 | |
| 1653 | RectangleInfo |
| 1654 | geometry; |
| 1655 | |
| 1656 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1657 | flags; |
| 1658 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1659 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1660 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1661 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1662 | const char /* For percent escape interpretImageProperties() */ |
| 1663 | *arg1, |
| 1664 | *arg2; |
| 1665 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 1666 | #define _image_info (cli_wand->wand.image_info) |
| 1667 | #define _image (cli_wand->wand.images) |
| 1668 | #define _exception (cli_wand->wand.exception) |
| 1669 | #define _draw_info (cli_wand->draw_info) |
| 1670 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1671 | #define _process_flags (cli_wand->process_flags) |
| 1672 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1673 | #define IfNormalOp (*option=='-') |
| 1674 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1675 | #define normal_op IsMagickTrue(IfNormalOp) |
| 1676 | #define plus_alt_op IsMagickFalse(IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1677 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1678 | assert(cli_wand != (MagickCLI *) NULL); |
| 1679 | assert(cli_wand->signature == WandSignature); |
| 1680 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1681 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1682 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1683 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1684 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1685 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 1686 | arg1 = arg1n, |
| 1687 | arg2 = arg2n; |
| 1688 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 1689 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 1690 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 1691 | /* Interpret Percent escapes in argument 1 */ |
| 1692 | if (arg1n != (char *) NULL) { |
| 1693 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 1694 | if (arg1 == (char *) NULL) { |
| 1695 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1696 | arg1=arg1n; /* use the given argument as is */ |
| 1697 | } |
| 1698 | } |
| 1699 | if (arg2n != (char *) NULL) { |
| 1700 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 1701 | if (arg2 == (char *) NULL) { |
| 1702 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1703 | arg2=arg2n; /* use the given argument as is */ |
| 1704 | } |
| 1705 | } |
| 1706 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 1707 | #undef _process_flags |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1708 | #undef _option_type |
| 1709 | |
| 1710 | #if 0 |
| 1711 | (void) FormatLocaleFile(stderr, |
| 1712 | "CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); |
| 1713 | #endif |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1714 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1715 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1716 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1717 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1718 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1719 | { |
| 1720 | case 'a': |
| 1721 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1722 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1723 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1724 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1725 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1726 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1727 | if ((flags & SigmaValue) == 0) |
| 1728 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1729 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1730 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1731 | break; |
| 1732 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1733 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1734 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1735 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1736 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1737 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1738 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1739 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1740 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1741 | break; |
| 1742 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1743 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1744 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1745 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1746 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1747 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1748 | if ((flags & SigmaValue) == 0) |
| 1749 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1750 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1751 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1752 | break; |
| 1753 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1754 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1755 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1756 | parse=ParseCommandOption(MagickAlphaOptions,MagickFalse,arg1); |
| 1757 | if (parse < 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1758 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelType", |
| 1759 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1760 | (void) SetImageAlphaChannel(_image,(AlphaChannelType)parse, |
| 1761 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1762 | break; |
| 1763 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1764 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1765 | { |
| 1766 | char |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1767 | geometry[MaxTextExtent]; |
| 1768 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1769 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1770 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1771 | if ((flags & RhoValue) == 0) |
| 1772 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1773 | if ((flags & SigmaValue) == 0) |
| 1774 | geometry_info.sigma=geometry_info.rho; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1775 | (void) CloneString(&_draw_info->text,arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1776 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1777 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1778 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1779 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1780 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1781 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1782 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1783 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1784 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1785 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1786 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1787 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1788 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1789 | break; |
| 1790 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1791 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1792 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1793 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1794 | break; |
| 1795 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1796 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1797 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1798 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1799 | break; |
| 1800 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1801 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1802 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1803 | /* This should probably be a MagickCore function */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1804 | switch (_image->orientation) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1805 | { |
| 1806 | case TopRightOrientation: |
| 1807 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1808 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1809 | break; |
| 1810 | } |
| 1811 | case BottomRightOrientation: |
| 1812 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1813 | new_image=RotateImage(_image,180.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1814 | break; |
| 1815 | } |
| 1816 | case BottomLeftOrientation: |
| 1817 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1818 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1819 | break; |
| 1820 | } |
| 1821 | case LeftTopOrientation: |
| 1822 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1823 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1824 | break; |
| 1825 | } |
| 1826 | case RightTopOrientation: |
| 1827 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1828 | new_image=RotateImage(_image,90.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1829 | break; |
| 1830 | } |
| 1831 | case RightBottomOrientation: |
| 1832 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1833 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1834 | break; |
| 1835 | } |
| 1836 | case LeftBottomOrientation: |
| 1837 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1838 | new_image=RotateImage(_image,270.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1839 | break; |
| 1840 | } |
| 1841 | default: |
| 1842 | break; |
| 1843 | } |
| 1844 | if (new_image != (Image *) NULL) |
| 1845 | new_image->orientation=TopLeftOrientation; |
| 1846 | break; |
| 1847 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1848 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1849 | } |
| 1850 | case 'b': |
| 1851 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1852 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1853 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1854 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1855 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1856 | (void) BlackThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1857 | break; |
| 1858 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1859 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1860 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1861 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1862 | if (IfNormalOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1863 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1864 | if ((flags & RhoValue) == 0) |
| 1865 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1866 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1867 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1868 | break; |
| 1869 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1870 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1871 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1872 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1873 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1874 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1875 | if ((flags & SigmaValue) == 0) |
| 1876 | geometry_info.sigma=1.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1877 | new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1878 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1879 | break; |
| 1880 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1881 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1882 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1883 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1884 | compose; |
| 1885 | |
| 1886 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1887 | value; |
| 1888 | |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1889 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 1890 | if ((flags & RhoValue) == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1891 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1892 | if ((flags & SigmaValue) == 0) |
| 1893 | geometry.height=geometry.width; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1894 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1895 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1896 | if (value != (const char *) NULL) |
| 1897 | compose=(CompositeOperator) ParseCommandOption( |
| 1898 | MagickComposeOptions,MagickFalse,value); |
| 1899 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1900 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1901 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1902 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1903 | break; |
| 1904 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1905 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1906 | { |
| 1907 | double |
| 1908 | brightness, |
| 1909 | contrast; |
| 1910 | |
| 1911 | GeometryInfo |
| 1912 | geometry_info; |
| 1913 | |
| 1914 | MagickStatusType |
| 1915 | flags; |
| 1916 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1917 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1918 | if ((flags & RhoValue) == 0) |
| 1919 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1920 | brightness=geometry_info.rho; |
| 1921 | contrast=0.0; |
| 1922 | if ((flags & SigmaValue) != 0) |
| 1923 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1924 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1925 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1926 | break; |
| 1927 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1928 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1929 | } |
| 1930 | case 'c': |
| 1931 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1932 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1933 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 1934 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1935 | char |
| 1936 | *color_correction_collection; |
| 1937 | |
| 1938 | /* |
| 1939 | Color correct with a color decision list. |
| 1940 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1941 | color_correction_collection=FileToString(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1942 | if (color_correction_collection == (char *) NULL) |
| 1943 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1944 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 1945 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1946 | break; |
| 1947 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1948 | if (LocaleCompare("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1949 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1950 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1951 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1952 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1953 | if ((flags & SigmaValue) == 0) |
| 1954 | geometry_info.sigma=1.0; |
| 1955 | if ((flags & XiValue) == 0) |
| 1956 | geometry_info.xi=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1957 | new_image=CharcoalImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1958 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1959 | break; |
| 1960 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1961 | if (LocaleCompare("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1962 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1963 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1964 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1965 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 1966 | new_image=ChopImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1967 | break; |
| 1968 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1969 | if (LocaleCompare("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1970 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1971 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1972 | break; |
| 1973 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1974 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1975 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1976 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1977 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1978 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1979 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1980 | break; |
| 1981 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1982 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1983 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 1984 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1985 | CacheView |
| 1986 | *mask_view; |
| 1987 | |
| 1988 | Image |
| 1989 | *mask_image; |
| 1990 | |
| 1991 | register Quantum |
| 1992 | *restrict q; |
| 1993 | |
| 1994 | register ssize_t |
| 1995 | x; |
| 1996 | |
| 1997 | ssize_t |
| 1998 | y; |
| 1999 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2000 | if (IfPlusOp) { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 2001 | /* use "+clip-mask" Remove the write mask for -clip-path */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2002 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2003 | break; |
| 2004 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2005 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2006 | if (mask_image == (Image *) NULL) |
| 2007 | break; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2008 | if (IfMagickFalse(SetImageStorageClass(mask_image,DirectClass,_exception))) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2009 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2010 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2011 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
cristy | db07095 | 2012-04-20 14:33:00 +0000 | [diff] [blame] | 2012 | mask_view=AcquireAuthenticCacheView(mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2013 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 2014 | { |
| 2015 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2016 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2017 | if (q == (Quantum *) NULL) |
| 2018 | break; |
| 2019 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 2020 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2021 | if (IfMagickFalse(mask_image->matte)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2022 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 2023 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2024 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2025 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2026 | q+=GetPixelChannels(mask_image); |
| 2027 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2028 | if (IfMagickFalse(SyncCacheViewAuthenticPixels(mask_view,_exception))) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2029 | break; |
| 2030 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2031 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2032 | mask_view=DestroyCacheView(mask_view); |
| 2033 | mask_image->matte=MagickTrue; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2034 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2035 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2036 | break; |
| 2037 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2038 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2039 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2040 | (void) ClipImagePath(_image,arg1,normal_op,_exception); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 2041 | /* Note: Use "+clip-mask" remove the write mask added */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2042 | break; |
| 2043 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2044 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2045 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2046 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2047 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2048 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2049 | break; |
| 2050 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2051 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2052 | { |
| 2053 | KernelInfo |
| 2054 | *kernel; |
| 2055 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2056 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2057 | if (kernel == (KernelInfo *) NULL) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2058 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2059 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2060 | kernel=DestroyKernelInfo(kernel); |
| 2061 | break; |
| 2062 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2063 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2064 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2065 | /* Reduce the number of colors in the image. |
| 2066 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2067 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2068 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2069 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2070 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2071 | if ((_image->storage_class == DirectClass) || |
| 2072 | _image->colors > _quantize_info->number_colors) |
| 2073 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2074 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2075 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2076 | break; |
| 2077 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2078 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2079 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2080 | /* WARNING: this is both a image_info setting (already done) |
| 2081 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2082 | |
| 2083 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2084 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2085 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2086 | Note that +colorspace sets "undefined" or no effect on |
| 2087 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2088 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2089 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2090 | (void) TransformImageColorspace(_image, |
| 2091 | IfNormalOp ? _image_info->colorspace : RGBColorspace, |
| 2092 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2093 | break; |
| 2094 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2095 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2096 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2097 | CLIWandWarnReplaced(normal_op?"-level":"+level"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2098 | (void) ContrastImage(_image,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2099 | break; |
| 2100 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2101 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2102 | { |
| 2103 | double |
| 2104 | black_point, |
| 2105 | white_point; |
| 2106 | |
| 2107 | MagickStatusType |
| 2108 | flags; |
| 2109 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2110 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2111 | if ((flags & RhoValue) == 0) |
| 2112 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2113 | black_point=geometry_info.rho; |
| 2114 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2115 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2116 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2117 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2118 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2119 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2120 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2121 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2122 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2123 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2124 | break; |
| 2125 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2126 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2127 | { |
| 2128 | KernelInfo |
| 2129 | *kernel_info; |
| 2130 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2131 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2132 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2133 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | a12d8ba | 2012-04-29 16:33:41 +0000 | [diff] [blame] | 2134 | new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info, |
| 2135 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2136 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2137 | break; |
| 2138 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2139 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2140 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2141 | /* WARNING: This can generate multiple images! */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2142 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2143 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2144 | new_image=CropImageToTiles(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2145 | break; |
| 2146 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2147 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2148 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2149 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2150 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2151 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2152 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2153 | break; |
| 2154 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2155 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2156 | } |
| 2157 | case 'd': |
| 2158 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2159 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2160 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 2161 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2162 | StringInfo |
| 2163 | *passkey; |
| 2164 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2165 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2166 | if (passkey == (StringInfo *) NULL) |
| 2167 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2168 | |
| 2169 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2170 | passkey=DestroyStringInfo(passkey); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2171 | break; |
| 2172 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2173 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2174 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2175 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2176 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2177 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2178 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2179 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2180 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2181 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2182 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2183 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2184 | break; |
| 2185 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2186 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2187 | { |
| 2188 | double |
| 2189 | threshold; |
| 2190 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2191 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2192 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2193 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2194 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2195 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2196 | else |
| 2197 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2198 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2199 | break; |
| 2200 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2201 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2202 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2203 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2204 | break; |
| 2205 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2206 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2207 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2208 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2209 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2210 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2211 | ssize_t |
| 2212 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2213 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2214 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2215 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2216 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2217 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2218 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2219 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2220 | double |
| 2221 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2222 | /* Special Case - Argument is actually a resize geometry! |
| 2223 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2224 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2225 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2226 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2227 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2228 | option,arg2); |
| 2229 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2230 | resize_args[0]=(double) geometry.width; |
| 2231 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2232 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2233 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2234 | break; |
| 2235 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2236 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2237 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2238 | if (args == (double *)NULL ) |
| 2239 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2240 | |
| 2241 | new_image=DistortImage(_image,(DistortImageMethod) parse,count,args, |
| 2242 | plus_alt_op,_exception); |
| 2243 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2244 | break; |
| 2245 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2246 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2247 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2248 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2249 | (void) DrawImage(_image,_draw_info,_exception); |
| 2250 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2251 | break; |
| 2252 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2253 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2254 | } |
| 2255 | case 'e': |
| 2256 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2257 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2258 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2259 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2260 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2261 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2262 | if ((flags & SigmaValue) == 0) |
| 2263 | geometry_info.sigma=1.0; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2264 | new_image=EdgeImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2265 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2266 | break; |
| 2267 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2268 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2269 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2270 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2271 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2272 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2273 | if ((flags & SigmaValue) == 0) |
| 2274 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2275 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2276 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2277 | break; |
| 2278 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2279 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2280 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 2281 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2282 | StringInfo |
| 2283 | *passkey; |
| 2284 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2285 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2286 | if (passkey != (StringInfo *) NULL) |
| 2287 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2288 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2289 | passkey=DestroyStringInfo(passkey); |
| 2290 | } |
| 2291 | break; |
| 2292 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2293 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2294 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2295 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2296 | break; |
| 2297 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2298 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2299 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2300 | (void) EqualizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2301 | break; |
| 2302 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2303 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2304 | { |
| 2305 | double |
| 2306 | constant; |
| 2307 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2308 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2309 | if ( parse < 0 ) |
| 2310 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2311 | option,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2312 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2313 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2314 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2315 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2316 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2317 | break; |
| 2318 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2319 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 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 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2324 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2325 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2326 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2327 | geometry.height=_image->rows; |
| 2328 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2329 | break; |
| 2330 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2331 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2332 | } |
| 2333 | case 'f': |
| 2334 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2335 | if (LocaleCompare("features",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2336 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2337 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2338 | if (IfPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2339 | (void) DeleteImageArtifact(_image,"identify:features"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2340 | break; |
| 2341 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2342 | (void) SetImageArtifact(_image,"identify:features","true"); |
| 2343 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2344 | break; |
| 2345 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2346 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2347 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2348 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2349 | break; |
| 2350 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2351 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2352 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2353 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2354 | break; |
| 2355 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2356 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2357 | { |
| 2358 | PixelInfo |
| 2359 | target; |
| 2360 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2361 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2362 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2363 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2364 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2365 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
| 2366 | geometry.y,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2367 | break; |
| 2368 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2369 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2370 | { |
| 2371 | FrameInfo |
| 2372 | frame_info; |
| 2373 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2374 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2375 | compose; |
| 2376 | |
| 2377 | const char* |
| 2378 | value; |
| 2379 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2380 | value=GetImageOption(_image_info,"compose"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2381 | if (value != (const char *) NULL) |
| 2382 | compose=(CompositeOperator) ParseCommandOption( |
| 2383 | MagickComposeOptions,MagickFalse,value); |
| 2384 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2385 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2386 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2387 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2388 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2389 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2390 | frame_info.width=geometry.width; |
| 2391 | frame_info.height=geometry.height; |
| 2392 | if ((flags & HeightValue) == 0) |
| 2393 | frame_info.height=geometry.width; |
| 2394 | frame_info.outer_bevel=geometry.x; |
| 2395 | frame_info.inner_bevel=geometry.y; |
| 2396 | frame_info.x=(ssize_t) frame_info.width; |
| 2397 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2398 | frame_info.width=_image->columns+2*frame_info.width; |
| 2399 | frame_info.height=_image->rows+2*frame_info.height; |
| 2400 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2401 | break; |
| 2402 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2403 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2404 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2405 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2406 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2407 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2408 | ssize_t |
| 2409 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2410 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2411 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2412 | if ( parse < 0 ) |
| 2413 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2414 | option,arg1); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2415 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2416 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2417 | if (args == (double *)NULL ) |
| 2418 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2419 | |
| 2420 | (void) FunctionImage(_image,(MagickFunction)parse,count,args, |
| 2421 | _exception); |
| 2422 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2423 | break; |
| 2424 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2425 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2426 | } |
| 2427 | case 'g': |
| 2428 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2429 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2430 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2431 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2432 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2433 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2434 | (void) GammaImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2435 | _exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2436 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2437 | _image->gamma=StringToDouble(arg1,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2438 | break; |
| 2439 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2440 | if (LocaleCompare("gaussian-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2441 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2442 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2443 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2444 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2445 | if ((flags & SigmaValue) == 0) |
| 2446 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2447 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2448 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2449 | break; |
| 2450 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2451 | if (LocaleCompare("gaussian",option+1) == 0) |
| 2452 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2453 | CLIWandWarnReplaced("-gaussian-blur"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2454 | CLISimpleOperatorImage(cli_wand,"-gaussian-blur",arg1,NULL); |
| 2455 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2456 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2457 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2458 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2459 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2460 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2461 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2462 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2463 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2464 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2465 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2466 | if (_image->geometry != (char *) NULL) |
| 2467 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2468 | break; |
| 2469 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2470 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2471 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2472 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2473 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2474 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2475 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2476 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2477 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2478 | break; |
| 2479 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2480 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2481 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2482 | case 'i': |
| 2483 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2484 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2485 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2486 | const char |
| 2487 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2488 | *text; |
| 2489 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2490 | format=GetImageOption(_image_info,"format"); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2491 | if (format == (char *) NULL) { |
| 2492 | (void) IdentifyImage(_image,stdout,_image_info->verbose,_exception); |
| 2493 | break; |
| 2494 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2495 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2496 | if (text == (char *) NULL) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2497 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 2498 | option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2499 | (void) fputs(text,stdout); |
| 2500 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2501 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2502 | break; |
| 2503 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2504 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2505 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2506 | flags=ParseGeometry(arg1,&geometry_info); |
| 2507 | if ((flags & RhoValue) == 0) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2508 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2509 | new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate, |
| 2510 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2511 | break; |
| 2512 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2513 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2514 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2515 | /* FUTURE: New to IMv7 |
| 2516 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2517 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2518 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2519 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2520 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2521 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2522 | break; |
| 2523 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2524 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2525 | } |
| 2526 | case 'l': |
| 2527 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2528 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2529 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2530 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2531 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2532 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2533 | if ((flags & PercentValue) != 0) |
| 2534 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2535 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2536 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2537 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2538 | break; |
| 2539 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2540 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2541 | { |
| 2542 | MagickRealType |
| 2543 | black_point, |
| 2544 | gamma, |
| 2545 | white_point; |
| 2546 | |
| 2547 | MagickStatusType |
| 2548 | flags; |
| 2549 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2550 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2551 | if ((flags & RhoValue) == 0) |
| 2552 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2553 | black_point=geometry_info.rho; |
| 2554 | white_point=(MagickRealType) QuantumRange; |
| 2555 | if ((flags & SigmaValue) != 0) |
| 2556 | white_point=geometry_info.sigma; |
| 2557 | gamma=1.0; |
| 2558 | if ((flags & XiValue) != 0) |
| 2559 | gamma=geometry_info.xi; |
| 2560 | if ((flags & PercentValue) != 0) |
| 2561 | { |
| 2562 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2563 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2564 | } |
| 2565 | if ((flags & SigmaValue) == 0) |
| 2566 | white_point=(MagickRealType) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2567 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2568 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2569 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2570 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2571 | break; |
| 2572 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2573 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2574 | { |
| 2575 | char |
| 2576 | token[MaxTextExtent]; |
| 2577 | |
| 2578 | const char |
| 2579 | *p; |
| 2580 | |
| 2581 | PixelInfo |
| 2582 | black_point, |
| 2583 | white_point; |
| 2584 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2585 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2586 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2587 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2588 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2589 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2590 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2591 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2592 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2593 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2594 | GetMagickToken(p,&p,token); |
| 2595 | if (*token == '\0') |
| 2596 | white_point=black_point; /* set everything to that color */ |
| 2597 | else |
| 2598 | { |
| 2599 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2600 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2601 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2602 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2603 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2604 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2605 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2606 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2607 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2608 | (void) LevelImageColors(_image,&black_point,&white_point, |
| 2609 | plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2610 | break; |
| 2611 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2612 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2613 | { |
| 2614 | double |
| 2615 | black_point, |
| 2616 | white_point; |
| 2617 | |
| 2618 | MagickStatusType |
| 2619 | flags; |
| 2620 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2621 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2622 | if ((flags & RhoValue) == 0) |
| 2623 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2624 | black_point=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2625 | white_point=(MagickRealType) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2626 | if ((flags & SigmaValue) != 0) |
| 2627 | white_point=geometry_info.sigma; |
| 2628 | if ((flags & PercentValue) != 0) |
| 2629 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2630 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2631 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2632 | } |
| 2633 | if ((flags & SigmaValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2634 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2635 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2636 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2637 | break; |
| 2638 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2639 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2640 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2641 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2642 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2643 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2644 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2645 | if ((flags & XValue) == 0) |
| 2646 | geometry.x=1; |
| 2647 | if ((flags & YValue) == 0) |
| 2648 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2649 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2650 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2651 | break; |
| 2652 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2653 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2654 | } |
| 2655 | case 'm': |
| 2656 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2657 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2658 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2659 | CLIWandWarnReplaced("-remap"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2660 | CLISimpleOperatorImage(cli_wand,"-remap",NULL,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2661 | break; |
| 2662 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2663 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2664 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 2665 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2666 | Image |
| 2667 | *mask; |
| 2668 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2669 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2670 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2671 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2672 | break; |
| 2673 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2674 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2675 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2676 | if (mask == (Image *) NULL) |
| 2677 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2678 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2679 | mask=DestroyImage(mask); |
| 2680 | break; |
| 2681 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2682 | if (LocaleCompare("matte",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2683 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2684 | CLIWandWarnReplaced(IfNormalOp?"-alpha Set":"-alpha Off"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2685 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2686 | DeactivateAlphaChannel, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2687 | break; |
| 2688 | } |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2689 | if (LocaleCompare("median",option+1) == 0) |
| 2690 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2691 | CLIWandWarnReplaced("-statistic Median"); |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2692 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2693 | break; |
| 2694 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2695 | if (LocaleCompare("mode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2696 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2697 | /* FUTURE: note this is also a special "montage" option */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2698 | CLIWandWarnReplaced("-statistic Mode"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2699 | CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2700 | break; |
| 2701 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2702 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2703 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2704 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2705 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2706 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2707 | break; |
| 2708 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2709 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2710 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2711 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2712 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2713 | break; |
| 2714 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2715 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2716 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2717 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2718 | break; |
| 2719 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2720 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2721 | { |
| 2722 | char |
| 2723 | token[MaxTextExtent]; |
| 2724 | |
| 2725 | const char |
| 2726 | *p; |
| 2727 | |
| 2728 | KernelInfo |
| 2729 | *kernel; |
| 2730 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2731 | ssize_t |
| 2732 | iterations; |
| 2733 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2734 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2735 | GetMagickToken(p,&p,token); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2736 | parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
| 2737 | if ( parse < 0 ) |
| 2738 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2739 | option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2740 | iterations=1L; |
| 2741 | GetMagickToken(p,&p,token); |
| 2742 | if ((*p == ':') || (*p == ',')) |
| 2743 | GetMagickToken(p,&p,token); |
| 2744 | if ((*p != '\0')) |
| 2745 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2746 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2747 | if (kernel == (KernelInfo *) NULL) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2748 | CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel", |
| 2749 | option,arg2); |
| 2750 | new_image=MorphologyImage(_image,(MorphologyMethod)parse, |
| 2751 | iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2752 | kernel=DestroyKernelInfo(kernel); |
| 2753 | break; |
| 2754 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2755 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2756 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2757 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2758 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2759 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2760 | if ((flags & SigmaValue) == 0) |
| 2761 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2762 | new_image=MotionBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2763 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2764 | break; |
| 2765 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2766 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2767 | } |
| 2768 | case 'n': |
| 2769 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2770 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2771 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2772 | (void) NegateImage(_image, plus_alt_op, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2773 | break; |
| 2774 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2775 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2776 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2777 | double |
| 2778 | attenuate; |
| 2779 | |
| 2780 | const char* |
| 2781 | value; |
| 2782 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2783 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2784 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2785 | CLIWandWarnReplaced("-statistic NonPeak"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2786 | CLISimpleOperatorImage(cli_wand,"-statistic","NonPeak",arg1); |
| 2787 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2788 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2789 | parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1); |
| 2790 | if ( parse < 0 ) |
| 2791 | CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType", |
| 2792 | option,arg1); |
| 2793 | attenuate=1.0; |
| 2794 | value=GetImageOption(_image_info,"attenuate"); |
| 2795 | if (value != (const char *) NULL) |
| 2796 | attenuate=StringToDouble(value,(char **) NULL); |
| 2797 | new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate, |
| 2798 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2799 | break; |
| 2800 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2801 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2802 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2803 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2804 | break; |
| 2805 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2806 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2807 | } |
| 2808 | case 'o': |
| 2809 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2810 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2811 | { |
| 2812 | PixelInfo |
| 2813 | target; |
| 2814 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2815 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 2816 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,plus_alt_op, |
| 2817 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2818 | break; |
| 2819 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2820 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2821 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2822 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2823 | break; |
| 2824 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2825 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2826 | } |
| 2827 | case 'p': |
| 2828 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2829 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2830 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2831 | flags=ParseGeometry(arg1,&geometry_info); |
| 2832 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2833 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2834 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2835 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2836 | break; |
| 2837 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2838 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2839 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2840 | const char |
| 2841 | *caption; |
| 2842 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2843 | double |
| 2844 | angle; |
| 2845 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2846 | if (IfPlusOp) { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2847 | RandomInfo |
| 2848 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2849 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2850 | random_info=AcquireRandomInfo(); |
| 2851 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2852 | random_info=DestroyRandomInfo(random_info); |
| 2853 | } |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2854 | else { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2855 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2856 | if ((flags & RhoValue) == 0) |
| 2857 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2858 | angle=geometry_info.rho; |
| 2859 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2860 | caption=GetImageProperty(_image,"caption",_exception); |
| 2861 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 2862 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2863 | break; |
| 2864 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2865 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2866 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2867 | flags=ParseGeometry(arg1,&geometry_info); |
| 2868 | if ((flags & RhoValue) == 0) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2869 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2870 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
| 2871 | _quantize_info->dither,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2872 | break; |
| 2873 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2874 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2875 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2876 | /* FUTURE: should be a 'Genesis' option? |
| 2877 | Option however is also in WandSettingOptionInfo() |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2878 | Why??? |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2879 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2880 | parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1); |
| 2881 | if ( parse < 0 ) |
| 2882 | CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType", |
| 2883 | option,arg1); |
| 2884 | new_image=PreviewImage(_image,(PreviewType)parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2885 | break; |
| 2886 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2887 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2888 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 2889 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2890 | const char |
| 2891 | *name; |
| 2892 | |
| 2893 | const StringInfo |
| 2894 | *profile; |
| 2895 | |
| 2896 | Image |
| 2897 | *profile_image; |
| 2898 | |
| 2899 | ImageInfo |
| 2900 | *profile_info; |
| 2901 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2902 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2903 | { /* Remove a profile from the _image. */ |
| 2904 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 2905 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2906 | break; |
| 2907 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2908 | /* Associate a profile with the _image. */ |
| 2909 | profile_info=CloneImageInfo(_image_info); |
| 2910 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2911 | if (profile != (StringInfo *) NULL) |
| 2912 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2913 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2914 | profile_info=DestroyImageInfo(profile_info); |
| 2915 | if (profile_image == (Image *) NULL) |
| 2916 | { |
| 2917 | StringInfo |
| 2918 | *profile; |
| 2919 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2920 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2921 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2922 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2923 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2924 | if (profile != (StringInfo *) NULL) |
| 2925 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2926 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2927 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2928 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2929 | profile=DestroyStringInfo(profile); |
| 2930 | } |
| 2931 | profile_info=DestroyImageInfo(profile_info); |
| 2932 | break; |
| 2933 | } |
| 2934 | ResetImageProfileIterator(profile_image); |
| 2935 | name=GetNextImageProfile(profile_image); |
| 2936 | while (name != (const char *) NULL) |
| 2937 | { |
| 2938 | profile=GetImageProfile(profile_image,name); |
| 2939 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2940 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 2941 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2942 | name=GetNextImageProfile(profile_image); |
| 2943 | } |
| 2944 | profile_image=DestroyImage(profile_image); |
| 2945 | break; |
| 2946 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2947 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2948 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2949 | case 'r': |
| 2950 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2951 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2952 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2953 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2954 | if ((flags & RhoValue) == 0) |
| 2955 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2956 | new_image=RadialBlurImage(_image,geometry_info.rho,_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("raise",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 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2964 | if ((flags & SigmaValue) == 0) |
| 2965 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2966 | (void) RaiseImage(_image,&geometry,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2967 | break; |
| 2968 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2969 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2970 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2971 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2972 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2973 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2974 | break; |
| 2975 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2976 | if (LocaleCompare("recolor",option+1) == 0) |
| 2977 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2978 | CLIWandWarnReplaced("-color-matrix"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2979 | CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL); |
| 2980 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2981 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2982 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 2983 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2984 | Image |
| 2985 | *remap_image; |
| 2986 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2987 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2988 | if (remap_image == (Image *) NULL) |
| 2989 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2990 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2991 | remap_image=DestroyImage(remap_image); |
| 2992 | break; |
| 2993 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2994 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2995 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2996 | if (IfNormalOp) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2997 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2998 | if (IfMagickFalse(IsGeometry(arg1))) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2999 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3000 | arg1); |
| 3001 | (void) ResetImagePage(_image,arg1); |
| 3002 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3003 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3004 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3005 | break; |
| 3006 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3007 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3008 | { |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 3009 | /* FUTURE: Roll into a resize special operation */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3010 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3011 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3012 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3013 | if ((flags & SigmaValue) == 0) |
| 3014 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3015 | new_image=ResampleImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3016 | geometry_info.sigma,_image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3017 | break; |
| 3018 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3019 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3020 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3021 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3022 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3023 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3024 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3025 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3026 | break; |
| 3027 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3028 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3029 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3030 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3031 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3032 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3033 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3034 | break; |
| 3035 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3036 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3037 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3038 | flags=ParseGeometry(arg1,&geometry_info); |
| 3039 | if ((flags & RhoValue) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3040 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | ad255a0 | 2012-04-19 15:02:01 +0000 | [diff] [blame] | 3041 | if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows)) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3042 | break; |
| 3043 | if ((flags & LessValue) != 0 && (_image->columns >= _image->rows)) |
| 3044 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3045 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3046 | break; |
| 3047 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3048 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3049 | } |
| 3050 | case 's': |
| 3051 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3052 | if (LocaleCompare("sample",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=SampleImage(_image,geometry.width,geometry.height, |
| 3059 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3060 | break; |
| 3061 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3062 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3063 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3064 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3065 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3066 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3067 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3068 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3069 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3070 | break; |
| 3071 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3072 | if (LocaleCompare("segment",option+1) == 0) |
| 3073 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3074 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3075 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3076 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3077 | if ((flags & SigmaValue) == 0) |
| 3078 | geometry_info.sigma=1.0; |
| 3079 | (void) SegmentImage(_image,_image->colorspace, |
| 3080 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3081 | _exception); |
| 3082 | break; |
| 3083 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3084 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3085 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3086 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3087 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3088 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3089 | if ((flags & SigmaValue) == 0) |
| 3090 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3091 | if ((flags & PercentValue) != 0) |
| 3092 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3093 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3094 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3095 | break; |
| 3096 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3097 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3098 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3099 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3100 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3101 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3102 | break; |
| 3103 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3104 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3105 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3106 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3107 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3108 | new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1, |
| 3109 | (double) QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3110 | break; |
| 3111 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3112 | if (LocaleCompare("set",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3113 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 3114 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3115 | char |
| 3116 | *value; |
| 3117 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3118 | if (IfPlusOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3119 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3120 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3121 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3122 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3123 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3124 | (void) DeleteImageOption(_image_info,arg1+7); |
| 3125 | (void) DeleteImageArtifact(_image,arg1+7); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3126 | } |
| 3127 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3128 | (void) DeleteImageProperty(_image,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3129 | break; |
| 3130 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3131 | value=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3132 | if (value == (char *) NULL) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3133 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 3134 | option); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3135 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3136 | (void) SetImageRegistry(StringRegistryType,arg1+9,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3137 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3138 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3139 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3140 | (void) SetImageOption(_image_info,arg1+7,value); |
| 3141 | (void) SetImageArtifact(_image,arg1+7,value); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3142 | } |
| 3143 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3144 | (void) SetImageProperty(_image,arg1,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3145 | value=DestroyString(value); |
| 3146 | break; |
| 3147 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3148 | if (LocaleCompare("shade",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) || ((flags & SigmaValue) == 0)) |
| 3152 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3153 | new_image=ShadeImage(_image,normal_op,geometry_info.rho, |
| 3154 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3155 | break; |
| 3156 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3157 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3158 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3159 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3160 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3161 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3162 | if ((flags & SigmaValue) == 0) |
| 3163 | geometry_info.sigma=1.0; |
| 3164 | if ((flags & XiValue) == 0) |
| 3165 | geometry_info.xi=4.0; |
| 3166 | if ((flags & PsiValue) == 0) |
| 3167 | geometry_info.psi=4.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3168 | new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3169 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3170 | ceil(geometry_info.psi-0.5),_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("sharpen",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; |
| 3180 | if ((flags & XiValue) == 0) |
| 3181 | geometry_info.xi=0.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3182 | new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3183 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3184 | break; |
| 3185 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3186 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3187 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3188 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3189 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3190 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3191 | new_image=ShaveImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3192 | break; |
| 3193 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3194 | if (LocaleCompare("shear",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3195 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3196 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3197 | if ((flags & RhoValue) == 0) |
| 3198 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3199 | if ((flags & SigmaValue) == 0) |
| 3200 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3201 | new_image=ShearImage(_image,geometry_info.rho, |
| 3202 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3203 | break; |
| 3204 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3205 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3206 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3207 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3208 | if ((flags & RhoValue) == 0) |
| 3209 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3210 | if ((flags & SigmaValue) == 0) |
| 3211 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3212 | if ((flags & PercentValue) != 0) |
| 3213 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3214 | 100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3215 | (void) SigmoidalContrastImage(_image,normal_op,geometry_info.rho, |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 3216 | geometry_info.sigma,_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("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3220 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3221 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3222 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3223 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3224 | if ((flags & SigmaValue) == 0) |
| 3225 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3226 | new_image=SketchImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3227 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3228 | break; |
| 3229 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3230 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3231 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3232 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3233 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3234 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3235 | QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3236 | break; |
| 3237 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3238 | if (LocaleCompare("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3239 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3240 | parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1); |
| 3241 | if ( parse < 0 ) |
| 3242 | CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod", |
| 3243 | option,arg1); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3244 | new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2, |
| 3245 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3246 | break; |
| 3247 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3248 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3249 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3250 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3251 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3252 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3253 | new_image=SpliceImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3254 | break; |
| 3255 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3256 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3257 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3258 | flags=ParseGeometry(arg1,&geometry_info); |
| 3259 | if ((flags & RhoValue) == 0) |
| 3260 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3261 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3262 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3263 | break; |
| 3264 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3265 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3266 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3267 | parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1); |
| 3268 | if ( parse < 0 ) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3269 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStatisticType", |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3270 | option,arg1); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3271 | flags=ParseGeometry(arg2,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3272 | if ((flags & RhoValue) == 0) |
| 3273 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3274 | if ((flags & SigmaValue) == 0) |
| 3275 | geometry_info.sigma=geometry_info.rho; |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3276 | new_image=StatisticImage(_image,(StatisticType)parse, |
| 3277 | (size_t) geometry_info.rho,(size_t) geometry_info.sigma, |
| 3278 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3279 | break; |
| 3280 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3281 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3282 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3283 | (void) StripImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3284 | break; |
| 3285 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3286 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3287 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3288 | flags=ParseGeometry(arg2,&geometry_info); |
| 3289 | if ((flags & RhoValue) == 0) |
| 3290 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3291 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3292 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3293 | break; |
| 3294 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3295 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3296 | } |
| 3297 | case 't': |
| 3298 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3299 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3300 | { |
| 3301 | double |
| 3302 | threshold; |
| 3303 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3304 | threshold=(double) QuantumRange/2; |
| 3305 | if (normal_op) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3306 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3307 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3308 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3309 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3310 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3311 | break; |
| 3312 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3313 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3314 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3315 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3316 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3317 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3318 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3319 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3320 | break; |
| 3321 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3322 | if (LocaleCompare("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3323 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3324 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3325 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3326 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3327 | break; |
| 3328 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3329 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3330 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3331 | CLIWandWarnReplaced("+distort AffineProjection"); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3332 | new_image=AffineTransformImage(_image,&_draw_info->affine,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3333 | break; |
| 3334 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3335 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3336 | { |
| 3337 | PixelInfo |
| 3338 | target; |
| 3339 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3340 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3341 | (void) TransparentPaintImage(_image,&target,(Quantum) |
| 3342 | TransparentAlpha,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3343 | break; |
| 3344 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3345 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3346 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3347 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3348 | break; |
| 3349 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3350 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3351 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3352 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3353 | break; |
| 3354 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3355 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3356 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3357 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3358 | break; |
| 3359 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3360 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3361 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3362 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3363 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3364 | break; |
| 3365 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3366 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3367 | } |
| 3368 | case 'u': |
| 3369 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3370 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3371 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3372 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? |
| 3373 | Option is not documented, bt appears to be for "identify". |
| 3374 | We may need a identify specific verbose! |
| 3375 | */ |
| 3376 | if (plus_alt_op) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3377 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3378 | break; |
| 3379 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3380 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3381 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3382 | break; |
| 3383 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3384 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3385 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3386 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3387 | break; |
| 3388 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3389 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3390 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3391 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3392 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3393 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3394 | if ((flags & SigmaValue) == 0) |
| 3395 | geometry_info.sigma=1.0; |
| 3396 | if ((flags & XiValue) == 0) |
| 3397 | geometry_info.xi=1.0; |
| 3398 | if ((flags & PsiValue) == 0) |
| 3399 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3400 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
| 3401 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3402 | break; |
| 3403 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3404 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3405 | } |
| 3406 | case 'v': |
| 3407 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3408 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3409 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3410 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3411 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3412 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3413 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3414 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3415 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3416 | break; |
| 3417 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3418 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3419 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3420 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3421 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3422 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3423 | if ((flags & SigmaValue) == 0) |
| 3424 | geometry_info.sigma=1.0; |
| 3425 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3426 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3427 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3428 | geometry_info.psi=0.1*_image->rows; |
| 3429 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3430 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3431 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3432 | break; |
| 3433 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3434 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3435 | } |
| 3436 | case 'w': |
| 3437 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3438 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3439 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3440 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3441 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3442 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3443 | if ((flags & SigmaValue) == 0) |
| 3444 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3445 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3446 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3447 | break; |
| 3448 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3449 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3450 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3451 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3452 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3453 | (void) WhiteThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3454 | break; |
| 3455 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3456 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3457 | } |
| 3458 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3459 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3460 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3461 | /* clean up percent escape interpreted strings */ |
| 3462 | if (arg1 != arg1n ) |
| 3463 | arg1=DestroyString((char *)arg1); |
| 3464 | if (arg2 != arg2n ) |
| 3465 | arg2=DestroyString((char *)arg2); |
| 3466 | |
| 3467 | /* Replace current image with any image that was generated |
| 3468 | and set image point to last image (so image->next is correct) */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3469 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3470 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3471 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3472 | return; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3473 | #undef _image_info |
| 3474 | #undef _draw_info |
| 3475 | #undef _quantize_info |
| 3476 | #undef _image |
| 3477 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3478 | #undef IfNormalOp |
| 3479 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3480 | #undef normal_op |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3481 | #undef plus_alt_op |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3482 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3483 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3484 | WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3485 | const char *option, const char *arg1, const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3486 | { |
| 3487 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3488 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3489 | i; |
| 3490 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3491 | assert(cli_wand != (MagickCLI *) NULL); |
| 3492 | assert(cli_wand->signature == WandSignature); |
| 3493 | assert(cli_wand->wand.signature == WandSignature); |
| 3494 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3495 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3496 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3497 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3498 | #if !USE_WAND_METHODS |
| 3499 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3500 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3501 | n=GetImageListLength(cli_wand->wand.images); |
| 3502 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3503 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3504 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3505 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3506 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3507 | break; |
| 3508 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3509 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3510 | assert( i == n ); |
| 3511 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3512 | #else |
| 3513 | MagickResetIterator(&cli_wand->wand); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3514 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3515 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3516 | MagickResetIterator(&cli_wand->wand); |
| 3517 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3518 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3519 | } |
| 3520 | |
| 3521 | /* |
| 3522 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3523 | % % |
| 3524 | % % |
| 3525 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3526 | + 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] | 3527 | % % |
| 3528 | % % |
| 3529 | % % |
| 3530 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3531 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3532 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3533 | % entire image list as a whole. The result is often a complete replacment |
| 3534 | % of the image list with a completely new list, or just a single image. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3535 | % |
| 3536 | % The format of the MogrifyImage method is: |
| 3537 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3538 | % void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3539 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3540 | % |
| 3541 | % A description of each parameter follows: |
| 3542 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3543 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3544 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3545 | % o option: The option string for the operation |
| 3546 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3547 | % o arg1, arg2: optional argument strings to the operation |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3548 | % arg2 is currently not used |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3549 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3550 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3551 | WandExport void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3552 | const char *option,const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3553 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3554 | ssize_t |
| 3555 | parse; |
| 3556 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3557 | Image |
| 3558 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3559 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3560 | const char /* For percent escape interpretImageProperties() */ |
| 3561 | *arg1, |
| 3562 | *arg2; |
| 3563 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3564 | #define _image_info (cli_wand->wand.image_info) |
| 3565 | #define _images (cli_wand->wand.images) |
| 3566 | #define _exception (cli_wand->wand.exception) |
| 3567 | #define _draw_info (cli_wand->draw_info) |
| 3568 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3569 | #define _process_flags (cli_wand->process_flags) |
| 3570 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3571 | #define IfNormalOp (*option=='-') |
| 3572 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3573 | #define normal_op IsMagickTrue(IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3574 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3575 | assert(cli_wand != (MagickCLI *) NULL); |
| 3576 | assert(cli_wand->signature == WandSignature); |
| 3577 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3578 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3579 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3580 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3581 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3582 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 3583 | arg1 = arg1n; |
| 3584 | arg2 = arg2n; |
| 3585 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 3586 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 3587 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 3588 | /* Interpret Percent escapes in argument 1 */ |
| 3589 | if (arg1n != (char *) NULL) { |
| 3590 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 3591 | if (arg1 == (char *) NULL) { |
| 3592 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3593 | arg1=arg1n; /* use the given argument as is */ |
| 3594 | } |
| 3595 | } |
| 3596 | if (arg2n != (char *) NULL) { |
| 3597 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 3598 | if (arg2 == (char *) NULL) { |
| 3599 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3600 | arg2=arg2n; /* use the given argument as is */ |
| 3601 | } |
| 3602 | } |
| 3603 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 3604 | #undef _process_flags |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3605 | #undef _option_type |
| 3606 | |
| 3607 | #if 0 |
| 3608 | (void) FormatLocaleFile(stderr, |
| 3609 | "CLIListOperatorImages: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); |
| 3610 | #endif |
| 3611 | |
| 3612 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3613 | new_images=NewImageList(); |
| 3614 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3615 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3616 | { |
| 3617 | case 'a': |
| 3618 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3619 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3620 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3621 | new_images=AppendImages(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3622 | break; |
| 3623 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3624 | if (LocaleCompare("average",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3625 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3626 | CLIWandWarnReplaced("-evaluate-sequence Mean"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3627 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3628 | break; |
| 3629 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3630 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3631 | } |
| 3632 | case 'c': |
| 3633 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3634 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3635 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3636 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3637 | break; |
| 3638 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3639 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3640 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3641 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3642 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3643 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3644 | /* FUTURE - make this a compose option, and thus can be used |
| 3645 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3646 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3647 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3648 | new_images=RemoveFirstImageFromList(&_images); |
| 3649 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3650 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3651 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3652 | break; |
cristy | e52fb5e | 2012-04-06 23:30:20 +0000 | [diff] [blame] | 3653 | (void) ClutImage(new_images,clut_image,new_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3654 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3655 | break; |
| 3656 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3657 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3658 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3659 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3660 | break; |
| 3661 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3662 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3663 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3664 | /* FUTURE - this may be replaced by a 'channel' method */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3665 | new_images=CombineImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3666 | break; |
| 3667 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3668 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3669 | { |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3670 | CompositeOperator |
| 3671 | compose; |
| 3672 | |
| 3673 | const char* |
| 3674 | value; |
| 3675 | |
| 3676 | MagickBooleanType |
| 3677 | clip_to_self; |
| 3678 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3679 | Image |
| 3680 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3681 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3682 | |
| 3683 | RectangleInfo |
| 3684 | geometry; |
| 3685 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3686 | /* Compose value from "-compose" option only */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3687 | value=GetImageOption(_image_info,"compose"); |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3688 | if (value == (const char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3689 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3690 | else |
| 3691 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 3692 | MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3693 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3694 | /* Get "clip-to-self" expert setting (false is normal) */ |
cristy | ca0e82c | 2012-04-10 11:53:24 +0000 | [diff] [blame] | 3695 | value=GetImageOption(_image_info,"compose:clip-to-self"); |
| 3696 | if (value == (const char *) NULL) |
| 3697 | clip_to_self=MagickTrue; |
| 3698 | else |
| 3699 | clip_to_self=IsStringTrue(GetImageOption(_image_info, |
| 3700 | "compose:clip-to-self")); /* if this is true */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3701 | value=GetImageOption(_image_info,"compose:outside-overlay"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3702 | if (value != (const char *) NULL) { /* or this false */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3703 | /* FUTURE: depreciate warning for "compose:outside-overlay"*/ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3704 | clip_to_self= IsMagickFalse(IsStringNotFalse(value)); |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3705 | } |
| 3706 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3707 | new_images=RemoveFirstImageFromList(&_images); |
| 3708 | source_image=RemoveFirstImageFromList(&_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3709 | if (source_image == (Image *) NULL) |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3710 | break; /* FUTURE - produce Exception, rather than silent fail */ |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3711 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3712 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3713 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3714 | source_image->geometry,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3715 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3716 | SetGeometry(source_image,&geometry); |
| 3717 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3718 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
| 3719 | new_images->gravity, &geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3720 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3721 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3722 | if (mask_image != (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3723 | { /* handle a third write mask image */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3724 | if ((compose == DisplaceCompositeOp) || |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3725 | (compose == DistortCompositeOp)) { |
| 3726 | /* Merge Y displacement into X displace/distort map. */ |
| 3727 | (void) CompositeImage(source_image,mask_image, |
| 3728 | CopyGreenCompositeOp,MagickTrue,0,0,_exception); |
| 3729 | mask_image=DestroyImage(mask_image); |
| 3730 | } |
| 3731 | else { |
| 3732 | /* Set a blending mask for the composition. */ |
| 3733 | (void) NegateImage(mask_image,MagickFalse,_exception); |
cristy | 665e18f | 2012-05-17 12:39:54 +0000 | [diff] [blame] | 3734 | (void) SetImageMask(source_image,mask_image,_exception); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3735 | mask_image=DestroyImage(mask_image); |
| 3736 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3737 | } |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3738 | (void) CompositeImage(new_images,source_image,compose,clip_to_self, |
| 3739 | geometry.x,geometry.y,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3740 | (void) SetImageMask(new_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3741 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3742 | break; |
| 3743 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3744 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3745 | } |
| 3746 | case 'd': |
| 3747 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3748 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3749 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3750 | CLIWandWarnReplaced("-layer CompareAny"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3751 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3752 | break; |
| 3753 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3754 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3755 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3756 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3757 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3758 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3759 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3760 | break; |
| 3761 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3762 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3763 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3764 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3765 | { |
| 3766 | const char |
| 3767 | *p; |
| 3768 | |
| 3769 | size_t |
| 3770 | number_duplicates; |
| 3771 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3772 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3773 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3774 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3775 | number_duplicates=(size_t) StringToLong(arg1); |
| 3776 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3777 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3778 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3779 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3780 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3781 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3782 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3783 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3784 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3785 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3786 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3787 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3788 | break; |
| 3789 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3790 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3791 | } |
| 3792 | case 'e': |
| 3793 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3794 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3795 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3796 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3797 | if ( parse < 0 ) |
| 3798 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3799 | option,arg1); |
| 3800 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
| 3801 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3802 | break; |
| 3803 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3804 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3805 | } |
| 3806 | case 'f': |
| 3807 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3808 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3809 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3810 | new_images=ForwardFourierTransformImage(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3811 | break; |
| 3812 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3813 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3814 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3815 | /* REDIRECTED to use -layers flatten instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3816 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3817 | break; |
| 3818 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3819 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3820 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3821 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3822 | break; |
| 3823 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3824 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3825 | } |
| 3826 | case 'h': |
| 3827 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3828 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3829 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3830 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3831 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3832 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3833 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3834 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3835 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3836 | new_images=RemoveFirstImageFromList(&_images); |
| 3837 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3838 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3839 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3840 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3841 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3842 | break; |
| 3843 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3844 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3845 | } |
| 3846 | case 'i': |
| 3847 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3848 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3849 | { |
| 3850 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3851 | *magnitude_image, |
| 3852 | *phase_image; |
| 3853 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3854 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3855 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3856 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3857 | if (phase_image == (Image *) NULL) |
| 3858 | break; |
| 3859 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3860 | normal_op,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3861 | magnitude_image=DestroyImage(magnitude_image); |
| 3862 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3863 | break; |
| 3864 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3865 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3866 | { |
| 3867 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3868 | *insert_image, |
| 3869 | *index_image; |
| 3870 | |
| 3871 | ssize_t |
| 3872 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3873 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3874 | if (IfNormalOp && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3875 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3876 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3877 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3878 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3879 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3880 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3881 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3882 | PrependImageToList(&_images,insert_image); |
| 3883 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3884 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3885 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3886 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3887 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3888 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3889 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3890 | InsertImageInList(&index_image,insert_image); |
| 3891 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3892 | _images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3893 | break; |
| 3894 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3895 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3896 | } |
| 3897 | case 'l': |
| 3898 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3899 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3900 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3901 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3902 | if ( parse < 0 ) |
| 3903 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3904 | option,arg1); |
| 3905 | switch ((ImageLayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3906 | { |
| 3907 | case CoalesceLayer: |
| 3908 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3909 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3910 | break; |
| 3911 | } |
| 3912 | case CompareAnyLayer: |
| 3913 | case CompareClearLayer: |
| 3914 | case CompareOverlayLayer: |
| 3915 | default: |
| 3916 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3917 | new_images=CompareImagesLayers(_images,(ImageLayerMethod) parse, |
| 3918 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3919 | break; |
| 3920 | } |
| 3921 | case MergeLayer: |
| 3922 | case FlattenLayer: |
| 3923 | case MosaicLayer: |
| 3924 | case TrimBoundsLayer: |
| 3925 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3926 | new_images=MergeImageLayers(_images,(ImageLayerMethod) parse, |
| 3927 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3928 | break; |
| 3929 | } |
| 3930 | case DisposeLayer: |
| 3931 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3932 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3933 | break; |
| 3934 | } |
| 3935 | case OptimizeImageLayer: |
| 3936 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3937 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3938 | break; |
| 3939 | } |
| 3940 | case OptimizePlusLayer: |
| 3941 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3942 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3943 | break; |
| 3944 | } |
| 3945 | case OptimizeTransLayer: |
| 3946 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3947 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3948 | break; |
| 3949 | } |
| 3950 | case RemoveDupsLayer: |
| 3951 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3952 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3953 | break; |
| 3954 | } |
| 3955 | case RemoveZeroLayer: |
| 3956 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3957 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3958 | break; |
| 3959 | } |
| 3960 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3961 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3962 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3963 | if (new_images == (Image *) NULL) |
| 3964 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3965 | _images=DestroyImageList(_images); |
| 3966 | _images=OptimizeImageLayers(new_images,_exception); |
| 3967 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3968 | break; |
| 3969 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3970 | OptimizeImageTransparency(_images,_exception); |
| 3971 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 3972 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3973 | break; |
| 3974 | } |
| 3975 | case CompositeLayer: |
| 3976 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3977 | Image |
| 3978 | *source; |
| 3979 | |
| 3980 | RectangleInfo |
| 3981 | geometry; |
| 3982 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3983 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3984 | compose; |
| 3985 | |
| 3986 | const char* |
| 3987 | value; |
| 3988 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3989 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3990 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3991 | if (value != (const char *) NULL) |
| 3992 | compose=(CompositeOperator) ParseCommandOption( |
| 3993 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3994 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3995 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3996 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3997 | while (source != (Image *) NULL) |
| 3998 | { |
| 3999 | source=GetNextImageInList(source); |
| 4000 | if ((source != (Image *) NULL) && |
| 4001 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 4002 | break; |
| 4003 | } |
| 4004 | if (source != (Image *) NULL) |
| 4005 | { |
| 4006 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 4007 | (GetNextImageInList(source) == (Image *) NULL)) |
| 4008 | source=(Image *) NULL; |
| 4009 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4010 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4011 | source=SplitImageList(source->previous); |
| 4012 | DeleteImageFromList(&source); |
| 4013 | } |
| 4014 | } |
| 4015 | if (source == (Image *) NULL) |
| 4016 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4017 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4018 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4019 | break; |
| 4020 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4021 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4022 | SetGeometry(_images,&geometry); |
| 4023 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4024 | geometry.width=source->page.width != 0 ? |
| 4025 | source->page.width : source->columns; |
| 4026 | geometry.height=source->page.height != 0 ? |
| 4027 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4028 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 4029 | _images->page.width : _images->columns, |
| 4030 | _images->page.height != 0 ? _images->page.height : |
| 4031 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4032 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4033 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4034 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 4035 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4036 | source=DestroyImageList(source); |
| 4037 | break; |
| 4038 | } |
| 4039 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4040 | break; |
| 4041 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4042 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4043 | } |
| 4044 | case 'm': |
| 4045 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4046 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4047 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4048 | CLIWandWarnReplaced("+remap"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4049 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4050 | break; |
| 4051 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4052 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4053 | { |
| 4054 | Image |
| 4055 | *morph_image; |
| 4056 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4057 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 4058 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4059 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4060 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4061 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4062 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4063 | _images=DestroyImageList(_images); |
| 4064 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4065 | break; |
| 4066 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4067 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4068 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4069 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 4070 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4071 | break; |
| 4072 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4073 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4074 | } |
| 4075 | case 'p': |
| 4076 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4077 | if (LocaleCompare("print",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4078 | { |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4079 | (void) FormatLocaleFile(stdout,"%s",arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4080 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4081 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4082 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4083 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 4084 | /* FUTURE: better parsing using ScriptToken() from string ??? */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4085 | char |
| 4086 | **arguments; |
| 4087 | |
| 4088 | int |
| 4089 | j, |
| 4090 | number_arguments; |
| 4091 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4092 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4093 | if (arguments == (char **) NULL) |
| 4094 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4095 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4096 | { |
| 4097 | char |
| 4098 | breaker, |
| 4099 | quote, |
| 4100 | *token; |
| 4101 | |
| 4102 | const char |
| 4103 | *arguments; |
| 4104 | |
| 4105 | int |
| 4106 | next, |
| 4107 | status; |
| 4108 | |
| 4109 | size_t |
| 4110 | length; |
| 4111 | |
| 4112 | TokenInfo |
| 4113 | *token_info; |
| 4114 | |
| 4115 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4116 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4117 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4118 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4119 | token=(char *) NULL; |
| 4120 | if (~length >= (MaxTextExtent-1)) |
| 4121 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4122 | sizeof(*token)); |
| 4123 | if (token == (char *) NULL) |
| 4124 | break; |
| 4125 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4126 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4127 | token_info=AcquireTokenInfo(); |
| 4128 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4129 | "\"",'\0',&breaker,&next,"e); |
| 4130 | token_info=DestroyTokenInfo(token_info); |
| 4131 | if (status == 0) |
| 4132 | { |
| 4133 | const char |
| 4134 | *argv; |
| 4135 | |
| 4136 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4137 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4138 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4139 | } |
| 4140 | token=DestroyString(token); |
| 4141 | break; |
| 4142 | } |
| 4143 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4144 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4145 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4146 | for (j=0; j < number_arguments; j++) |
| 4147 | arguments[j]=DestroyString(arguments[j]); |
| 4148 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4149 | break; |
| 4150 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4151 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4152 | } |
| 4153 | case 'r': |
| 4154 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4155 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4156 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4157 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4158 | break; |
| 4159 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4160 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4161 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4162 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4163 | break; |
| 4164 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4165 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4166 | } |
| 4167 | case 's': |
| 4168 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4169 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4170 | { |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4171 | /* FUTURE: this option needs more work to make better */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4172 | ssize_t |
| 4173 | offset; |
| 4174 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4175 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 4176 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4177 | offset=(ssize_t) StringToLong(arg1); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4178 | new_images=SmushImages(_images,normal_op,offset,_exception); |
| 4179 | break; |
| 4180 | } |
| 4181 | if (LocaleCompare("subimage",option+1) == 0) |
| 4182 | { |
| 4183 | Image |
| 4184 | *base_image, |
| 4185 | *compare_image; |
| 4186 | |
| 4187 | const char * |
| 4188 | value; |
| 4189 | |
| 4190 | MetricType |
| 4191 | metric; |
| 4192 | |
| 4193 | double |
| 4194 | similarity; |
| 4195 | |
| 4196 | RectangleInfo |
| 4197 | offset; |
| 4198 | |
| 4199 | base_image=GetImageFromList(_images,0); |
| 4200 | compare_image=GetImageFromList(_images,1); |
| 4201 | |
| 4202 | /* Comparision Metric */ |
| 4203 | metric=UndefinedMetric; |
| 4204 | value=GetImageOption(_image_info,"metric"); |
| 4205 | if (value != (const char *) NULL) |
| 4206 | metric=(MetricType) ParseCommandOption(MagickMetricOptions, |
| 4207 | MagickFalse,value); |
| 4208 | |
| 4209 | new_images=SimilarityImage(base_image,compare_image,metric, |
| 4210 | &offset,&similarity,_exception); |
| 4211 | |
| 4212 | if ( new_images != (Image *)NULL ) { |
| 4213 | char |
| 4214 | result[MaxTextExtent]; |
| 4215 | |
| 4216 | (void) FormatLocaleString(result,MaxTextExtent,"%lf",similarity); |
| 4217 | (void) SetImageProperty(new_images,"subimage:similarity",result, |
| 4218 | _exception); |
| 4219 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4220 | (long) offset.x); |
| 4221 | (void) SetImageProperty(new_images,"subimage:x",result, |
| 4222 | _exception); |
| 4223 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4224 | (long) offset.y); |
| 4225 | (void) SetImageProperty(new_images,"subimage:y",result, |
| 4226 | _exception); |
| 4227 | (void) FormatLocaleString(result,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 4228 | (unsigned long) offset.width,(unsigned long) offset.height, |
| 4229 | (long) offset.x,(long) offset.y); |
| 4230 | (void) SetImageProperty(new_images,"subimage:offset",result, |
| 4231 | _exception); |
| 4232 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4233 | break; |
| 4234 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4235 | if (LocaleCompare("swap",option+1) == 0) { |
| 4236 | Image |
| 4237 | *p, |
| 4238 | *q, |
| 4239 | *swap; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4240 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4241 | ssize_t |
| 4242 | index, |
| 4243 | swap_index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4244 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4245 | index=-1; |
| 4246 | swap_index=-2; |
| 4247 | if (IfNormalOp) { |
| 4248 | GeometryInfo |
| 4249 | geometry_info; |
| 4250 | |
| 4251 | MagickStatusType |
| 4252 | flags; |
| 4253 | |
| 4254 | swap_index=(-1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4255 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 4256 | if ((flags & RhoValue) != 0) |
| 4257 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4258 | index=(ssize_t) geometry_info.rho; |
| 4259 | if ((flags & SigmaValue) != 0) |
| 4260 | swap_index=(ssize_t) geometry_info.sigma; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4261 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4262 | p=GetImageFromList(_images,index); |
| 4263 | q=GetImageFromList(_images,swap_index); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4264 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) { |
| 4265 | if (IfNormalOp) |
| 4266 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1) |
| 4267 | else |
| 4268 | CLIWandExceptionBreak(OptionError,"TwoOrMoreImagesRequired",option); |
| 4269 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4270 | if (p == q) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4271 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4272 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4273 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
| 4274 | ReplaceImageInList(&q,swap); |
| 4275 | _images=GetFirstImageInList(q); |
| 4276 | break; |
| 4277 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4278 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4279 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4280 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4281 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4282 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4283 | |
| 4284 | /* clean up percent escape interpreted strings */ |
| 4285 | if (arg1 != arg1n ) |
| 4286 | arg1=DestroyString((char *)arg1); |
| 4287 | if (arg2 != arg2n ) |
| 4288 | arg2=DestroyString((char *)arg2); |
| 4289 | |
| 4290 | /* if new image list generated, replace existing image list */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4291 | if (new_images == (Image *) NULL) |
| 4292 | return; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4293 | _images=DestroyImageList(_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4294 | _images=GetFirstImageInList(new_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4295 | return; |
| 4296 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4297 | #undef _image_info |
| 4298 | #undef _images |
| 4299 | #undef _exception |
| 4300 | #undef _draw_info |
| 4301 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4302 | #undef IfNormalOp |
| 4303 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4304 | #undef normal_op |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4305 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4306 | |
| 4307 | /* |
| 4308 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4309 | % % |
| 4310 | % % |
| 4311 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4312 | + 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] | 4313 | % % |
| 4314 | % % |
| 4315 | % % |
| 4316 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4317 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4318 | % CLINoImageOperator() Applies operations that may not actually need images |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4319 | % in an image list. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4320 | % |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4321 | % The classic operators of this type is "-read", which actually creates |
| 4322 | % images even when no images are present. Or image stack operators, which |
| 4323 | % can be applied (push or pop) to an empty image list. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4324 | % |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4325 | % Note that these operators may involve other special 'option' prefix |
| 4326 | % characters other than '-' or '+', namely parenthesis and braces. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4327 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4328 | % The format of the CLINoImageOption method is: |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4329 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4330 | % void CLINoImageOption(MagickCLI *cli_wand,const char *option, |
| 4331 | % const char *arg1, const char *arg2) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4332 | % |
| 4333 | % A description of each parameter follows: |
| 4334 | % |
| 4335 | % o cli_wand: the main CLI Wand to use. |
| 4336 | % |
| 4337 | % o option: The special option (with any switch char) to process |
| 4338 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4339 | % o arg1 & arg2: Argument for option, if required |
| 4340 | % Currently arg2 is not used. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4341 | % |
| 4342 | */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4343 | WandExport void CLINoImageOperator(MagickCLI *cli_wand, |
| 4344 | const char *option, const char *arg1, const char *magick_unused(arg2)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4345 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4346 | #if 0 |
| 4347 | const char /* For percent escape interpretImageProperties() */ |
| 4348 | *arg1, |
| 4349 | *arg2; |
| 4350 | #endif |
| 4351 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4352 | #define _image_info (cli_wand->wand.image_info) |
| 4353 | #define _images (cli_wand->wand.images) |
| 4354 | #define _exception (cli_wand->wand.exception) |
| 4355 | #define IfNormalOp (*option=='-') |
| 4356 | #define IfPlusOp (*option!='-') |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4357 | |
| 4358 | assert(cli_wand != (MagickCLI *) NULL); |
| 4359 | assert(cli_wand->signature == WandSignature); |
| 4360 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4361 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4362 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4363 | |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4364 | #if 0 |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4365 | Not able to be used as their may not be any images! |
| 4366 | Also the only option that may have arguments that can be percent escaped is |
| 4367 | "-clone". |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4368 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4369 | #define _process_flags (cli_wand->process_flags) |
| 4370 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
| 4371 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 4372 | arg1 = arg1n; |
| 4373 | arg2 = arg2n; |
| 4374 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 4375 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 4376 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 4377 | /* Interpret Percent escapes in argument 1 */ |
| 4378 | if (arg1n != (char *) NULL) { |
| 4379 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 4380 | if (arg1 == (char *) NULL) { |
| 4381 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 4382 | arg1=arg1n; /* use the given argument as is */ |
| 4383 | } |
| 4384 | } |
| 4385 | if (arg2n != (char *) NULL) { |
| 4386 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4387 | if (arg2 == (char *) NULL) { |
| 4388 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 4389 | arg2=arg2n; /* use the given argument as is */ |
| 4390 | } |
| 4391 | } |
| 4392 | } |
| 4393 | #undef _process_flags |
| 4394 | #undef _option_type |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4395 | #endif |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4396 | |
| 4397 | do { /* break to exit code */ |
| 4398 | /* |
| 4399 | No-op options (ignore these) |
| 4400 | */ |
| 4401 | if (LocaleCompare("noop",option+1) == 0) /* no argument */ |
| 4402 | break; |
| 4403 | if (LocaleCompare("sans",option+1) == 0) /* one argument */ |
| 4404 | break; |
| 4405 | if (LocaleCompare("sans0",option+1) == 0) /* no argument */ |
| 4406 | break; |
| 4407 | if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ |
| 4408 | break; |
| 4409 | /* |
| 4410 | Image Reading |
| 4411 | */ |
| 4412 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
| 4413 | ( LocaleCompare("--",option) == 0 ) ) { |
| 4414 | /* Do Glob filename Expansion for 'arg1' then read all images. |
| 4415 | * |
| 4416 | * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring |
| 4417 | * (but attaching to the filenames in the generated argument list) any |
| 4418 | * [...] read modifiers that may be present. |
| 4419 | * |
| 4420 | * For example: It will expand '*.gif[20x20]' into a list such as |
| 4421 | * 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]' |
| 4422 | * |
| 4423 | * NOTE: In IMv6 this was done globally across all images. This |
| 4424 | * meant you could include IM options in '@filename' lists, but you |
| 4425 | * could not include comments. Doing it only for image read makes |
| 4426 | * it far more secure. |
| 4427 | * |
| 4428 | * Note: arguments do not have percent escapes expanded for security |
| 4429 | * reasons. |
| 4430 | */ |
| 4431 | int argc; |
| 4432 | char **argv; |
| 4433 | ssize_t i; |
| 4434 | |
| 4435 | argc = 1; |
| 4436 | argv = (char **) &arg1; |
| 4437 | |
| 4438 | /* Expand 'glob' expressions in the given filename. |
| 4439 | Expansion handles any 'coder:' prefix, or read modifiers attached |
| 4440 | to the filename, including them in the resulting expanded list. |
| 4441 | */ |
| 4442 | if (IfMagickFalse( ExpandFilenames(&argc,&argv) )) |
| 4443 | CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed", |
| 4444 | option,GetExceptionMessage(errno)); |
| 4445 | |
| 4446 | /* loop over expanded filename list, and read then all in */ |
| 4447 | for (i=0; i<argc; i++) { |
| 4448 | Image * |
| 4449 | new_images; |
| 4450 | if (IfMagickTrue(_image_info->ping)) |
| 4451 | new_images=PingImages(_image_info,argv[i],_exception); |
| 4452 | else |
| 4453 | new_images=ReadImages(_image_info,argv[i],_exception); |
| 4454 | AppendImageToList(&_images, new_images); |
| 4455 | } |
| 4456 | argv=DestroyStringList(argv); /* Destroy the Expanded Filename list */ |
| 4457 | break; |
| 4458 | } |
| 4459 | /* |
| 4460 | Image Writing |
| 4461 | Note: Writing a empty image list is valid in specific cases |
| 4462 | */ |
| 4463 | if (LocaleCompare("write",option+1) == 0) { |
| 4464 | /* Note: arguments do not have percent escapes expanded */ |
| 4465 | char |
| 4466 | key[MaxTextExtent]; |
| 4467 | |
| 4468 | Image |
| 4469 | *write_images; |
| 4470 | |
| 4471 | ImageInfo |
| 4472 | *write_info; |
| 4473 | |
| 4474 | /* Need images, unless a "null:" output coder is used */ |
| 4475 | if ( cli_wand->wand.images == (Image *) NULL ) { |
| 4476 | if ( LocaleCompare(arg1,"null:") == 0 ) |
| 4477 | break; |
| 4478 | CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1); |
| 4479 | } |
| 4480 | |
| 4481 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
| 4482 | (void) DeleteImageRegistry(key); |
| 4483 | write_images=_images; |
| 4484 | if (IfPlusOp) |
| 4485 | write_images=CloneImageList(_images,_exception); |
| 4486 | write_info=CloneImageInfo(_image_info); |
| 4487 | (void) WriteImages(write_info,write_images,arg1,_exception); |
| 4488 | write_info=DestroyImageInfo(write_info); |
| 4489 | if (IfPlusOp) |
| 4490 | write_images=DestroyImageList(write_images); |
| 4491 | break; |
| 4492 | } |
| 4493 | /* |
| 4494 | Parenthesis and Brace operations |
| 4495 | */ |
| 4496 | if (LocaleCompare("(",option) == 0) { |
| 4497 | /* stack 'push' images */ |
| 4498 | Stack |
| 4499 | *node; |
| 4500 | |
| 4501 | size_t |
| 4502 | size; |
| 4503 | |
| 4504 | size=0; |
| 4505 | node=cli_wand->image_list_stack; |
| 4506 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4507 | size++; |
| 4508 | if ( size >= MAX_STACK_DEPTH ) |
| 4509 | CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option); |
| 4510 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4511 | if (node == (Stack *) NULL) |
| 4512 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 4513 | "MemoryAllocationFailed",option); |
| 4514 | node->data = (void *)cli_wand->wand.images; |
| 4515 | cli_wand->wand.images = NewImageList(); |
| 4516 | node->next = cli_wand->image_list_stack; |
| 4517 | cli_wand->image_list_stack = node; |
| 4518 | |
| 4519 | /* handle respect-parenthesis */ |
| 4520 | if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info, |
| 4521 | "respect-parenthesis")))) |
| 4522 | option="{"; /* fall-thru so as to push image settings too */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4523 | else |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4524 | break; |
| 4525 | /* fall thru to next if */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4526 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4527 | if (LocaleCompare("{",option) == 0) { |
| 4528 | /* stack 'push' of image_info settings */ |
| 4529 | Stack |
| 4530 | *node; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4531 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4532 | size_t |
| 4533 | size; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4534 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4535 | size=0; |
| 4536 | node=cli_wand->image_info_stack; |
| 4537 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4538 | size++; |
| 4539 | if ( size >= MAX_STACK_DEPTH ) |
| 4540 | CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option); |
| 4541 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4542 | if (node == (Stack *) NULL) |
| 4543 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 4544 | "MemoryAllocationFailed",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4545 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4546 | node->data = (void *)cli_wand->wand.image_info; |
| 4547 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
| 4548 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
| 4549 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4550 | option); |
| 4551 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4552 | node = (Stack *)RelinquishMagickMemory(node); |
| 4553 | break; |
| 4554 | } |
| 4555 | |
| 4556 | node->next = cli_wand->image_info_stack; |
| 4557 | cli_wand->image_info_stack = node; |
| 4558 | |
| 4559 | break; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4560 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4561 | if (LocaleCompare(")",option) == 0) { |
| 4562 | /* pop images from stack */ |
| 4563 | Stack |
| 4564 | *node; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4565 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4566 | node = (Stack *)cli_wand->image_list_stack; |
| 4567 | if ( node == (Stack *)NULL) |
| 4568 | CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option); |
| 4569 | cli_wand->image_list_stack = node->next; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4570 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4571 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4572 | cli_wand->wand.images= (Image *)node->data; |
| 4573 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4574 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4575 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
| 4576 | node = cli_wand->image_info_stack; |
| 4577 | if ( node != (Stack *)NULL) |
| 4578 | { |
| 4579 | if (IfMagickTrue(IsStringTrue(GetImageOption( |
| 4580 | cli_wand->wand.image_info,"respect-parenthesis")))) |
| 4581 | option="}"; /* fall-thru so as to pop image settings too */ |
| 4582 | else |
| 4583 | break; |
| 4584 | } |
| 4585 | else |
| 4586 | break; |
| 4587 | /* fall thru to next if */ |
| 4588 | } |
| 4589 | if (LocaleCompare("}",option) == 0) { |
| 4590 | /* pop image_info settings from stack */ |
| 4591 | Stack |
| 4592 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4593 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4594 | node = (Stack *)cli_wand->image_info_stack; |
| 4595 | if ( node == (Stack *)NULL) |
| 4596 | CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option); |
| 4597 | cli_wand->image_info_stack = node->next; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4598 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4599 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4600 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4601 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4602 | |
| 4603 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4604 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4605 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4606 | |
| 4607 | break; |
| 4608 | } |
| 4609 | if (LocaleCompare("clone",option+1) == 0) { |
| 4610 | Image |
| 4611 | *new_images; |
| 4612 | |
| 4613 | if (*option == '+') |
| 4614 | arg1="-1"; |
| 4615 | if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse))) |
| 4616 | CLIWandExceptionBreak(OptionError,"InvalidArgument",option); |
| 4617 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
| 4618 | CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); |
| 4619 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4620 | if (new_images == (Image *) NULL) |
| 4621 | CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); |
| 4622 | new_images=CloneImages(new_images,arg1,_exception); |
| 4623 | if (new_images == (Image *) NULL) |
| 4624 | CLIWandExceptionBreak(OptionError,"NoSuchImage",option); |
| 4625 | AppendImageToList(&_images,new_images); |
| 4626 | break; |
| 4627 | } |
| 4628 | /* |
| 4629 | Informational Operations |
| 4630 | |
| 4631 | Note that these do not require either cli-wand or images! |
| 4632 | */ |
| 4633 | if (LocaleCompare("version",option+1) == 0) { |
| 4634 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
| 4635 | GetMagickVersion((size_t *) NULL)); |
| 4636 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 4637 | GetMagickCopyright()); |
| 4638 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 4639 | GetMagickFeatures()); |
| 4640 | break; |
| 4641 | } |
| 4642 | if (LocaleCompare("list",option+1) == 0) { |
| 4643 | /* |
| 4644 | FUTURE: This 'switch' should really be built into the MagickCore |
| 4645 | */ |
| 4646 | ssize_t |
| 4647 | list; |
| 4648 | |
| 4649 | list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); |
| 4650 | if ( list < 0 ) { |
| 4651 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
| 4652 | break; |
| 4653 | } |
| 4654 | switch (list) |
| 4655 | { |
| 4656 | case MagickCoderOptions: |
| 4657 | { |
| 4658 | (void) ListCoderInfo((FILE *) NULL,_exception); |
| 4659 | break; |
| 4660 | } |
| 4661 | case MagickColorOptions: |
| 4662 | { |
| 4663 | (void) ListColorInfo((FILE *) NULL,_exception); |
| 4664 | break; |
| 4665 | } |
| 4666 | case MagickConfigureOptions: |
| 4667 | { |
| 4668 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
| 4669 | break; |
| 4670 | } |
| 4671 | case MagickDelegateOptions: |
| 4672 | { |
| 4673 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
| 4674 | break; |
| 4675 | } |
| 4676 | case MagickFontOptions: |
| 4677 | { |
| 4678 | (void) ListTypeInfo((FILE *) NULL,_exception); |
| 4679 | break; |
| 4680 | } |
| 4681 | case MagickFormatOptions: |
| 4682 | (void) ListMagickInfo((FILE *) NULL,_exception); |
| 4683 | break; |
| 4684 | case MagickLocaleOptions: |
| 4685 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
| 4686 | break; |
| 4687 | case MagickLogOptions: |
| 4688 | (void) ListLogInfo((FILE *) NULL,_exception); |
| 4689 | break; |
| 4690 | case MagickMagicOptions: |
| 4691 | (void) ListMagicInfo((FILE *) NULL,_exception); |
| 4692 | break; |
| 4693 | case MagickMimeOptions: |
| 4694 | (void) ListMimeInfo((FILE *) NULL,_exception); |
| 4695 | break; |
| 4696 | case MagickModuleOptions: |
| 4697 | (void) ListModuleInfo((FILE *) NULL,_exception); |
| 4698 | break; |
| 4699 | case MagickPolicyOptions: |
| 4700 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
| 4701 | break; |
| 4702 | case MagickResourceOptions: |
| 4703 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
| 4704 | break; |
| 4705 | case MagickThresholdOptions: |
| 4706 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
| 4707 | break; |
| 4708 | default: |
| 4709 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
| 4710 | _exception); |
| 4711 | break; |
| 4712 | } |
| 4713 | break; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4714 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4715 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4716 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4717 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4718 | } while (0); /* break to exit code. */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4719 | |
| 4720 | #if 0 |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame^] | 4721 | /* clean up percent escape interpreted strings */ |
| 4722 | if (arg1 != arg1n ) |
| 4723 | arg1=DestroyString((char *)arg1); |
| 4724 | if (arg2 != arg2n ) |
| 4725 | arg2=DestroyString((char *)arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4726 | #endif |
| 4727 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4728 | #undef _image_info |
| 4729 | #undef _images |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4730 | #undef _exception |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4731 | #undef IfNormalOp |
| 4732 | #undef IfPlusOp |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4733 | } |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4734 | |
| 4735 | /* |
| 4736 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4737 | % % |
| 4738 | % % |
| 4739 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4740 | + C L I O p t i o n % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4741 | % % |
| 4742 | % % |
| 4743 | % % |
| 4744 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4745 | % |
| 4746 | % CLIOption() Processes the given option using the given CLI Magick Wand. |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4747 | % The option arguments can be variable in number, though at this time no more |
| 4748 | % that two is actually used by any option (this may change). Excess options |
| 4749 | % are simply ignored. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4750 | % |
| 4751 | % If the cli_wand->command pointer is non-null, then it is assumed that the |
| 4752 | % option has already been search for up from the CommandOptions[] table in |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4753 | % "MagickCore/options.c" using GetCommandOptionInfo(). If not set this |
| 4754 | % routine will do the lookup instead. The pointer is reset afterward. |
| 4755 | % |
| 4756 | % This action allows the caller to lookup and pre-handle any 'special' |
| 4757 | % options, (such as implicit reads) before calling this general option |
| 4758 | % handler to deal with 'standard' command line options. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4759 | % |
| 4760 | % The format of the CLIOption method is: |
| 4761 | % |
| 4762 | % void CLIOption(MagickCLI *cli_wand,const char *option, ...) |
| 4763 | % |
| 4764 | % A description of each parameter follows: |
| 4765 | % |
| 4766 | % o cli_wand: the main CLI Wand to use. |
| 4767 | % |
| 4768 | % o option: The special option (with any switch char) to process |
| 4769 | % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4770 | % o args: any required arguments for an option (variable number) |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4771 | % |
| 4772 | % Example Usage... |
| 4773 | % |
| 4774 | % CLIoption(cli_wand,"-read","rose:"); |
| 4775 | % CLIoption(cli_wand,"-virtual-pixel","transparent"); |
| 4776 | % CLIoption(cli_wand,"-distort","SRT:","30"); |
| 4777 | % CLIoption(cli_wand,"-write","rotated_rose.png"); |
| 4778 | % |
| 4779 | */ |
| 4780 | WandExport void CLIOption(MagickCLI *cli_wand,const char *option,...) |
| 4781 | { |
| 4782 | const char |
| 4783 | *arg1, |
| 4784 | *arg2; |
| 4785 | |
| 4786 | CommandOptionFlags |
| 4787 | option_type; |
| 4788 | |
| 4789 | assert(cli_wand != (MagickCLI *) NULL); |
| 4790 | assert(cli_wand->signature == WandSignature); |
| 4791 | assert(cli_wand->wand.signature == WandSignature); |
| 4792 | if (IfMagickTrue(cli_wand->wand.debug)) |
| 4793 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4794 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4795 | do { /* Break Code Block for error handling */ |
| 4796 | |
| 4797 | /* get information about option */ |
| 4798 | if ( cli_wand->command == (const OptionInfo *) NULL ) |
| 4799 | cli_wand->command = GetCommandOptionInfo(option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4800 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4801 | (void) FormatLocaleFile(stderr, "CLIOption \"%s\" matched \"%s\"\n", |
| 4802 | option, cli_wand->command->mnemonic ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4803 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4804 | option_type=(CommandOptionFlags) cli_wand->command->flags; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4805 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4806 | if ( option_type == UndefinedOptionFlag ) |
| 4807 | CLIWandExceptionReturn(OptionFatalError,"UnrecognizedOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4808 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4809 | assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4810 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4811 | /* depreciated options */ |
| 4812 | if ( (option_type & DeprecateOptionFlag) != 0 ) |
| 4813 | CLIWandExceptionBreak(OptionError,"DeprecatedOptionNoCode",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4814 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4815 | /* options that this module does not handle */ |
| 4816 | if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) |
| 4817 | CLIWandExceptionBreak(OptionFatalError,"InvalidUseOfOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4818 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4819 | /* Get argument strings from VarArgs |
| 4820 | How can you determine arguments is enough was supplied? */ |
| 4821 | { size_t |
| 4822 | count = cli_wand->command->type; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4823 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4824 | va_list |
| 4825 | operands; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4826 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4827 | va_start(operands,option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4828 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4829 | arg1=arg2=NULL; |
| 4830 | if ( count >= 1 ) |
| 4831 | arg1=(const char *) va_arg(operands, const char *); |
| 4832 | if ( count >= 2 ) |
| 4833 | arg2=(const char *) va_arg(operands, const char *); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4834 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4835 | va_end(operands); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4836 | |
anthony | 52cb3df | 2012-04-24 03:29:32 +0000 | [diff] [blame] | 4837 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4838 | (void) FormatLocaleFile(stderr, |
| 4839 | "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n", |
| 4840 | option,(long) count,option_type,arg1,arg2); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4841 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4842 | } |
| 4843 | |
| 4844 | /* |
| 4845 | Call the appropriate option handler |
| 4846 | */ |
| 4847 | |
| 4848 | /* FUTURE: this is temporary - get 'settings' to handle distribution of |
| 4849 | settings to images attributes,proprieties,artifacts */ |
| 4850 | if ( cli_wand->wand.images != (Image *)NULL ) |
| 4851 | SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, |
| 4852 | cli_wand->wand.exception); |
| 4853 | |
| 4854 | if ( (option_type & SettingOptionFlags) != 0 ) { |
| 4855 | CLISettingOptionInfo(cli_wand, option, arg1, arg2); |
| 4856 | // FUTURE: Sync Specific Settings into Image Properities (not global) |
| 4857 | } |
| 4858 | |
| 4859 | /* Operators that do not need images - read, write, stack, clone */ |
| 4860 | if ( (option_type & NoImageOperatorFlag) != 0) |
| 4861 | CLINoImageOperator(cli_wand, option, arg1, arg2); |
| 4862 | |
| 4863 | /* FUTURE: The not a setting part below is a temporary hack due to |
| 4864 | * some options being both a Setting and a Simple operator. |
| 4865 | * Specifically -monitor, -depth, and -colorspace */ |
| 4866 | if ( cli_wand->wand.images == (Image *)NULL ) |
| 4867 | if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) && |
| 4868 | ((option_type & SettingOptionFlags) == 0 )) /* temp hack */ |
| 4869 | CLIWandExceptionBreak(OptionError,"NoImagesFound",option); |
| 4870 | |
| 4871 | /* Operators work on single images, and needs a loop over the images */ |
| 4872 | if ( (option_type & SimpleOperatorFlag) != 0) |
| 4873 | CLISimpleOperatorImages(cli_wand, option, arg1, arg2); |
| 4874 | |
| 4875 | /* Operators that work on the image list as a whole */ |
| 4876 | if ( (option_type & ListOperatorFlag) != 0 ) |
| 4877 | CLIListOperatorImages(cli_wand, option, arg1, arg2); |
| 4878 | |
| 4879 | } while (0); /* end Break code block */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4880 | |
| 4881 | cli_wand->command = (const OptionInfo *) NULL; /* prevent re-use later */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4882 | } |