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 | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 423 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 424 | { |
| 425 | case 'a': |
| 426 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 427 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 428 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 429 | _image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 430 | break; |
| 431 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 432 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 433 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 434 | CLIWandWarnReplaced("-draw 'affine ...'"); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 435 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 436 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 437 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 438 | GetAffineMatrix(&_draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 439 | break; |
| 440 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 441 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 442 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 443 | _image_info->antialias = |
| 444 | _draw_info->stroke_antialias = |
| 445 | _draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 446 | break; |
| 447 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 448 | if (LocaleCompare("attenuate",option+1) == 0) |
| 449 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 450 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 451 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 452 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 453 | break; |
| 454 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 455 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 456 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 457 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 458 | break; |
| 459 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 460 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 461 | } |
| 462 | case 'b': |
| 463 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 464 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 465 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 466 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 467 | _image_info only used directly for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 468 | SyncImageSettings() used to set per-image attribute. |
| 469 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 470 | FUTURE: if _image_info->background_color is not set then |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 471 | we should fall back to per-image background_color |
| 472 | |
| 473 | At this time -background will 'wipe out' the per-image |
| 474 | background color! |
| 475 | |
| 476 | Better error handling of QueryColorCompliance() needed. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 477 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 478 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 479 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 480 | &_image_info->background_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 481 | break; |
| 482 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 483 | if (LocaleCompare("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 484 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 485 | /* FUTURE: bias OBSOLETED, replaced by Artifact "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 486 | as it is actually rarely used except in direct convolve operations |
| 487 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 488 | |
| 489 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 490 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 491 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 492 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 493 | (void) SetImageOption(_image_info,"convolve:bias",ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 494 | break; |
| 495 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 496 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 497 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 498 | /* Used as a image chromaticity setting |
| 499 | SyncImageSettings() used to set per-image attribute. |
| 500 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 501 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 502 | break; |
| 503 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 504 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 505 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 506 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 507 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 508 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 509 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 510 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 511 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 512 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 513 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 514 | break; |
| 515 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 516 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 517 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 518 | /* FUTURE: both _image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 519 | SyncImageSettings() used to set per-image attribute. |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 520 | Better error checking of QueryColorCompliance(). |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 521 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 522 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 523 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 524 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 525 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 526 | &_image_info->border_color,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 527 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 528 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 529 | break; |
| 530 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 531 | (void) DeleteImageOption(_image_info,option+1); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 532 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 533 | &_image_info->border_color,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 534 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 535 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 536 | break; |
| 537 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 538 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 539 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 540 | CLIWandWarnReplaced("-undercolor"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 541 | CLISettingOptionInfo(cli_wand,"-undercolor",arg1, arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 542 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 543 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 544 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 545 | } |
| 546 | case 'c': |
| 547 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 548 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 549 | { |
| 550 | MagickSizeType |
| 551 | limit; |
| 552 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 553 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 554 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 555 | limit=MagickResourceInfinity; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 556 | if (LocaleCompare("unlimited",arg1) != 0) |
| 557 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 558 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 559 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 560 | break; |
| 561 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 562 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 563 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 564 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 565 | break; |
| 566 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 567 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 568 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 569 | arg1=ArgOption("default"); |
| 570 | parse=ParseChannelOption(arg1); |
| 571 | if (parse < 0) |
| 572 | CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType", |
| 573 | option,arg1); |
| 574 | _image_info->channel=(ChannelType) parse; |
| 575 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 576 | break; |
| 577 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 578 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 579 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 580 | /* Setting used for new images via AquireImage() |
| 581 | But also used as a SimpleImageOperator |
| 582 | Undefined colorspace means don't modify images on |
| 583 | read or as a operation */ |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 584 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 585 | ArgOption("undefined")); |
| 586 | if (parse < 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 587 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 588 | option,arg1); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 589 | _image_info->colorspace=(ColorspaceType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 590 | break; |
| 591 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 592 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 593 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 594 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 595 | break; |
| 596 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 597 | if (LocaleCompare("compose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 598 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 599 | /* FUTURE: _image_info should be used, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 600 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 601 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 602 | This setting should NOT be used to set image 'compose' |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 603 | "-layer" operators shoud use _image_info if defined otherwise |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 604 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 605 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 606 | parse = ParseCommandOption(MagickComposeOptions,MagickFalse, |
| 607 | ArgOption("undefined")); |
| 608 | if (parse < 0) |
| 609 | CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", |
| 610 | option,arg1); |
| 611 | _image_info->compose=(CompositeOperator) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 612 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 613 | break; |
| 614 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 615 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 616 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 617 | /* FUTURE: What should be used? _image_info or ImageOption ??? |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 618 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 619 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 620 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 621 | The coders appears to use _image_info, not Image_Option |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 622 | however the image attribute (for save) is set from the |
| 623 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 624 | |
| 625 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 626 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 627 | parse = ParseCommandOption(MagickCompressOptions,MagickFalse, |
| 628 | ArgOption("undefined")); |
| 629 | if (parse < 0) |
| 630 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", |
| 631 | option,arg1); |
| 632 | _image_info->compression=(CompressionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 633 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 634 | break; |
| 635 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 636 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 637 | } |
| 638 | case 'd': |
| 639 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 640 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 641 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 642 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 643 | arg1=ArgOption("none"); |
| 644 | parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); |
| 645 | if (parse < 0) |
| 646 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", |
| 647 | option,arg1); |
| 648 | (void) SetLogEventMask(arg1); |
| 649 | _image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 650 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 651 | break; |
| 652 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 653 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 654 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 655 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 656 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 657 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 658 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 659 | else |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 660 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 661 | break; |
| 662 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 663 | /* DefineImageOption() equals SetImageOption() but with '=' */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 664 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 665 | (void) DefineImageOption(_image_info,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 666 | else if (IsMagickFalse(DeleteImageOption(_image_info,arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 667 | CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 668 | break; |
| 669 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 670 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 671 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 672 | /* Only used for new images via AcquireImage() |
| 673 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 674 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 675 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 676 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 677 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 678 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 679 | break; |
| 680 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 681 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 682 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 683 | /* FUTURE: strings used in _image_info attr and _draw_info! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 684 | Basically as density can be in a XxY form! |
| 685 | |
| 686 | SyncImageSettings() used to set per-image attribute. |
| 687 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 688 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 689 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 690 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 691 | (void) CloneString(&_image_info->density,ArgOption(NULL)); |
| 692 | (void) CloneString(&_draw_info->density,_image_info->density); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 693 | break; |
| 694 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 695 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 696 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 697 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 698 | SyncImageSettings() used to set per-image attribute. |
| 699 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 700 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 701 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 702 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 703 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 704 | break; |
| 705 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 706 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 707 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 708 | /* Image Option is only used to set _draw_info */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 709 | arg1=ArgOption("undefined"); |
| 710 | parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); |
| 711 | if (parse < 0) |
| 712 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", |
| 713 | option,arg1); |
| 714 | _draw_info->direction=(DirectionType) parse; |
| 715 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 716 | break; |
| 717 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 718 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 719 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 720 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); |
| 721 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 722 | break; |
| 723 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 724 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 725 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 726 | /* only used in setting new images */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 727 | arg1=ArgOption("undefined"); |
| 728 | parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); |
| 729 | if (parse < 0) |
| 730 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", |
| 731 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 732 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 733 | break; |
| 734 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 735 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 736 | { |
| 737 | /* FUTURE: this is only used by CompareImages() which is used |
| 738 | only by the "compare" CLI program at this time. */ |
| 739 | arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD); |
| 740 | if (IfMagickFalse(IsGeometry(arg1))) |
| 741 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 742 | (void) SetImageOption(_image_info,option+1,arg1); |
| 743 | break; |
| 744 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 745 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 746 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 747 | /* _image_info attr (on/off), _quantize_info attr (on/off) |
| 748 | but also ImageInfo and _quantize_info method! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 749 | FUTURE: merge the duality of the dithering options |
| 750 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 751 | _image_info->dither = _quantize_info->dither = ArgBoolean; |
| 752 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); |
| 753 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 754 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 755 | if (_quantize_info->dither_method == NoDitherMethod) |
| 756 | _image_info->dither = _quantize_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 757 | break; |
| 758 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 759 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 760 | } |
| 761 | case 'e': |
| 762 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 763 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 764 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 765 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); |
| 766 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 767 | break; |
| 768 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 769 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 770 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 771 | /* Both _image_info attr and ImageInfo */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 772 | arg1 = ArgOption("undefined"); |
| 773 | parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); |
| 774 | if (parse < 0) |
| 775 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", |
| 776 | option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 777 | /* FUTURE: check alloc/free of endian string! - remove? */ |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 778 | _image_info->endian=(EndianType) (*arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 779 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 780 | break; |
| 781 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 782 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 783 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 784 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 785 | break; |
| 786 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 787 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 788 | } |
| 789 | case 'f': |
| 790 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 791 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 792 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 793 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 794 | break; |
| 795 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 796 | if (LocaleCompare("fill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 797 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 798 | /* Set "fill" OR "fill-pattern" in _draw_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 799 | The original fill color is preserved if a fill-pattern is given. |
| 800 | That way it does not effect other operations that directly using |
| 801 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 802 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 803 | MagickBooleanType |
| 804 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 805 | |
| 806 | ExceptionInfo |
| 807 | *sans; |
| 808 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 809 | PixelInfo |
| 810 | color; |
| 811 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 812 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 813 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 814 | if (_draw_info->fill_pattern != (Image *) NULL) |
| 815 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 816 | |
| 817 | /* is it a color or a image? -- ignore exceptions */ |
| 818 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 819 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 820 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 821 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 822 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 823 | _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 824 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 825 | _draw_info->fill=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 826 | break; |
| 827 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 828 | if (LocaleCompare("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 829 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 830 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 831 | arg1 = ArgOption("undefined"); |
| 832 | parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); |
| 833 | if (parse < 0) |
| 834 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", |
| 835 | option,arg1); |
| 836 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 837 | break; |
| 838 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 839 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 840 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 841 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); |
| 842 | (void) CloneString(&_image_info->font,_draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 843 | break; |
| 844 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 845 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 846 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 847 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 848 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 849 | register const char |
| 850 | *q; |
| 851 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 852 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 853 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 854 | _image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 855 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 856 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 857 | break; |
| 858 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 859 | if (LocaleCompare("fuzz",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 860 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 861 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 862 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 863 | SyncImageSettings() used to set per-image attribute. |
| 864 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 865 | FUTURE: Can't find anything else using _image_info->fuzz directly! |
| 866 | remove direct sttribute from image_info |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 867 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 868 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 869 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 870 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 871 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 872 | QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 873 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 874 | break; |
| 875 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 876 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 877 | } |
| 878 | case 'g': |
| 879 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 880 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 881 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 882 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 883 | arg1 = ArgOption("none"); |
| 884 | parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); |
| 885 | if (parse < 0) |
| 886 | CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", |
| 887 | option,arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 888 | _draw_info->gravity=(GravityType) parse; |
anthony | e849097 | 2012-04-03 13:16:01 +0000 | [diff] [blame] | 889 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 890 | break; |
| 891 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 892 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 893 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 894 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 895 | SyncImageSettings() used to set per-image attribute. |
| 896 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 897 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 898 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 899 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 900 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 901 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 902 | break; |
| 903 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 904 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 905 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 906 | case 'h': |
| 907 | { |
| 908 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 909 | { |
| 910 | /* FUTURE: this is only used by CompareImages() which is used |
| 911 | only by the "compare" CLI program at this time. */ |
| 912 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 913 | break; |
| 914 | } |
| 915 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
| 916 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 917 | case 'i': |
| 918 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 919 | if (LocaleCompare("intent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 920 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 921 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 922 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 923 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 924 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 925 | arg1 = ArgOption("indefined"); |
| 926 | parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); |
| 927 | if (parse < 0) |
| 928 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", |
| 929 | option,arg1); |
| 930 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 931 | break; |
| 932 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 933 | if (LocaleCompare("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 934 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 935 | /* _image_info is directly used by coders (so why an image setting?) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 936 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 937 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 938 | arg1 = ArgOption("undefined"); |
| 939 | parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); |
| 940 | if (parse < 0) |
| 941 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", |
| 942 | option,arg1); |
| 943 | _image_info->interlace=(InterlaceType) parse; |
| 944 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 945 | break; |
| 946 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 947 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 948 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 949 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 950 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 951 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 952 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 953 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 954 | break; |
| 955 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 956 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 957 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 958 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 959 | arg1 = ArgOption("undefined"); |
| 960 | parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); |
| 961 | if (parse < 0) |
| 962 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", |
| 963 | option,arg1); |
| 964 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 965 | break; |
| 966 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 967 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 968 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 969 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 970 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 971 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 972 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 973 | break; |
| 974 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 975 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 976 | } |
| 977 | case 'k': |
| 978 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 979 | if (LocaleCompare("kerning",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->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 985 | break; |
| 986 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 987 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 988 | } |
| 989 | case 'l': |
| 990 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 991 | if (LocaleCompare("label",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 992 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 993 | /* only used for new images - not in SyncImageOptions() */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 994 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 995 | break; |
| 996 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 997 | if (LocaleCompare("limit",option+1) == 0) |
| 998 | { |
| 999 | MagickSizeType |
| 1000 | limit; |
| 1001 | |
| 1002 | limit=MagickResourceInfinity; |
| 1003 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 1004 | if ( parse < 0 ) |
| 1005 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 1006 | option,arg1); |
| 1007 | if (LocaleCompare("unlimited",arg2) != 0) |
| 1008 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
| 1009 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
| 1010 | break; |
| 1011 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1012 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1013 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1014 | if (IfSetOption) { |
| 1015 | if ((strchr(arg1,'%') == (char *) NULL)) |
| 1016 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1017 | (void) SetLogFormat(arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1018 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1019 | break; |
| 1020 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1021 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1022 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1023 | /* FUTURE: this is only used by CompareImages() which is used |
| 1024 | only by the "compare" CLI program at this time. */ |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1025 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1026 | break; |
| 1027 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1028 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1029 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1030 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1031 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1032 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1033 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1034 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1035 | break; |
| 1036 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1037 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1038 | } |
| 1039 | case 'm': |
| 1040 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1041 | if (LocaleCompare("mattecolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1042 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1043 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1044 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1045 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1046 | &_image_info->matte_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1047 | break; |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1048 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1049 | if (LocaleCompare("metric",option+1) == 0) |
| 1050 | { |
| 1051 | /* FUTURE: this is only used by CompareImages() which is used |
| 1052 | only by the "compare" CLI program at this time. */ |
| 1053 | parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1); |
| 1054 | if ( parse < 0 ) |
| 1055 | CLIWandExceptArgBreak(OptionError,"UnrecognizedMetricType", |
| 1056 | option,arg1); |
| 1057 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1058 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1059 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1060 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1061 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1062 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1063 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1064 | break; |
| 1065 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1066 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1067 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1068 | /* Setting (used by some input coders!) -- why? |
| 1069 | Warning: This is also Special '-type' SimpleOperator |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1070 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1071 | _image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1072 | break; |
| 1073 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1074 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1075 | } |
| 1076 | case 'o': |
| 1077 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1078 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1079 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1080 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1081 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1082 | FUTURE: make set meta-data operator instead. |
| 1083 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1084 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1085 | parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
| 1086 | ArgOption("undefined")); |
| 1087 | if (parse < 0) |
| 1088 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", |
| 1089 | option,arg1); |
| 1090 | _image_info->orientation=(OrientationType)parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1091 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1092 | break; |
| 1093 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1094 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1095 | } |
| 1096 | case 'p': |
| 1097 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1098 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1099 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1100 | /* Only used for new images and image generators. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1101 | SyncImageSettings() used to set per-image attribute. ????? |
| 1102 | That last is WRONG!!!! |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1103 | FUTURE: adjust named 'page' sizes according density |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1104 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1105 | char |
| 1106 | *canonical_page, |
| 1107 | page[MaxTextExtent]; |
| 1108 | |
| 1109 | const char |
| 1110 | *image_option; |
| 1111 | |
| 1112 | MagickStatusType |
| 1113 | flags; |
| 1114 | |
| 1115 | RectangleInfo |
| 1116 | geometry; |
| 1117 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1118 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1119 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1120 | (void) DeleteImageOption(_image_info,option+1); |
| 1121 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1122 | break; |
| 1123 | } |
| 1124 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1125 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1126 | if (image_option != (const char *) NULL) |
| 1127 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1128 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1129 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1130 | canonical_page=DestroyString(canonical_page); |
| 1131 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1132 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1133 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1134 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1135 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1136 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1137 | (void) SetImageOption(_image_info,option+1,page); |
| 1138 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1139 | break; |
| 1140 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1141 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1142 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1143 | _image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1144 | break; |
| 1145 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1146 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1147 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1148 | if (IfSetOption) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1149 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1150 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1151 | _image_info->pointsize = |
| 1152 | _draw_info->pointsize = |
| 1153 | StringToDouble(arg1,(char **) NULL); |
| 1154 | } |
| 1155 | else { |
| 1156 | _image_info->pointsize=0.0; /* unset pointsize */ |
| 1157 | _draw_info->pointsize=12.0; |
| 1158 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1159 | break; |
| 1160 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1161 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1162 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1163 | arg1=ArgOption("-1"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1164 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1165 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1166 | (void) SetMagickPrecision(StringToInteger(arg1)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1167 | break; |
| 1168 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1169 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1170 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1171 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1172 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1173 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1174 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1175 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1176 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1177 | break; |
| 1178 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1179 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1180 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1181 | } |
| 1182 | case 'q': |
| 1183 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1184 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1185 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1186 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1187 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1188 | _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1) |
| 1189 | : UNDEFINED_COMPRESSION_QUALITY; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1190 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
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("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1194 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1195 | /* Just a set direct in _quantize_info */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1196 | arg1=ArgOption("undefined"); |
| 1197 | parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
| 1198 | if (parse < 0) |
| 1199 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 1200 | option,arg1); |
| 1201 | _quantize_info->colorspace=(ColorspaceType)parse; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1202 | break; |
| 1203 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1204 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1205 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1206 | /* FUTURE: if two -quiet is performed you can not do +quiet! |
| 1207 | This needs to be checked over thoughly. |
| 1208 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1209 | static WarningHandler |
| 1210 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1211 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1212 | WarningHandler |
| 1213 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1214 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1215 | if ( tmp != (WarningHandler) NULL) |
| 1216 | warning_handler = tmp; /* remember the old handler */ |
| 1217 | if (!IfSetOption) /* set the old handler */ |
| 1218 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1219 | break; |
| 1220 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1221 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1222 | } |
| 1223 | case 'r': |
| 1224 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1225 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1226 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1227 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1228 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1229 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1230 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1231 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1232 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1233 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1234 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1235 | break; |
| 1236 | } |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1237 | if (LocaleCompare("regard-warnings",option+1) == 0) |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 1238 | /* FUTURE: to be replaced by a 'fatal-level' type setting */ |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1239 | break; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1240 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1241 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1242 | /* _draw_info only setting */ |
| 1243 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1244 | break; |
| 1245 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1246 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
| 1247 | { |
| 1248 | /* link image and setting stacks - option is itself saved on stack! */ |
| 1249 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1250 | break; |
| 1251 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1252 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1253 | } |
| 1254 | case 's': |
| 1255 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1256 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1257 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1258 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1259 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1260 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1261 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1262 | break; |
| 1263 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1264 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1265 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1266 | /* SyncImageSettings() used to set this as a per-image attribute. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1267 | What ??? Why ???? |
| 1268 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1269 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1270 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1271 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1272 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1273 | break; |
| 1274 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1275 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1276 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1277 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1278 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame] | 1279 | SetRandomSecretKey( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1280 | IfSetOption ? (size_t) StringToUnsignedLong(arg1) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1281 | : (size_t) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1282 | break; |
| 1283 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1284 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1285 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1286 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1287 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1288 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1289 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1290 | break; |
| 1291 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1292 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1293 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1294 | arg1=ArgOption("undefined"); |
| 1295 | parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1); |
| 1296 | if (parse < 0) |
| 1297 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStretchType", |
| 1298 | option,arg1); |
| 1299 | _draw_info->stretch=(StretchType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1300 | break; |
| 1301 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1302 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1303 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1304 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1305 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1306 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1307 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1308 | MagickBooleanType |
| 1309 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1310 | |
| 1311 | ExceptionInfo |
| 1312 | *sans; |
| 1313 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1314 | PixelInfo |
| 1315 | color; |
| 1316 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1317 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1318 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1319 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1320 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1321 | |
| 1322 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1323 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1324 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1325 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1326 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1327 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1328 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1329 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1330 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1331 | break; |
| 1332 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1333 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1334 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1335 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1336 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1337 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1338 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1339 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1340 | break; |
| 1341 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1342 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1343 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1344 | arg1=ArgOption("undefined"); |
| 1345 | parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1); |
| 1346 | if (parse < 0) |
| 1347 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStyleType", |
| 1348 | option,arg1); |
| 1349 | _draw_info->style=(StyleType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1350 | break; |
| 1351 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1352 | #if 0 |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1353 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 1354 | { |
| 1355 | /* FUTURE: this is only used by CompareImages() which is used |
| 1356 | only by the "compare" CLI program at this time. */ |
| 1357 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1358 | break; |
| 1359 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1360 | #endif |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1361 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1362 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1363 | /* FUTURE: syncronize to storage - but what does that mean? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1364 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1365 | break; |
| 1366 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1367 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1368 | } |
| 1369 | case 't': |
| 1370 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1371 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1372 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1373 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1374 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1375 | break; |
| 1376 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1377 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1378 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1379 | /* FUTURE: move _image_info string to option splay-tree |
| 1380 | Other than "montage" what uses "texture" ???? |
| 1381 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1382 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1383 | break; |
| 1384 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1385 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1386 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1387 | _draw_info->fill_pattern=IfSetOption |
| 1388 | ?GetImageCache(_image_info,arg1,_exception) |
| 1389 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1390 | break; |
| 1391 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1392 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1393 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1394 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1395 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1396 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1397 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1398 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1399 | break; |
| 1400 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1401 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1402 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1403 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1404 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1405 | SyncImageSettings() used to set per-image attribute. |
| 1406 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1407 | Note that +transparent-color, means fall-back to image |
| 1408 | attribute so ImageOption is deleted, not set to a default. |
| 1409 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1410 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1411 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1412 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1413 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1414 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1415 | break; |
| 1416 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1417 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1418 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1419 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1420 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1421 | break; |
| 1422 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1423 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1424 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1425 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1426 | parse=ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 1427 | ArgOption("undefined")); |
| 1428 | if (parse < 0) |
| 1429 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageType", |
| 1430 | option,arg1); |
| 1431 | _image_info->type=(ImageType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1432 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1433 | break; |
| 1434 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1435 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1436 | } |
| 1437 | case 'u': |
| 1438 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1439 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1440 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1441 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1442 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1443 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1444 | break; |
| 1445 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1446 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1447 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1448 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1449 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1450 | FUTURE: this probably should be part of the density setting |
| 1451 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1452 | parse=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
| 1453 | ArgOption("undefined")); |
| 1454 | if (parse < 0) |
| 1455 | CLIWandExceptArgBreak(OptionError,"UnrecognizedUnitsType", |
| 1456 | option,arg1); |
| 1457 | _image_info->units=(ResolutionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1458 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1459 | break; |
| 1460 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1461 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1462 | } |
| 1463 | case 'v': |
| 1464 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1465 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1466 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1467 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1468 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1469 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1470 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1471 | _image_info->verbose= ArgBoolean; |
| 1472 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1473 | break; |
| 1474 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1475 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1476 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1477 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1478 | Only used by coder FPX |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1479 | And it only tests existance, not its content! |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1480 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1481 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1482 | break; |
| 1483 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1484 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1485 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1486 | /* SyncImageSettings() used to set per-image attribute. |
| 1487 | This is VERY deep in the image caching structure. |
| 1488 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1489 | parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 1490 | ArgOption("undefined")); |
| 1491 | if (parse < 0) |
| 1492 | CLIWandExceptArgBreak(OptionError,"UnrecognizedVirtualPixelMethod", |
| 1493 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1494 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1495 | break; |
| 1496 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1497 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1498 | } |
| 1499 | case 'w': |
| 1500 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1501 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1502 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1503 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1504 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1505 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1506 | arg1=ArgOption("all"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1507 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1508 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1509 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1510 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1511 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1512 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1513 | if (_draw_info->weight <= 800) |
| 1514 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1515 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1516 | if (_draw_info->weight >= 100) |
| 1517 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1518 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1519 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1520 | break; |
| 1521 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1522 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1523 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1524 | /* Used as a image chromaticity setting |
| 1525 | SyncImageSettings() used to set per-image attribute. |
| 1526 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1527 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1528 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1529 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1530 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1531 | break; |
| 1532 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1533 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1534 | } |
| 1535 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1536 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1537 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1538 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1539 | #undef _image_info |
| 1540 | #undef _exception |
| 1541 | #undef _draw_info |
| 1542 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1543 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1544 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1545 | #undef ArgBooleanNot |
| 1546 | #undef ArgBooleanString |
| 1547 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1548 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1549 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1550 | } |
| 1551 | |
| 1552 | /* |
| 1553 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1554 | % % |
| 1555 | % % |
| 1556 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1557 | + 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] | 1558 | % % |
| 1559 | % % |
| 1560 | % % |
| 1561 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1562 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1563 | % WandSimpleOperatorImages() applys one simple image operation given to all |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1564 | % the images in the CLI wand, with the settings that was previously saved in |
| 1565 | % the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1566 | % |
| 1567 | % 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] | 1568 | % extra settings that were already saved in the wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1569 | % |
anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1570 | % The format of the WandSimpleOperatorImage method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1571 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1572 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1573 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1574 | % |
| 1575 | % A description of each parameter follows: |
| 1576 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1577 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1578 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1579 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1580 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1581 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1582 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1583 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1584 | |
| 1585 | /* |
| 1586 | Internal subrountine to apply one simple image operation to the current |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1587 | image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1588 | |
| 1589 | The image in the list may be modified in three different ways... |
| 1590 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1591 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1592 | * one image replace by a list of images (-separate and -crop only!) |
| 1593 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1594 | In each case the result replaces the single original image in the list, as |
| 1595 | well as the pointer to the modified image (last image added if replaced by a |
| 1596 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1597 | |
| 1598 | As the image pointed to may be replaced, the first image in the list may |
| 1599 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1600 | return the Image pointer to the first image in list. |
| 1601 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1602 | static void CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 1603 | const char *option, const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1604 | { |
| 1605 | Image * |
| 1606 | new_image; |
| 1607 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1608 | GeometryInfo |
| 1609 | geometry_info; |
| 1610 | |
| 1611 | RectangleInfo |
| 1612 | geometry; |
| 1613 | |
| 1614 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1615 | flags; |
| 1616 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1617 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1618 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1619 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 1620 | const char /* For percent escape interpretImageProperties() */ |
| 1621 | *arg1, |
| 1622 | *arg2; |
| 1623 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 1624 | #define _image_info (cli_wand->wand.image_info) |
| 1625 | #define _image (cli_wand->wand.images) |
| 1626 | #define _exception (cli_wand->wand.exception) |
| 1627 | #define _draw_info (cli_wand->draw_info) |
| 1628 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 1629 | #define _process_flags (cli_wand->process_flags) |
| 1630 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1631 | #define IfNormalOp (*option=='-') |
| 1632 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1633 | #define normal_op IsMagickTrue(IfNormalOp) |
| 1634 | #define plus_alt_op IsMagickFalse(IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1635 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1636 | assert(cli_wand != (MagickCLI *) NULL); |
| 1637 | assert(cli_wand->signature == WandSignature); |
| 1638 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1639 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1640 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1641 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1642 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 1643 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 1644 | arg1 = arg1n, |
| 1645 | arg2 = arg2n; |
| 1646 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 1647 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 1648 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 1649 | /* Interpret Percent escapes in argument 1 */ |
| 1650 | if (arg1n != (char *) NULL) { |
| 1651 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 1652 | if (arg1 == (char *) NULL) { |
| 1653 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1654 | arg1=arg1n; /* use the given argument as is */ |
| 1655 | } |
| 1656 | } |
| 1657 | if (arg2n != (char *) NULL) { |
| 1658 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 1659 | if (arg2 == (char *) NULL) { |
| 1660 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1661 | arg2=arg2n; /* use the given argument as is */ |
| 1662 | } |
| 1663 | } |
| 1664 | } |
| 1665 | #undef _option_type |
| 1666 | |
| 1667 | #if 0 |
| 1668 | (void) FormatLocaleFile(stderr, |
| 1669 | "CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); |
| 1670 | #endif |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1671 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1672 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 1673 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1674 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1675 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1676 | { |
| 1677 | case 'a': |
| 1678 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1679 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1680 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1681 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1682 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1683 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1684 | if ((flags & SigmaValue) == 0) |
| 1685 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1686 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1687 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1688 | break; |
| 1689 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1690 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1691 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1692 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1693 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1694 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1695 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1696 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1697 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1698 | break; |
| 1699 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1700 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1701 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1702 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1703 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1704 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1705 | if ((flags & SigmaValue) == 0) |
| 1706 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1707 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1708 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1709 | break; |
| 1710 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1711 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1712 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1713 | parse=ParseCommandOption(MagickAlphaOptions,MagickFalse,arg1); |
| 1714 | if (parse < 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1715 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelType", |
| 1716 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1717 | (void) SetImageAlphaChannel(_image,(AlphaChannelType)parse, |
| 1718 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1719 | break; |
| 1720 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1721 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1722 | { |
| 1723 | char |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1724 | geometry[MaxTextExtent]; |
| 1725 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1726 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1727 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1728 | if ((flags & RhoValue) == 0) |
| 1729 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1730 | if ((flags & SigmaValue) == 0) |
| 1731 | geometry_info.sigma=geometry_info.rho; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 1732 | (void) CloneString(&_draw_info->text,arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1733 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1734 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1735 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1736 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1737 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1738 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1739 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1740 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1741 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1742 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1743 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1744 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1745 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1746 | break; |
| 1747 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1748 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1749 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1750 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1751 | break; |
| 1752 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1753 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1754 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1755 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1756 | break; |
| 1757 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1758 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1759 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1760 | /* This should probably be a MagickCore function */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1761 | switch (_image->orientation) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1762 | { |
| 1763 | case TopRightOrientation: |
| 1764 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1765 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1766 | break; |
| 1767 | } |
| 1768 | case BottomRightOrientation: |
| 1769 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1770 | new_image=RotateImage(_image,180.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1771 | break; |
| 1772 | } |
| 1773 | case BottomLeftOrientation: |
| 1774 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1775 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1776 | break; |
| 1777 | } |
| 1778 | case LeftTopOrientation: |
| 1779 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1780 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1781 | break; |
| 1782 | } |
| 1783 | case RightTopOrientation: |
| 1784 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1785 | new_image=RotateImage(_image,90.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1786 | break; |
| 1787 | } |
| 1788 | case RightBottomOrientation: |
| 1789 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1790 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1791 | break; |
| 1792 | } |
| 1793 | case LeftBottomOrientation: |
| 1794 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1795 | new_image=RotateImage(_image,270.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1796 | break; |
| 1797 | } |
| 1798 | default: |
| 1799 | break; |
| 1800 | } |
| 1801 | if (new_image != (Image *) NULL) |
| 1802 | new_image->orientation=TopLeftOrientation; |
| 1803 | break; |
| 1804 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1805 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1806 | } |
| 1807 | case 'b': |
| 1808 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1809 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1810 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1811 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1812 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1813 | (void) BlackThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1814 | break; |
| 1815 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1816 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1817 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1818 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1819 | if (IfNormalOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1820 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1821 | if ((flags & RhoValue) == 0) |
| 1822 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1823 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1824 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1825 | break; |
| 1826 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1827 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1828 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1829 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1830 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1831 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1832 | if ((flags & SigmaValue) == 0) |
| 1833 | geometry_info.sigma=1.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1834 | new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1835 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1836 | break; |
| 1837 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1838 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1839 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1840 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1841 | compose; |
| 1842 | |
| 1843 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1844 | value; |
| 1845 | |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1846 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 1847 | if ((flags & RhoValue) == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1848 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1849 | if ((flags & SigmaValue) == 0) |
| 1850 | geometry.height=geometry.width; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1851 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1852 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1853 | if (value != (const char *) NULL) |
| 1854 | compose=(CompositeOperator) ParseCommandOption( |
| 1855 | MagickComposeOptions,MagickFalse,value); |
| 1856 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1857 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1858 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1859 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1860 | break; |
| 1861 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1862 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1863 | { |
| 1864 | double |
| 1865 | brightness, |
| 1866 | contrast; |
| 1867 | |
| 1868 | GeometryInfo |
| 1869 | geometry_info; |
| 1870 | |
| 1871 | MagickStatusType |
| 1872 | flags; |
| 1873 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1874 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1875 | if ((flags & RhoValue) == 0) |
| 1876 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1877 | brightness=geometry_info.rho; |
| 1878 | contrast=0.0; |
| 1879 | if ((flags & SigmaValue) != 0) |
| 1880 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1881 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1882 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1883 | break; |
| 1884 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1885 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1886 | } |
| 1887 | case 'c': |
| 1888 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1889 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1890 | { |
| 1891 | char |
| 1892 | *color_correction_collection; |
| 1893 | |
| 1894 | /* |
| 1895 | Color correct with a color decision list. |
| 1896 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1897 | color_correction_collection=FileToString(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1898 | if (color_correction_collection == (char *) NULL) |
| 1899 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1900 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 1901 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1902 | break; |
| 1903 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1904 | if (LocaleCompare("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1905 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1906 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1907 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1908 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1909 | if ((flags & SigmaValue) == 0) |
| 1910 | geometry_info.sigma=1.0; |
| 1911 | if ((flags & XiValue) == 0) |
| 1912 | geometry_info.xi=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1913 | new_image=CharcoalImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1914 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1915 | break; |
| 1916 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1917 | if (LocaleCompare("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1918 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1919 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1920 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1921 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 1922 | new_image=ChopImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1923 | break; |
| 1924 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1925 | if (LocaleCompare("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1926 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1927 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1928 | break; |
| 1929 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1930 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1931 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1932 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1933 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1934 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1935 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1936 | break; |
| 1937 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1938 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1939 | { |
| 1940 | CacheView |
| 1941 | *mask_view; |
| 1942 | |
| 1943 | Image |
| 1944 | *mask_image; |
| 1945 | |
| 1946 | register Quantum |
| 1947 | *restrict q; |
| 1948 | |
| 1949 | register ssize_t |
| 1950 | x; |
| 1951 | |
| 1952 | ssize_t |
| 1953 | y; |
| 1954 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1955 | if (IfPlusOp) { |
| 1956 | /* "+clip-mask" Remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1957 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1958 | break; |
| 1959 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1960 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1961 | if (mask_image == (Image *) NULL) |
| 1962 | break; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1963 | if (IfMagickFalse(SetImageStorageClass(mask_image,DirectClass,_exception))) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1964 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1965 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1966 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
cristy | db07095 | 2012-04-20 14:33:00 +0000 | [diff] [blame] | 1967 | mask_view=AcquireAuthenticCacheView(mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1968 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1969 | { |
| 1970 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1971 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1972 | if (q == (Quantum *) NULL) |
| 1973 | break; |
| 1974 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1975 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1976 | if (IfMagickFalse(mask_image->matte)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1977 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1978 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1979 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1980 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1981 | q+=GetPixelChannels(mask_image); |
| 1982 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1983 | if (IfMagickFalse(SyncCacheViewAuthenticPixels(mask_view,_exception))) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1984 | break; |
| 1985 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1986 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1987 | mask_view=DestroyCacheView(mask_view); |
| 1988 | mask_image->matte=MagickTrue; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1989 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1990 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1991 | break; |
| 1992 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1993 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1994 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1995 | (void) ClipImagePath(_image,arg1,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1996 | break; |
| 1997 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1998 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1999 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2000 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2001 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2002 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2003 | break; |
| 2004 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2005 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2006 | { |
| 2007 | KernelInfo |
| 2008 | *kernel; |
| 2009 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2010 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2011 | if (kernel == (KernelInfo *) NULL) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2012 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2013 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2014 | kernel=DestroyKernelInfo(kernel); |
| 2015 | break; |
| 2016 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2017 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2018 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2019 | /* Reduce the number of colors in the image. |
| 2020 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2021 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2022 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2023 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2024 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2025 | if ((_image->storage_class == DirectClass) || |
| 2026 | _image->colors > _quantize_info->number_colors) |
| 2027 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2028 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2029 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2030 | break; |
| 2031 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2032 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2033 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2034 | /* WARNING: this is both a image_info setting (already done) |
| 2035 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2036 | |
| 2037 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2038 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2039 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2040 | Note that +colorspace sets "undefined" or no effect on |
| 2041 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2042 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2043 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2044 | (void) TransformImageColorspace(_image, |
| 2045 | IfNormalOp ? _image_info->colorspace : RGBColorspace, |
| 2046 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2047 | break; |
| 2048 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2049 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2050 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2051 | CLIWandWarnReplaced(normal_op?"-level":"+level"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2052 | (void) ContrastImage(_image,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2053 | break; |
| 2054 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2055 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2056 | { |
| 2057 | double |
| 2058 | black_point, |
| 2059 | white_point; |
| 2060 | |
| 2061 | MagickStatusType |
| 2062 | flags; |
| 2063 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2064 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2065 | if ((flags & RhoValue) == 0) |
| 2066 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2067 | black_point=geometry_info.rho; |
| 2068 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2069 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2070 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2071 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2072 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2073 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2074 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2075 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2076 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2077 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2078 | break; |
| 2079 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2080 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2081 | { |
| 2082 | KernelInfo |
| 2083 | *kernel_info; |
| 2084 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2085 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2086 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2087 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | a12d8ba | 2012-04-29 16:33:41 +0000 | [diff] [blame] | 2088 | new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info, |
| 2089 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2090 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2091 | break; |
| 2092 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2093 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2094 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2095 | /* WARNING: This can generate multiple images! */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2096 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2097 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2098 | new_image=CropImageToTiles(_image,arg1,_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("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2102 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2103 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2104 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2105 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2106 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2107 | break; |
| 2108 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2109 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2110 | } |
| 2111 | case 'd': |
| 2112 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2113 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2114 | { |
| 2115 | StringInfo |
| 2116 | *passkey; |
| 2117 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2118 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2119 | if (passkey == (StringInfo *) NULL) |
| 2120 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2121 | |
| 2122 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2123 | passkey=DestroyStringInfo(passkey); |
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("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2127 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2128 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2129 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2130 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2131 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2132 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2133 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2134 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2135 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2136 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2137 | break; |
| 2138 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2139 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2140 | { |
| 2141 | double |
| 2142 | threshold; |
| 2143 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2144 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2145 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2146 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2147 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2148 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2149 | else |
| 2150 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2151 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2152 | break; |
| 2153 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2154 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2155 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2156 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2157 | break; |
| 2158 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2159 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2160 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2161 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2162 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2163 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2164 | ssize_t |
| 2165 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2166 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2167 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2168 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2169 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2170 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2171 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2172 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2173 | double |
| 2174 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2175 | /* Special Case - Argument is actually a resize geometry! |
| 2176 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2177 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2178 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2179 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2180 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2181 | option,arg2); |
| 2182 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2183 | resize_args[0]=(double) geometry.width; |
| 2184 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2185 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2186 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2187 | break; |
| 2188 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2189 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 2190 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2191 | if (args == (double *)NULL ) |
| 2192 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2193 | |
| 2194 | new_image=DistortImage(_image,(DistortImageMethod) parse,count,args, |
| 2195 | plus_alt_op,_exception); |
| 2196 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2197 | break; |
| 2198 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2199 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2200 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2201 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2202 | (void) DrawImage(_image,_draw_info,_exception); |
| 2203 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2204 | break; |
| 2205 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2206 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2207 | } |
| 2208 | case 'e': |
| 2209 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2210 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2211 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2212 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2213 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2214 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2215 | if ((flags & SigmaValue) == 0) |
| 2216 | geometry_info.sigma=1.0; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2217 | new_image=EdgeImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2218 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2219 | break; |
| 2220 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2221 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2222 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2223 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2224 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2225 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2226 | if ((flags & SigmaValue) == 0) |
| 2227 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2228 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2229 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2230 | break; |
| 2231 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2232 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2233 | { |
| 2234 | StringInfo |
| 2235 | *passkey; |
| 2236 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2237 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2238 | if (passkey != (StringInfo *) NULL) |
| 2239 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2240 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2241 | passkey=DestroyStringInfo(passkey); |
| 2242 | } |
| 2243 | break; |
| 2244 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2245 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2246 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2247 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2248 | break; |
| 2249 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2250 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2251 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2252 | (void) EqualizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2253 | break; |
| 2254 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2255 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2256 | { |
| 2257 | double |
| 2258 | constant; |
| 2259 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2260 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2261 | if ( parse < 0 ) |
| 2262 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2263 | option,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2264 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2265 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2266 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2267 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2268 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2269 | break; |
| 2270 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2271 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2272 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2273 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2274 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2275 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2276 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2277 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2278 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2279 | geometry.height=_image->rows; |
| 2280 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2281 | break; |
| 2282 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2283 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2284 | } |
| 2285 | case 'f': |
| 2286 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2287 | if (LocaleCompare("features",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2288 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2289 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2290 | if (IfPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2291 | (void) DeleteImageArtifact(_image,"identify:features"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2292 | break; |
| 2293 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2294 | (void) SetImageArtifact(_image,"identify:features","true"); |
| 2295 | (void) SetImageArtifact(_image,"verbose","true"); |
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("flip",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 | new_image=FlipImage(_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("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2304 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2305 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2306 | break; |
| 2307 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2308 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2309 | { |
| 2310 | PixelInfo |
| 2311 | target; |
| 2312 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2313 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2314 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2315 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2316 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2317 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
| 2318 | geometry.y,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2319 | break; |
| 2320 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2321 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2322 | { |
| 2323 | FrameInfo |
| 2324 | frame_info; |
| 2325 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2326 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2327 | compose; |
| 2328 | |
| 2329 | const char* |
| 2330 | value; |
| 2331 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2332 | value=GetImageOption(_image_info,"compose"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2333 | if (value != (const char *) NULL) |
| 2334 | compose=(CompositeOperator) ParseCommandOption( |
| 2335 | MagickComposeOptions,MagickFalse,value); |
| 2336 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2337 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2338 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2339 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2340 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2341 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2342 | frame_info.width=geometry.width; |
| 2343 | frame_info.height=geometry.height; |
| 2344 | if ((flags & HeightValue) == 0) |
| 2345 | frame_info.height=geometry.width; |
| 2346 | frame_info.outer_bevel=geometry.x; |
| 2347 | frame_info.inner_bevel=geometry.y; |
| 2348 | frame_info.x=(ssize_t) frame_info.width; |
| 2349 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2350 | frame_info.width=_image->columns+2*frame_info.width; |
| 2351 | frame_info.height=_image->rows+2*frame_info.height; |
| 2352 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2353 | break; |
| 2354 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2355 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2356 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2357 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2358 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2359 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2360 | ssize_t |
| 2361 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2362 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2363 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2364 | if ( parse < 0 ) |
| 2365 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2366 | option,arg1); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2367 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 2368 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2369 | if (args == (double *)NULL ) |
| 2370 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2371 | |
| 2372 | (void) FunctionImage(_image,(MagickFunction)parse,count,args, |
| 2373 | _exception); |
| 2374 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2375 | break; |
| 2376 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2377 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2378 | } |
| 2379 | case 'g': |
| 2380 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2381 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2382 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2383 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2384 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2385 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2386 | (void) GammaImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2387 | _exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2388 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2389 | _image->gamma=StringToDouble(arg1,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2390 | break; |
| 2391 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2392 | if (LocaleCompare("gaussian-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2393 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2394 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2395 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2396 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2397 | if ((flags & SigmaValue) == 0) |
| 2398 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2399 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2400 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2401 | break; |
| 2402 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2403 | if (LocaleCompare("gaussian",option+1) == 0) |
| 2404 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2405 | CLIWandWarnReplaced("-gaussian-blur"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2406 | CLISimpleOperatorImage(cli_wand,"-gaussian-blur",arg1,NULL); |
| 2407 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2408 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2409 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2410 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2411 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2412 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2413 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2414 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2415 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2416 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2417 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2418 | if (_image->geometry != (char *) NULL) |
| 2419 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2420 | break; |
| 2421 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2422 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2423 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2424 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2425 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2426 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2427 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2428 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2429 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2430 | break; |
| 2431 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2432 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2433 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2434 | case 'i': |
| 2435 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2436 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2437 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2438 | const char |
| 2439 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2440 | *text; |
| 2441 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2442 | format=GetImageOption(_image_info,"format"); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 2443 | if (format == (char *) NULL) { |
| 2444 | (void) IdentifyImage(_image,stdout,_image_info->verbose,_exception); |
| 2445 | break; |
| 2446 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2447 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2448 | if (text == (char *) NULL) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 2449 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 2450 | option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2451 | (void) fputs(text,stdout); |
| 2452 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2453 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2454 | break; |
| 2455 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2456 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2457 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2458 | flags=ParseGeometry(arg1,&geometry_info); |
| 2459 | if ((flags & RhoValue) == 0) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2460 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2461 | new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate, |
| 2462 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2463 | break; |
| 2464 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2465 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2466 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2467 | /* FUTURE: New to IMv7 |
| 2468 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2469 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2470 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2471 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2472 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2473 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2474 | break; |
| 2475 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2476 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2477 | } |
| 2478 | case 'l': |
| 2479 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2480 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2481 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2482 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2483 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2484 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2485 | if ((flags & PercentValue) != 0) |
| 2486 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2487 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2488 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2489 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2490 | break; |
| 2491 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2492 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2493 | { |
| 2494 | MagickRealType |
| 2495 | black_point, |
| 2496 | gamma, |
| 2497 | white_point; |
| 2498 | |
| 2499 | MagickStatusType |
| 2500 | flags; |
| 2501 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2502 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2503 | if ((flags & RhoValue) == 0) |
| 2504 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2505 | black_point=geometry_info.rho; |
| 2506 | white_point=(MagickRealType) QuantumRange; |
| 2507 | if ((flags & SigmaValue) != 0) |
| 2508 | white_point=geometry_info.sigma; |
| 2509 | gamma=1.0; |
| 2510 | if ((flags & XiValue) != 0) |
| 2511 | gamma=geometry_info.xi; |
| 2512 | if ((flags & PercentValue) != 0) |
| 2513 | { |
| 2514 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2515 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2516 | } |
| 2517 | if ((flags & SigmaValue) == 0) |
| 2518 | white_point=(MagickRealType) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2519 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2520 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2521 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2522 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2523 | break; |
| 2524 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2525 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2526 | { |
| 2527 | char |
| 2528 | token[MaxTextExtent]; |
| 2529 | |
| 2530 | const char |
| 2531 | *p; |
| 2532 | |
| 2533 | PixelInfo |
| 2534 | black_point, |
| 2535 | white_point; |
| 2536 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2537 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2538 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2539 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2540 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2541 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2542 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2543 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2544 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2545 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2546 | GetMagickToken(p,&p,token); |
| 2547 | if (*token == '\0') |
| 2548 | white_point=black_point; /* set everything to that color */ |
| 2549 | else |
| 2550 | { |
| 2551 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2552 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2553 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2554 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2555 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2556 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2557 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2558 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2559 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2560 | (void) LevelImageColors(_image,&black_point,&white_point, |
| 2561 | plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2562 | break; |
| 2563 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2564 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2565 | { |
| 2566 | double |
| 2567 | black_point, |
| 2568 | white_point; |
| 2569 | |
| 2570 | MagickStatusType |
| 2571 | flags; |
| 2572 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2573 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2574 | if ((flags & RhoValue) == 0) |
| 2575 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2576 | black_point=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2577 | white_point=(MagickRealType) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2578 | if ((flags & SigmaValue) != 0) |
| 2579 | white_point=geometry_info.sigma; |
| 2580 | if ((flags & PercentValue) != 0) |
| 2581 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2582 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2583 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2584 | } |
| 2585 | if ((flags & SigmaValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2586 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2587 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2588 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2589 | break; |
| 2590 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2591 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2592 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2593 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2594 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2595 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2596 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2597 | if ((flags & XValue) == 0) |
| 2598 | geometry.x=1; |
| 2599 | if ((flags & YValue) == 0) |
| 2600 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2601 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2602 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2603 | break; |
| 2604 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2605 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2606 | } |
| 2607 | case 'm': |
| 2608 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2609 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2610 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2611 | CLIWandWarnReplaced("-remap"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2612 | CLISimpleOperatorImage(cli_wand,"-remap",NULL,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2613 | break; |
| 2614 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2615 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2616 | { |
| 2617 | Image |
| 2618 | *mask; |
| 2619 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2620 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2621 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2622 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2623 | break; |
| 2624 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2625 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2626 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2627 | if (mask == (Image *) NULL) |
| 2628 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2629 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2630 | mask=DestroyImage(mask); |
| 2631 | break; |
| 2632 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2633 | if (LocaleCompare("matte",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2634 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2635 | CLIWandWarnReplaced(IfNormalOp?"-alpha Set":"-alpha Off"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2636 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2637 | DeactivateAlphaChannel, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2638 | break; |
| 2639 | } |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2640 | if (LocaleCompare("median",option+1) == 0) |
| 2641 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2642 | CLIWandWarnReplaced("-statistic Median"); |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2643 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2644 | break; |
| 2645 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2646 | if (LocaleCompare("mode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2647 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2648 | /* FUTURE: note this is also a special "montage" option */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2649 | CLIWandWarnReplaced("-statistic Mode"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2650 | CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2651 | break; |
| 2652 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2653 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2654 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2655 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2656 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2657 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2658 | break; |
| 2659 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2660 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2661 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2662 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2663 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2664 | break; |
| 2665 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2666 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2667 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2668 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2669 | break; |
| 2670 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2671 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2672 | { |
| 2673 | char |
| 2674 | token[MaxTextExtent]; |
| 2675 | |
| 2676 | const char |
| 2677 | *p; |
| 2678 | |
| 2679 | KernelInfo |
| 2680 | *kernel; |
| 2681 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2682 | ssize_t |
| 2683 | iterations; |
| 2684 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2685 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2686 | GetMagickToken(p,&p,token); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2687 | parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
| 2688 | if ( parse < 0 ) |
| 2689 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2690 | option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2691 | iterations=1L; |
| 2692 | GetMagickToken(p,&p,token); |
| 2693 | if ((*p == ':') || (*p == ',')) |
| 2694 | GetMagickToken(p,&p,token); |
| 2695 | if ((*p != '\0')) |
| 2696 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2697 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2698 | if (kernel == (KernelInfo *) NULL) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2699 | CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel", |
| 2700 | option,arg2); |
| 2701 | new_image=MorphologyImage(_image,(MorphologyMethod)parse, |
| 2702 | iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2703 | kernel=DestroyKernelInfo(kernel); |
| 2704 | break; |
| 2705 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2706 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2707 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2708 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2709 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2710 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2711 | if ((flags & SigmaValue) == 0) |
| 2712 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2713 | new_image=MotionBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2714 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2715 | break; |
| 2716 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2717 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2718 | } |
| 2719 | case 'n': |
| 2720 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2721 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2722 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2723 | (void) NegateImage(_image, plus_alt_op, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2724 | break; |
| 2725 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2726 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2727 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2728 | double |
| 2729 | attenuate; |
| 2730 | |
| 2731 | const char* |
| 2732 | value; |
| 2733 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2734 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2735 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2736 | CLIWandWarnReplaced("-statistic NonPeak"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2737 | CLISimpleOperatorImage(cli_wand,"-statistic","NonPeak",arg1); |
| 2738 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2739 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2740 | parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1); |
| 2741 | if ( parse < 0 ) |
| 2742 | CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType", |
| 2743 | option,arg1); |
| 2744 | attenuate=1.0; |
| 2745 | value=GetImageOption(_image_info,"attenuate"); |
| 2746 | if (value != (const char *) NULL) |
| 2747 | attenuate=StringToDouble(value,(char **) NULL); |
| 2748 | new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate, |
| 2749 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2750 | break; |
| 2751 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2752 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2753 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2754 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2755 | break; |
| 2756 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2757 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2758 | } |
| 2759 | case 'o': |
| 2760 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2761 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2762 | { |
| 2763 | PixelInfo |
| 2764 | target; |
| 2765 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2766 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 2767 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,plus_alt_op, |
| 2768 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2769 | break; |
| 2770 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2771 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2772 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2773 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2774 | break; |
| 2775 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2776 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2777 | } |
| 2778 | case 'p': |
| 2779 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2780 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2781 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2782 | flags=ParseGeometry(arg1,&geometry_info); |
| 2783 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2784 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2785 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2786 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2787 | break; |
| 2788 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2789 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2790 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2791 | const char |
| 2792 | *caption; |
| 2793 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2794 | double |
| 2795 | angle; |
| 2796 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2797 | if (IfPlusOp) { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2798 | RandomInfo |
| 2799 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2800 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2801 | random_info=AcquireRandomInfo(); |
| 2802 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2803 | random_info=DestroyRandomInfo(random_info); |
| 2804 | } |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2805 | else { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2806 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2807 | if ((flags & RhoValue) == 0) |
| 2808 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2809 | angle=geometry_info.rho; |
| 2810 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2811 | caption=GetImageProperty(_image,"caption",_exception); |
| 2812 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 2813 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2814 | break; |
| 2815 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2816 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2817 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2818 | flags=ParseGeometry(arg1,&geometry_info); |
| 2819 | if ((flags & RhoValue) == 0) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2820 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2821 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
| 2822 | _quantize_info->dither,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2823 | break; |
| 2824 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2825 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2826 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2827 | /* FUTURE: should be a 'Genesis' option? |
| 2828 | Option however is also in WandSettingOptionInfo() |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2829 | Why??? |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2830 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2831 | parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1); |
| 2832 | if ( parse < 0 ) |
| 2833 | CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType", |
| 2834 | option,arg1); |
| 2835 | new_image=PreviewImage(_image,(PreviewType)parse,_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("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2839 | { |
| 2840 | const char |
| 2841 | *name; |
| 2842 | |
| 2843 | const StringInfo |
| 2844 | *profile; |
| 2845 | |
| 2846 | Image |
| 2847 | *profile_image; |
| 2848 | |
| 2849 | ImageInfo |
| 2850 | *profile_info; |
| 2851 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2852 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2853 | { /* Remove a profile from the _image. */ |
| 2854 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 2855 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2856 | break; |
| 2857 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2858 | /* Associate a profile with the _image. */ |
| 2859 | profile_info=CloneImageInfo(_image_info); |
| 2860 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2861 | if (profile != (StringInfo *) NULL) |
| 2862 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2863 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2864 | profile_info=DestroyImageInfo(profile_info); |
| 2865 | if (profile_image == (Image *) NULL) |
| 2866 | { |
| 2867 | StringInfo |
| 2868 | *profile; |
| 2869 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2870 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2871 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2872 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2873 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2874 | if (profile != (StringInfo *) NULL) |
| 2875 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2876 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2877 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2878 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2879 | profile=DestroyStringInfo(profile); |
| 2880 | } |
| 2881 | profile_info=DestroyImageInfo(profile_info); |
| 2882 | break; |
| 2883 | } |
| 2884 | ResetImageProfileIterator(profile_image); |
| 2885 | name=GetNextImageProfile(profile_image); |
| 2886 | while (name != (const char *) NULL) |
| 2887 | { |
| 2888 | profile=GetImageProfile(profile_image,name); |
| 2889 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2890 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 2891 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2892 | name=GetNextImageProfile(profile_image); |
| 2893 | } |
| 2894 | profile_image=DestroyImage(profile_image); |
| 2895 | break; |
| 2896 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2897 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2898 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2899 | case 'r': |
| 2900 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2901 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2902 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2903 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2904 | if ((flags & RhoValue) == 0) |
| 2905 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2906 | new_image=RadialBlurImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2907 | break; |
| 2908 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2909 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2910 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2911 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2912 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2913 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2914 | if ((flags & SigmaValue) == 0) |
| 2915 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2916 | (void) RaiseImage(_image,&geometry,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2917 | break; |
| 2918 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2919 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2920 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2921 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2922 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2923 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2924 | break; |
| 2925 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2926 | if (LocaleCompare("recolor",option+1) == 0) |
| 2927 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2928 | CLIWandWarnReplaced("-color-matrix"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2929 | CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL); |
| 2930 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2931 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2932 | { |
| 2933 | Image |
| 2934 | *remap_image; |
| 2935 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2936 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2937 | if (remap_image == (Image *) NULL) |
| 2938 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2939 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2940 | remap_image=DestroyImage(remap_image); |
| 2941 | break; |
| 2942 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2943 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2944 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2945 | if (IfNormalOp) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2946 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2947 | if (IfMagickFalse(IsGeometry(arg1))) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2948 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 2949 | arg1); |
| 2950 | (void) ResetImagePage(_image,arg1); |
| 2951 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2952 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2953 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2954 | break; |
| 2955 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2956 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2957 | { |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 2958 | /* FUTURE: Roll into a resize special operation */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2959 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2960 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2961 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2962 | if ((flags & SigmaValue) == 0) |
| 2963 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2964 | new_image=ResampleImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2965 | geometry_info.sigma,_image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2966 | break; |
| 2967 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2968 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2969 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2970 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2971 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2972 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2973 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2974 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2975 | break; |
| 2976 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2977 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2978 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2979 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2980 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2981 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2982 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2983 | break; |
| 2984 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2985 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2986 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2987 | flags=ParseGeometry(arg1,&geometry_info); |
| 2988 | if ((flags & RhoValue) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2989 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | ad255a0 | 2012-04-19 15:02:01 +0000 | [diff] [blame] | 2990 | if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows)) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2991 | break; |
| 2992 | if ((flags & LessValue) != 0 && (_image->columns >= _image->rows)) |
| 2993 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2994 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2995 | break; |
| 2996 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2997 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2998 | } |
| 2999 | case 's': |
| 3000 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3001 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3002 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3003 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3004 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3005 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3006 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3007 | new_image=SampleImage(_image,geometry.width,geometry.height, |
| 3008 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3009 | break; |
| 3010 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3011 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3012 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3013 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3014 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3015 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3016 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3017 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3018 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3019 | break; |
| 3020 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3021 | if (LocaleCompare("segment",option+1) == 0) |
| 3022 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3023 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3024 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3025 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3026 | if ((flags & SigmaValue) == 0) |
| 3027 | geometry_info.sigma=1.0; |
| 3028 | (void) SegmentImage(_image,_image->colorspace, |
| 3029 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3030 | _exception); |
| 3031 | break; |
| 3032 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3033 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3034 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3035 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3036 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3037 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3038 | if ((flags & SigmaValue) == 0) |
| 3039 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3040 | if ((flags & PercentValue) != 0) |
| 3041 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3042 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3043 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3044 | break; |
| 3045 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3046 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3047 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3048 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3049 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3050 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3051 | break; |
| 3052 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3053 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3054 | { |
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); |
| 3057 | new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1, |
| 3058 | (double) QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3059 | break; |
| 3060 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3061 | if (LocaleCompare("set",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3062 | { |
| 3063 | char |
| 3064 | *value; |
| 3065 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3066 | if (IfPlusOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3067 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3068 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3069 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3070 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3071 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3072 | (void) DeleteImageOption(_image_info,arg1+7); |
| 3073 | (void) DeleteImageArtifact(_image,arg1+7); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3074 | } |
| 3075 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3076 | (void) DeleteImageProperty(_image,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3077 | break; |
| 3078 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3079 | value=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3080 | if (value == (char *) NULL) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 3081 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 3082 | option); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3083 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3084 | (void) SetImageRegistry(StringRegistryType,arg1+9,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3085 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3086 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3087 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3088 | (void) SetImageOption(_image_info,arg1+7,value); |
| 3089 | (void) SetImageArtifact(_image,arg1+7,value); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3090 | } |
| 3091 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3092 | (void) SetImageProperty(_image,arg1,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3093 | value=DestroyString(value); |
| 3094 | break; |
| 3095 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3096 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3097 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3098 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3099 | if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0)) |
| 3100 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3101 | new_image=ShadeImage(_image,normal_op,geometry_info.rho, |
| 3102 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3103 | break; |
| 3104 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3105 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3106 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3107 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3108 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3109 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3110 | if ((flags & SigmaValue) == 0) |
| 3111 | geometry_info.sigma=1.0; |
| 3112 | if ((flags & XiValue) == 0) |
| 3113 | geometry_info.xi=4.0; |
| 3114 | if ((flags & PsiValue) == 0) |
| 3115 | geometry_info.psi=4.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3116 | new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3117 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3118 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3119 | break; |
| 3120 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3121 | if (LocaleCompare("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3122 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3123 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3124 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3125 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3126 | if ((flags & SigmaValue) == 0) |
| 3127 | geometry_info.sigma=1.0; |
| 3128 | if ((flags & XiValue) == 0) |
| 3129 | geometry_info.xi=0.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3130 | new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3131 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3132 | break; |
| 3133 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3134 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3135 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3136 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3137 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3138 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3139 | new_image=ShaveImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3140 | break; |
| 3141 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3142 | if (LocaleCompare("shear",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3143 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3144 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3145 | if ((flags & RhoValue) == 0) |
| 3146 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3147 | if ((flags & SigmaValue) == 0) |
| 3148 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3149 | new_image=ShearImage(_image,geometry_info.rho, |
| 3150 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3151 | break; |
| 3152 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3153 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3154 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3155 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3156 | if ((flags & RhoValue) == 0) |
| 3157 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3158 | if ((flags & SigmaValue) == 0) |
| 3159 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3160 | if ((flags & PercentValue) != 0) |
| 3161 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3162 | 100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3163 | (void) SigmoidalContrastImage(_image,normal_op,geometry_info.rho, |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 3164 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3165 | break; |
| 3166 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3167 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3168 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3169 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3170 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3171 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3172 | if ((flags & SigmaValue) == 0) |
| 3173 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3174 | new_image=SketchImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3175 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3176 | break; |
| 3177 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3178 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3179 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3180 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3181 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3182 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3183 | QuantumRange+1.0),_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("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3187 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3188 | parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1); |
| 3189 | if ( parse < 0 ) |
| 3190 | CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod", |
| 3191 | option,arg1); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 3192 | new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2, |
| 3193 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3194 | break; |
| 3195 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3196 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3197 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3198 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3199 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3200 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3201 | new_image=SpliceImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3202 | break; |
| 3203 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3204 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3205 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3206 | flags=ParseGeometry(arg1,&geometry_info); |
| 3207 | if ((flags & RhoValue) == 0) |
| 3208 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3209 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3210 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3211 | break; |
| 3212 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3213 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3214 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3215 | parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1); |
| 3216 | if ( parse < 0 ) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3217 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStatisticType", |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3218 | option,arg1); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3219 | flags=ParseGeometry(arg2,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3220 | if ((flags & RhoValue) == 0) |
| 3221 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3222 | if ((flags & SigmaValue) == 0) |
| 3223 | geometry_info.sigma=geometry_info.rho; |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3224 | new_image=StatisticImage(_image,(StatisticType)parse, |
| 3225 | (size_t) geometry_info.rho,(size_t) geometry_info.sigma, |
| 3226 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3227 | break; |
| 3228 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3229 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3230 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3231 | (void) StripImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3232 | break; |
| 3233 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3234 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3235 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3236 | flags=ParseGeometry(arg2,&geometry_info); |
| 3237 | if ((flags & RhoValue) == 0) |
| 3238 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3239 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3240 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3241 | break; |
| 3242 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3243 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3244 | } |
| 3245 | case 't': |
| 3246 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3247 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3248 | { |
| 3249 | double |
| 3250 | threshold; |
| 3251 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3252 | threshold=(double) QuantumRange/2; |
| 3253 | if (normal_op) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3254 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3255 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3256 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3257 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3258 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3259 | break; |
| 3260 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3261 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3262 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3263 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3264 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3265 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3266 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3267 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3268 | break; |
| 3269 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3270 | if (LocaleCompare("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3271 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3272 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3273 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3274 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3275 | break; |
| 3276 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3277 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3278 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3279 | CLIWandWarnReplaced("+distort AffineProjection"); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3280 | new_image=AffineTransformImage(_image,&_draw_info->affine,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3281 | break; |
| 3282 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3283 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3284 | { |
| 3285 | PixelInfo |
| 3286 | target; |
| 3287 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3288 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3289 | (void) TransparentPaintImage(_image,&target,(Quantum) |
| 3290 | TransparentAlpha,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3291 | break; |
| 3292 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3293 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3294 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3295 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3296 | break; |
| 3297 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3298 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3299 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3300 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3301 | break; |
| 3302 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3303 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3304 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3305 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3306 | break; |
| 3307 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3308 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3309 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3310 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3311 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3312 | break; |
| 3313 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3314 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3315 | } |
| 3316 | case 'u': |
| 3317 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3318 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3319 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3320 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? |
| 3321 | Option is not documented, bt appears to be for "identify". |
| 3322 | We may need a identify specific verbose! |
| 3323 | */ |
| 3324 | if (plus_alt_op) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3325 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3326 | break; |
| 3327 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3328 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3329 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3330 | break; |
| 3331 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3332 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3333 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3334 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3335 | break; |
| 3336 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3337 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3338 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3339 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3340 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3341 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3342 | if ((flags & SigmaValue) == 0) |
| 3343 | geometry_info.sigma=1.0; |
| 3344 | if ((flags & XiValue) == 0) |
| 3345 | geometry_info.xi=1.0; |
| 3346 | if ((flags & PsiValue) == 0) |
| 3347 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3348 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
| 3349 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3350 | break; |
| 3351 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3352 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3353 | } |
| 3354 | case 'v': |
| 3355 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3356 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3357 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3358 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3359 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3360 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3361 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3362 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3363 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3364 | break; |
| 3365 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3366 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3367 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3368 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3369 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3370 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3371 | if ((flags & SigmaValue) == 0) |
| 3372 | geometry_info.sigma=1.0; |
| 3373 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3374 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3375 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3376 | geometry_info.psi=0.1*_image->rows; |
| 3377 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3378 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3379 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3380 | break; |
| 3381 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3382 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3383 | } |
| 3384 | case 'w': |
| 3385 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3386 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3387 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3388 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3389 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3390 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3391 | if ((flags & SigmaValue) == 0) |
| 3392 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3393 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3394 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3395 | break; |
| 3396 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3397 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3398 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3399 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3400 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3401 | (void) WhiteThresholdImage(_image,arg1,_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 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3407 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3408 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 3409 | /* clean up percent escape interpreted strings */ |
| 3410 | if (arg1 != arg1n ) |
| 3411 | arg1=DestroyString((char *)arg1); |
| 3412 | if (arg2 != arg2n ) |
| 3413 | arg2=DestroyString((char *)arg2); |
| 3414 | |
| 3415 | /* Replace current image with any image that was generated |
| 3416 | and set image point to last image (so image->next is correct) */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3417 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3418 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3419 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3420 | return; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3421 | #undef _image_info |
| 3422 | #undef _draw_info |
| 3423 | #undef _quantize_info |
| 3424 | #undef _image |
| 3425 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3426 | #undef IfNormalOp |
| 3427 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3428 | #undef normal_op |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3429 | #undef plus_alt_op |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3430 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3431 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3432 | WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3433 | const char *option, const char *arg1, const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3434 | { |
| 3435 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3436 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3437 | i; |
| 3438 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3439 | assert(cli_wand != (MagickCLI *) NULL); |
| 3440 | assert(cli_wand->signature == WandSignature); |
| 3441 | assert(cli_wand->wand.signature == WandSignature); |
| 3442 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3443 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3444 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3445 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3446 | #if !USE_WAND_METHODS |
| 3447 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3448 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3449 | n=GetImageListLength(cli_wand->wand.images); |
| 3450 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3451 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3452 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3453 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3454 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3455 | break; |
| 3456 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3457 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3458 | assert( i == n ); |
| 3459 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3460 | #else |
| 3461 | MagickResetIterator(&cli_wand->wand); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3462 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3463 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3464 | MagickResetIterator(&cli_wand->wand); |
| 3465 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3466 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3467 | } |
| 3468 | |
| 3469 | /* |
| 3470 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3471 | % % |
| 3472 | % % |
| 3473 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3474 | + 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] | 3475 | % % |
| 3476 | % % |
| 3477 | % % |
| 3478 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3479 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3480 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3481 | % entire image list as a whole. The result is often a complete replacment |
| 3482 | % 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] | 3483 | % |
| 3484 | % The format of the MogrifyImage method is: |
| 3485 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3486 | % void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3487 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3488 | % |
| 3489 | % A description of each parameter follows: |
| 3490 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3491 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3492 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3493 | % o option: The option string for the operation |
| 3494 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3495 | % o arg1, arg2: optional argument strings to the operation |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3496 | % arg2 is currently not used |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3497 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3498 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3499 | WandExport void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 3500 | const char *option,const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3501 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3502 | ssize_t |
| 3503 | parse; |
| 3504 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3505 | Image |
| 3506 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3507 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 3508 | const char /* For percent escape interpretImageProperties() */ |
| 3509 | *arg1, |
| 3510 | *arg2; |
| 3511 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3512 | #define _image_info (cli_wand->wand.image_info) |
| 3513 | #define _images (cli_wand->wand.images) |
| 3514 | #define _exception (cli_wand->wand.exception) |
| 3515 | #define _draw_info (cli_wand->draw_info) |
| 3516 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 3517 | #define _process_flags (cli_wand->process_flags) |
| 3518 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3519 | #define IfNormalOp (*option=='-') |
| 3520 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3521 | #define normal_op IsMagickTrue(IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3522 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3523 | assert(cli_wand != (MagickCLI *) NULL); |
| 3524 | assert(cli_wand->signature == WandSignature); |
| 3525 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3526 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3527 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3528 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3529 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 3530 | /* Interpret Percent Escapes in Arguments - using first image */ |
| 3531 | arg1 = arg1n; |
| 3532 | arg2 = arg2n; |
| 3533 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 3534 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 3535 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 3536 | /* Interpret Percent escapes in argument 1 */ |
| 3537 | if (arg1n != (char *) NULL) { |
| 3538 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 3539 | if (arg1 == (char *) NULL) { |
| 3540 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3541 | arg1=arg1n; /* use the given argument as is */ |
| 3542 | } |
| 3543 | } |
| 3544 | if (arg2n != (char *) NULL) { |
| 3545 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 3546 | if (arg2 == (char *) NULL) { |
| 3547 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3548 | arg2=arg2n; /* use the given argument as is */ |
| 3549 | } |
| 3550 | } |
| 3551 | } |
| 3552 | #undef _option_type |
| 3553 | |
| 3554 | #if 0 |
| 3555 | (void) FormatLocaleFile(stderr, |
| 3556 | "CLIListOperatorImages: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); |
| 3557 | #endif |
| 3558 | |
| 3559 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3560 | new_images=NewImageList(); |
| 3561 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3562 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3563 | { |
| 3564 | case 'a': |
| 3565 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3566 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3567 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3568 | new_images=AppendImages(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3569 | break; |
| 3570 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3571 | if (LocaleCompare("average",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3572 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3573 | CLIWandWarnReplaced("-evaluate-sequence Mean"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3574 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3575 | break; |
| 3576 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3577 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3578 | } |
| 3579 | case 'c': |
| 3580 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3581 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3582 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3583 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3584 | break; |
| 3585 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3586 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3587 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3588 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3589 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3590 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3591 | /* FUTURE - make this a compose option, and thus can be used |
| 3592 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3593 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3594 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3595 | new_images=RemoveFirstImageFromList(&_images); |
| 3596 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3597 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3598 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3599 | break; |
cristy | e52fb5e | 2012-04-06 23:30:20 +0000 | [diff] [blame] | 3600 | (void) ClutImage(new_images,clut_image,new_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3601 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3602 | break; |
| 3603 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3604 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3605 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3606 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3607 | break; |
| 3608 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3609 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3610 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3611 | /* FUTURE - this may be replaced by a 'channel' method */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3612 | new_images=CombineImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3613 | break; |
| 3614 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3615 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3616 | { |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3617 | CompositeOperator |
| 3618 | compose; |
| 3619 | |
| 3620 | const char* |
| 3621 | value; |
| 3622 | |
| 3623 | MagickBooleanType |
| 3624 | clip_to_self; |
| 3625 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3626 | Image |
| 3627 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3628 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3629 | |
| 3630 | RectangleInfo |
| 3631 | geometry; |
| 3632 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3633 | /* Compose value from "-compose" option only */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3634 | value=GetImageOption(_image_info,"compose"); |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3635 | if (value == (const char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3636 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3637 | else |
| 3638 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 3639 | MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3640 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3641 | /* Get "clip-to-self" expert setting (false is normal) */ |
cristy | ca0e82c | 2012-04-10 11:53:24 +0000 | [diff] [blame] | 3642 | value=GetImageOption(_image_info,"compose:clip-to-self"); |
| 3643 | if (value == (const char *) NULL) |
| 3644 | clip_to_self=MagickTrue; |
| 3645 | else |
| 3646 | clip_to_self=IsStringTrue(GetImageOption(_image_info, |
| 3647 | "compose:clip-to-self")); /* if this is true */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3648 | value=GetImageOption(_image_info,"compose:outside-overlay"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3649 | if (value != (const char *) NULL) { /* or this false */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3650 | /* FUTURE: depreciate warning for "compose:outside-overlay"*/ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3651 | clip_to_self= IsMagickFalse(IsStringNotFalse(value)); |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3652 | } |
| 3653 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3654 | new_images=RemoveFirstImageFromList(&_images); |
| 3655 | source_image=RemoveFirstImageFromList(&_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3656 | if (source_image == (Image *) NULL) |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3657 | break; /* FUTURE - produce Exception, rather than silent fail */ |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3658 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3659 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3660 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3661 | source_image->geometry,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3662 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3663 | SetGeometry(source_image,&geometry); |
| 3664 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3665 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
| 3666 | new_images->gravity, &geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3667 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3668 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3669 | if (mask_image != (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3670 | { /* handle a third write mask image */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3671 | if ((compose == DisplaceCompositeOp) || |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3672 | (compose == DistortCompositeOp)) { |
| 3673 | /* Merge Y displacement into X displace/distort map. */ |
| 3674 | (void) CompositeImage(source_image,mask_image, |
| 3675 | CopyGreenCompositeOp,MagickTrue,0,0,_exception); |
| 3676 | mask_image=DestroyImage(mask_image); |
| 3677 | } |
| 3678 | else { |
| 3679 | /* Set a blending mask for the composition. */ |
| 3680 | (void) NegateImage(mask_image,MagickFalse,_exception); |
cristy | 665e18f | 2012-05-17 12:39:54 +0000 | [diff] [blame] | 3681 | (void) SetImageMask(source_image,mask_image,_exception); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3682 | mask_image=DestroyImage(mask_image); |
| 3683 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3684 | } |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3685 | (void) CompositeImage(new_images,source_image,compose,clip_to_self, |
| 3686 | geometry.x,geometry.y,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3687 | (void) SetImageMask(new_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3688 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3689 | break; |
| 3690 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3691 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3692 | } |
| 3693 | case 'd': |
| 3694 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3695 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3696 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3697 | CLIWandWarnReplaced("-layer CompareAny"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3698 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3699 | break; |
| 3700 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3701 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3702 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3703 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3704 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3705 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3706 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3707 | break; |
| 3708 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3709 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3710 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3711 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3712 | { |
| 3713 | const char |
| 3714 | *p; |
| 3715 | |
| 3716 | size_t |
| 3717 | number_duplicates; |
| 3718 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3719 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3720 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3721 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3722 | number_duplicates=(size_t) StringToLong(arg1); |
| 3723 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3724 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3725 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3726 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3727 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3728 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3729 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3730 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3731 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3732 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3733 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3734 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3735 | break; |
| 3736 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3737 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3738 | } |
| 3739 | case 'e': |
| 3740 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3741 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3742 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3743 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3744 | if ( parse < 0 ) |
| 3745 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3746 | option,arg1); |
| 3747 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
| 3748 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3749 | break; |
| 3750 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3751 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3752 | } |
| 3753 | case 'f': |
| 3754 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3755 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3756 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3757 | new_images=ForwardFourierTransformImage(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3758 | break; |
| 3759 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3760 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3761 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3762 | /* REDIRECTED to use -layers flatten instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3763 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3764 | break; |
| 3765 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3766 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3767 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3768 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3769 | break; |
| 3770 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3771 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3772 | } |
| 3773 | case 'h': |
| 3774 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3775 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3776 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3777 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3778 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3779 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3780 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3781 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3782 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3783 | new_images=RemoveFirstImageFromList(&_images); |
| 3784 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3785 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3786 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3787 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3788 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3789 | break; |
| 3790 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3791 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3792 | } |
| 3793 | case 'i': |
| 3794 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3795 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3796 | { |
| 3797 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3798 | *magnitude_image, |
| 3799 | *phase_image; |
| 3800 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3801 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3802 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3803 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3804 | if (phase_image == (Image *) NULL) |
| 3805 | break; |
| 3806 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3807 | normal_op,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3808 | magnitude_image=DestroyImage(magnitude_image); |
| 3809 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3810 | break; |
| 3811 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3812 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3813 | { |
| 3814 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3815 | *insert_image, |
| 3816 | *index_image; |
| 3817 | |
| 3818 | ssize_t |
| 3819 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3820 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3821 | if (IfNormalOp && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3822 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3823 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3824 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3825 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3826 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3827 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3828 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3829 | PrependImageToList(&_images,insert_image); |
| 3830 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3831 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3832 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3833 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3834 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3835 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3836 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3837 | InsertImageInList(&index_image,insert_image); |
| 3838 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3839 | _images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3840 | break; |
| 3841 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3842 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3843 | } |
| 3844 | case 'l': |
| 3845 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3846 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3847 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3848 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3849 | if ( parse < 0 ) |
| 3850 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3851 | option,arg1); |
| 3852 | switch ((ImageLayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3853 | { |
| 3854 | case CoalesceLayer: |
| 3855 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3856 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3857 | break; |
| 3858 | } |
| 3859 | case CompareAnyLayer: |
| 3860 | case CompareClearLayer: |
| 3861 | case CompareOverlayLayer: |
| 3862 | default: |
| 3863 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3864 | new_images=CompareImagesLayers(_images,(ImageLayerMethod) parse, |
| 3865 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3866 | break; |
| 3867 | } |
| 3868 | case MergeLayer: |
| 3869 | case FlattenLayer: |
| 3870 | case MosaicLayer: |
| 3871 | case TrimBoundsLayer: |
| 3872 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3873 | new_images=MergeImageLayers(_images,(ImageLayerMethod) parse, |
| 3874 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3875 | break; |
| 3876 | } |
| 3877 | case DisposeLayer: |
| 3878 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3879 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3880 | break; |
| 3881 | } |
| 3882 | case OptimizeImageLayer: |
| 3883 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3884 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3885 | break; |
| 3886 | } |
| 3887 | case OptimizePlusLayer: |
| 3888 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3889 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3890 | break; |
| 3891 | } |
| 3892 | case OptimizeTransLayer: |
| 3893 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3894 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3895 | break; |
| 3896 | } |
| 3897 | case RemoveDupsLayer: |
| 3898 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3899 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3900 | break; |
| 3901 | } |
| 3902 | case RemoveZeroLayer: |
| 3903 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3904 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3905 | break; |
| 3906 | } |
| 3907 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3908 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3909 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3910 | if (new_images == (Image *) NULL) |
| 3911 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3912 | _images=DestroyImageList(_images); |
| 3913 | _images=OptimizeImageLayers(new_images,_exception); |
| 3914 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3915 | break; |
| 3916 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3917 | OptimizeImageTransparency(_images,_exception); |
| 3918 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 3919 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3920 | break; |
| 3921 | } |
| 3922 | case CompositeLayer: |
| 3923 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3924 | Image |
| 3925 | *source; |
| 3926 | |
| 3927 | RectangleInfo |
| 3928 | geometry; |
| 3929 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3930 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3931 | compose; |
| 3932 | |
| 3933 | const char* |
| 3934 | value; |
| 3935 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3936 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3937 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3938 | if (value != (const char *) NULL) |
| 3939 | compose=(CompositeOperator) ParseCommandOption( |
| 3940 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3941 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3942 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3943 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3944 | while (source != (Image *) NULL) |
| 3945 | { |
| 3946 | source=GetNextImageInList(source); |
| 3947 | if ((source != (Image *) NULL) && |
| 3948 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 3949 | break; |
| 3950 | } |
| 3951 | if (source != (Image *) NULL) |
| 3952 | { |
| 3953 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 3954 | (GetNextImageInList(source) == (Image *) NULL)) |
| 3955 | source=(Image *) NULL; |
| 3956 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3957 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3958 | source=SplitImageList(source->previous); |
| 3959 | DeleteImageFromList(&source); |
| 3960 | } |
| 3961 | } |
| 3962 | if (source == (Image *) NULL) |
| 3963 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3964 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3965 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3966 | break; |
| 3967 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3968 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3969 | SetGeometry(_images,&geometry); |
| 3970 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3971 | geometry.width=source->page.width != 0 ? |
| 3972 | source->page.width : source->columns; |
| 3973 | geometry.height=source->page.height != 0 ? |
| 3974 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3975 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 3976 | _images->page.width : _images->columns, |
| 3977 | _images->page.height != 0 ? _images->page.height : |
| 3978 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3979 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3980 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3981 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 3982 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3983 | source=DestroyImageList(source); |
| 3984 | break; |
| 3985 | } |
| 3986 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3987 | break; |
| 3988 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3989 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3990 | } |
| 3991 | case 'm': |
| 3992 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3993 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3994 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3995 | CLIWandWarnReplaced("+remap"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3996 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3997 | break; |
| 3998 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3999 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4000 | { |
| 4001 | Image |
| 4002 | *morph_image; |
| 4003 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4004 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 4005 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4006 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4007 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4008 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4009 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4010 | _images=DestroyImageList(_images); |
| 4011 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4012 | break; |
| 4013 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4014 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4015 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4016 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 4017 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4018 | break; |
| 4019 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4020 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4021 | } |
| 4022 | case 'p': |
| 4023 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4024 | if (LocaleCompare("print",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4025 | { |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4026 | (void) FormatLocaleFile(stdout,"%s",arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4027 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4028 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4029 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4030 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 4031 | /* FUTURE: better parsing using ScriptToken() from string ??? */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4032 | char |
| 4033 | **arguments; |
| 4034 | |
| 4035 | int |
| 4036 | j, |
| 4037 | number_arguments; |
| 4038 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4039 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4040 | if (arguments == (char **) NULL) |
| 4041 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4042 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4043 | { |
| 4044 | char |
| 4045 | breaker, |
| 4046 | quote, |
| 4047 | *token; |
| 4048 | |
| 4049 | const char |
| 4050 | *arguments; |
| 4051 | |
| 4052 | int |
| 4053 | next, |
| 4054 | status; |
| 4055 | |
| 4056 | size_t |
| 4057 | length; |
| 4058 | |
| 4059 | TokenInfo |
| 4060 | *token_info; |
| 4061 | |
| 4062 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4063 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4064 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4065 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4066 | token=(char *) NULL; |
| 4067 | if (~length >= (MaxTextExtent-1)) |
| 4068 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4069 | sizeof(*token)); |
| 4070 | if (token == (char *) NULL) |
| 4071 | break; |
| 4072 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4073 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4074 | token_info=AcquireTokenInfo(); |
| 4075 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4076 | "\"",'\0',&breaker,&next,"e); |
| 4077 | token_info=DestroyTokenInfo(token_info); |
| 4078 | if (status == 0) |
| 4079 | { |
| 4080 | const char |
| 4081 | *argv; |
| 4082 | |
| 4083 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4084 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4085 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4086 | } |
| 4087 | token=DestroyString(token); |
| 4088 | break; |
| 4089 | } |
| 4090 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4091 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4092 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4093 | for (j=0; j < number_arguments; j++) |
| 4094 | arguments[j]=DestroyString(arguments[j]); |
| 4095 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4096 | break; |
| 4097 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4098 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4099 | } |
| 4100 | case 'r': |
| 4101 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4102 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4103 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4104 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4105 | break; |
| 4106 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4107 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4108 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4109 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4110 | break; |
| 4111 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4112 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4113 | } |
| 4114 | case 's': |
| 4115 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4116 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4117 | { |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4118 | /* FUTURE: this option needs more work to make better */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4119 | ssize_t |
| 4120 | offset; |
| 4121 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4122 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 4123 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4124 | offset=(ssize_t) StringToLong(arg1); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4125 | new_images=SmushImages(_images,normal_op,offset,_exception); |
| 4126 | break; |
| 4127 | } |
| 4128 | if (LocaleCompare("subimage",option+1) == 0) |
| 4129 | { |
| 4130 | Image |
| 4131 | *base_image, |
| 4132 | *compare_image; |
| 4133 | |
| 4134 | const char * |
| 4135 | value; |
| 4136 | |
| 4137 | MetricType |
| 4138 | metric; |
| 4139 | |
| 4140 | double |
| 4141 | similarity; |
| 4142 | |
| 4143 | RectangleInfo |
| 4144 | offset; |
| 4145 | |
| 4146 | base_image=GetImageFromList(_images,0); |
| 4147 | compare_image=GetImageFromList(_images,1); |
| 4148 | |
| 4149 | /* Comparision Metric */ |
| 4150 | metric=UndefinedMetric; |
| 4151 | value=GetImageOption(_image_info,"metric"); |
| 4152 | if (value != (const char *) NULL) |
| 4153 | metric=(MetricType) ParseCommandOption(MagickMetricOptions, |
| 4154 | MagickFalse,value); |
| 4155 | |
| 4156 | new_images=SimilarityImage(base_image,compare_image,metric, |
| 4157 | &offset,&similarity,_exception); |
| 4158 | |
| 4159 | if ( new_images != (Image *)NULL ) { |
| 4160 | char |
| 4161 | result[MaxTextExtent]; |
| 4162 | |
| 4163 | (void) FormatLocaleString(result,MaxTextExtent,"%lf",similarity); |
| 4164 | (void) SetImageProperty(new_images,"subimage:similarity",result, |
| 4165 | _exception); |
| 4166 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4167 | (long) offset.x); |
| 4168 | (void) SetImageProperty(new_images,"subimage:x",result, |
| 4169 | _exception); |
| 4170 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4171 | (long) offset.y); |
| 4172 | (void) SetImageProperty(new_images,"subimage:y",result, |
| 4173 | _exception); |
| 4174 | (void) FormatLocaleString(result,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 4175 | (unsigned long) offset.width,(unsigned long) offset.height, |
| 4176 | (long) offset.x,(long) offset.y); |
| 4177 | (void) SetImageProperty(new_images,"subimage:offset",result, |
| 4178 | _exception); |
| 4179 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4180 | break; |
| 4181 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4182 | if (LocaleCompare("swap",option+1) == 0) { |
| 4183 | Image |
| 4184 | *p, |
| 4185 | *q, |
| 4186 | *swap; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4187 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4188 | ssize_t |
| 4189 | index, |
| 4190 | swap_index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4191 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4192 | index=-1; |
| 4193 | swap_index=-2; |
| 4194 | if (IfNormalOp) { |
| 4195 | GeometryInfo |
| 4196 | geometry_info; |
| 4197 | |
| 4198 | MagickStatusType |
| 4199 | flags; |
| 4200 | |
| 4201 | swap_index=(-1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4202 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 4203 | if ((flags & RhoValue) != 0) |
| 4204 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4205 | index=(ssize_t) geometry_info.rho; |
| 4206 | if ((flags & SigmaValue) != 0) |
| 4207 | swap_index=(ssize_t) geometry_info.sigma; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4208 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4209 | p=GetImageFromList(_images,index); |
| 4210 | q=GetImageFromList(_images,swap_index); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4211 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) { |
| 4212 | if (IfNormalOp) |
| 4213 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1) |
| 4214 | else |
| 4215 | CLIWandExceptionBreak(OptionError,"TwoOrMoreImagesRequired",option); |
| 4216 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4217 | if (p == q) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4218 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4219 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4220 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
| 4221 | ReplaceImageInList(&q,swap); |
| 4222 | _images=GetFirstImageInList(q); |
| 4223 | break; |
| 4224 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4225 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4226 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4227 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4228 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4229 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4230 | |
| 4231 | /* clean up percent escape interpreted strings */ |
| 4232 | if (arg1 != arg1n ) |
| 4233 | arg1=DestroyString((char *)arg1); |
| 4234 | if (arg2 != arg2n ) |
| 4235 | arg2=DestroyString((char *)arg2); |
| 4236 | |
| 4237 | /* if new image list generated, replace existing image list */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4238 | if (new_images == (Image *) NULL) |
| 4239 | return; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4240 | _images=DestroyImageList(_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4241 | _images=GetFirstImageInList(new_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4242 | return; |
| 4243 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4244 | #undef _image_info |
| 4245 | #undef _images |
| 4246 | #undef _exception |
| 4247 | #undef _draw_info |
| 4248 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4249 | #undef IfNormalOp |
| 4250 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4251 | #undef normal_op |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4252 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4253 | |
| 4254 | /* |
| 4255 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4256 | % % |
| 4257 | % % |
| 4258 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4259 | + 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] | 4260 | % % |
| 4261 | % % |
| 4262 | % % |
| 4263 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4264 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4265 | % CLINoImageOperator() Applies operations that may not actually need images |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4266 | % in an image list. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4267 | % |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4268 | % The classic operators of this type is -read, which actually creates images |
| 4269 | % even when no images are present. Or image stack operators, which can be |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4270 | % applied (push or pop) to an empty image list. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4271 | % |
| 4272 | % Note: unlike other Operators, these may involve other special 'option' |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4273 | % characters other than '-' or '+', namely parenthesis and braces. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4274 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4275 | % The format of the CLINoImageOption method is: |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4276 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4277 | % void CLINoImageOption(MagickCLI *cli_wand,const char *option, |
| 4278 | % const char *arg1, const char *arg2) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4279 | % |
| 4280 | % A description of each parameter follows: |
| 4281 | % |
| 4282 | % o cli_wand: the main CLI Wand to use. |
| 4283 | % |
| 4284 | % o option: The special option (with any switch char) to process |
| 4285 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4286 | % o arg1 & arg2: Argument for option, if required |
| 4287 | % Currently arg2 is not used. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4288 | % |
| 4289 | */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4290 | WandExport void CLINoImageOperator(MagickCLI *cli_wand, |
| 4291 | const char *option, const char *arg1, const char *magick_unused(arg2)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4292 | { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4293 | #define _image_info (cli_wand->wand.image_info) |
| 4294 | #define _images (cli_wand->wand.images) |
| 4295 | #define _exception (cli_wand->wand.exception) |
| 4296 | #define IfNormalOp (*option=='-') |
| 4297 | #define IfPlusOp (*option!='-') |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4298 | |
| 4299 | assert(cli_wand != (MagickCLI *) NULL); |
| 4300 | assert(cli_wand->signature == WandSignature); |
| 4301 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4302 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4303 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4304 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4305 | /* |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4306 | No-op options (ignore these) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4307 | */ |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4308 | if (LocaleCompare("noop",option+1) == 0) /* no argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4309 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4310 | if (LocaleCompare("sans",option+1) == 0) /* one argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4311 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4312 | if (LocaleCompare("sans0",option+1) == 0) /* no argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4313 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4314 | if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4315 | return; |
| 4316 | /* |
| 4317 | Image Reading |
| 4318 | */ |
| 4319 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4320 | ( LocaleCompare("--",option) == 0 ) ) { |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4321 | #if 0 |
| 4322 | /* Directly read 'arg1' without filename expansion handling (see below). |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4323 | */ |
anthony | 9b33b25 | 2012-04-29 12:29:31 +0000 | [diff] [blame] | 4324 | # if !USE_WAND_METHODS |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4325 | Image *new_images; |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4326 | |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4327 | if (IfMagickTrue(_image_info->ping)) |
| 4328 | new_images=PingImages(_image_info,arg1,_exception); |
| 4329 | else |
| 4330 | new_images=ReadImages(_image_info,arg1,_exception); |
| 4331 | AppendImageToList(&_images, new_images); |
anthony | 9b33b25 | 2012-04-29 12:29:31 +0000 | [diff] [blame] | 4332 | # else |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4333 | /* read images using MagickWand method - no ping */ |
| 4334 | /* This is not working! - it locks up in a CPU loop! */ |
| 4335 | MagickSetLastIterator(&cli_wand->wand); |
| 4336 | MagickReadImage(&cli_wand->wand,arg1); |
| 4337 | MagickSetFirstIterator(&cli_wand->wand); |
anthony | 9b33b25 | 2012-04-29 12:29:31 +0000 | [diff] [blame] | 4338 | # endif |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4339 | #else |
| 4340 | /* Do Filename Expansion for 'arg1' then read all images. |
| 4341 | * |
| 4342 | * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring |
| 4343 | * (but attaching to generated argument list) any [...] read modifiers |
| 4344 | * that may be present. |
| 4345 | * |
| 4346 | * For example: correctly expand '*.gif[20x20]' into a list such as |
| 4347 | * 'abc.gif[20x20', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]' |
| 4348 | * |
| 4349 | * NOTE: In IMv6 this was done globally across all images. This |
| 4350 | * meant you could include IM options in '@filename' lists, but you |
| 4351 | * could not include comments. Doing it only for image read makes |
| 4352 | * it far more secure. |
| 4353 | */ |
| 4354 | int argc; |
| 4355 | char **argv; |
| 4356 | ssize_t i; |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4357 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4358 | argc = 1; |
cristy | e71f294 | 2012-04-04 11:07:05 +0000 | [diff] [blame] | 4359 | argv = (char **) &arg1; |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4360 | |
anthony | 451f909 | 2012-05-11 01:56:24 +0000 | [diff] [blame] | 4361 | /* Expand 'glob' expressions in the given filename. |
| 4362 | Expansion handles any 'coder:' prefix, or read modifiers attached |
| 4363 | to the filename, including them in the resulting expanded list. |
| 4364 | */ |
| 4365 | if (IfMagickFalse( ExpandFilenames(&argc,&argv) )) |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4366 | CLIWandExceptArgReturn(ResourceLimitError,"MemoryAllocationFailed", |
| 4367 | option,GetExceptionMessage(errno)); |
| 4368 | |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4369 | /* loop over expanded filename list, and read then all in */ |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4370 | for (i=0; i<argc; i++) { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4371 | Image * |
| 4372 | new_images; |
anthony | ff134e6 | 2012-04-30 04:25:09 +0000 | [diff] [blame] | 4373 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4374 | fprintf(stderr, "DEBUG: Reading image: \"%s\"\n", argv[i]); |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4375 | #endif |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4376 | if (IfMagickTrue(_image_info->ping)) |
| 4377 | new_images=PingImages(_image_info,argv[i],_exception); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4378 | else |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4379 | new_images=ReadImages(_image_info,argv[i],_exception); |
| 4380 | AppendImageToList(&_images, new_images); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4381 | } |
anthony | 451f909 | 2012-05-11 01:56:24 +0000 | [diff] [blame] | 4382 | argv=DestroyStringList(argv); /* Destroy the Expanded Filename list */ |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4383 | #endif |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4384 | return; |
| 4385 | } |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4386 | /* |
anthony | de897b7 | 2012-04-27 00:16:17 +0000 | [diff] [blame] | 4387 | Image Writing |
| 4388 | Note: Writing a empty image list is valid in specific cases |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4389 | */ |
| 4390 | if (LocaleCompare("write",option+1) == 0) { |
| 4391 | char |
| 4392 | key[MaxTextExtent]; |
| 4393 | |
| 4394 | Image |
| 4395 | *write_images; |
| 4396 | |
| 4397 | ImageInfo |
| 4398 | *write_info; |
| 4399 | |
| 4400 | /* Need images, unless a "null:" output coder is used */ |
| 4401 | if ( cli_wand->wand.images == (Image *) NULL ) { |
anthony | a9e4f5d | 2012-04-12 06:44:02 +0000 | [diff] [blame] | 4402 | if ( LocaleCompare(arg1,"null:") == 0 ) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4403 | return; |
| 4404 | CLIWandExceptArgReturn(OptionError,"NoImagesForWrite",option,arg1); |
| 4405 | } |
| 4406 | |
| 4407 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
| 4408 | (void) DeleteImageRegistry(key); |
| 4409 | write_images=_images; |
| 4410 | if (IfPlusOp) |
| 4411 | write_images=CloneImageList(_images,_exception); |
| 4412 | write_info=CloneImageInfo(_image_info); |
| 4413 | (void) WriteImages(write_info,write_images,arg1,_exception); |
| 4414 | write_info=DestroyImageInfo(write_info); |
| 4415 | if (IfPlusOp) |
| 4416 | write_images=DestroyImageList(write_images); |
| 4417 | return; |
| 4418 | } |
| 4419 | /* |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4420 | Parenthesis and Brace operations |
| 4421 | */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4422 | if (LocaleCompare("(",option) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4423 | /* stack 'push' images */ |
| 4424 | Stack |
| 4425 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4426 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4427 | size_t |
| 4428 | size; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4429 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4430 | size=0; |
| 4431 | node=cli_wand->image_list_stack; |
| 4432 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4433 | size++; |
| 4434 | if ( size >= MAX_STACK_DEPTH ) |
| 4435 | CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option); |
| 4436 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4437 | if (node == (Stack *) NULL) |
| 4438 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4439 | "MemoryAllocationFailed",option); |
| 4440 | node->data = (void *)cli_wand->wand.images; |
| 4441 | cli_wand->wand.images = NewImageList(); |
| 4442 | node->next = cli_wand->image_list_stack; |
| 4443 | cli_wand->image_list_stack = node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4444 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4445 | /* handle respect-parenthesis */ |
| 4446 | if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info, |
| 4447 | "respect-parenthesis")))) |
| 4448 | option="{"; /* fall-thru so as to push image settings too */ |
| 4449 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4450 | return; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4451 | } |
| 4452 | if (LocaleCompare("{",option) == 0) { |
| 4453 | /* stack 'push' of image_info settings */ |
| 4454 | Stack |
| 4455 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4456 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4457 | size_t |
| 4458 | size; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4459 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4460 | size=0; |
| 4461 | node=cli_wand->image_info_stack; |
| 4462 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4463 | size++; |
| 4464 | if ( size >= MAX_STACK_DEPTH ) |
| 4465 | CLIWandExceptionReturn(OptionError,"CurlyBracesNestedTooDeeply",option); |
| 4466 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4467 | if (node == (Stack *) NULL) |
| 4468 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4469 | "MemoryAllocationFailed",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4470 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4471 | node->data = (void *)cli_wand->wand.image_info; |
| 4472 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
| 4473 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
| 4474 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4475 | option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4476 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4477 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4478 | return; |
| 4479 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4480 | |
| 4481 | node->next = cli_wand->image_info_stack; |
| 4482 | cli_wand->image_info_stack = node; |
| 4483 | |
| 4484 | return; |
| 4485 | } |
| 4486 | if (LocaleCompare(")",option) == 0) { |
| 4487 | /* pop images from stack */ |
| 4488 | Stack |
| 4489 | *node; |
| 4490 | |
| 4491 | node = (Stack *)cli_wand->image_list_stack; |
| 4492 | if ( node == (Stack *)NULL) |
| 4493 | CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option); |
| 4494 | cli_wand->image_list_stack = node->next; |
| 4495 | |
| 4496 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4497 | cli_wand->wand.images= (Image *)node->data; |
| 4498 | node = (Stack *)RelinquishMagickMemory(node); |
| 4499 | |
| 4500 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
| 4501 | node = cli_wand->image_info_stack; |
| 4502 | if ( node != (Stack *)NULL) |
| 4503 | { |
| 4504 | if (IfMagickTrue(IsStringTrue(GetImageOption( |
| 4505 | cli_wand->wand.image_info,"respect-parenthesis")))) |
| 4506 | option="}"; /* fall-thru so as to pop image settings too */ |
| 4507 | else |
| 4508 | return; |
| 4509 | } |
| 4510 | else |
| 4511 | return; |
| 4512 | } |
| 4513 | if (LocaleCompare("}",option) == 0) { |
| 4514 | /* pop image_info settings from stack */ |
| 4515 | Stack |
| 4516 | *node; |
| 4517 | |
| 4518 | node = (Stack *)cli_wand->image_info_stack; |
| 4519 | if ( node == (Stack *)NULL) |
| 4520 | CLIWandExceptionReturn(OptionError,"UnbalancedCurlyBraces",option); |
| 4521 | cli_wand->image_info_stack = node->next; |
| 4522 | |
| 4523 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
| 4524 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4525 | node = (Stack *)RelinquishMagickMemory(node); |
| 4526 | |
| 4527 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4528 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4529 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4530 | |
| 4531 | return; |
| 4532 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4533 | if (LocaleCompare("clone",option+1) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4534 | Image |
| 4535 | *new_images; |
| 4536 | |
| 4537 | if (*option == '+') |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4538 | arg1="-1"; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4539 | if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4540 | CLIWandExceptionReturn(OptionError,"InvalidArgument",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4541 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4542 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4543 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4544 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4545 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
| 4546 | new_images=CloneImages(new_images,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4547 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4548 | CLIWandExceptionReturn(OptionError,"NoSuchImage",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4549 | AppendImageToList(&_images,new_images); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4550 | return; |
| 4551 | } |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4552 | /* |
| 4553 | Informational Operations |
| 4554 | */ |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4555 | if (LocaleCompare("version",option+1) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4556 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
| 4557 | GetMagickVersion((size_t *) NULL)); |
| 4558 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 4559 | GetMagickCopyright()); |
| 4560 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 4561 | GetMagickFeatures()); |
| 4562 | return; |
| 4563 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4564 | if (LocaleCompare("list",option+1) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4565 | /* FUTURE: This should really be built into the MagickCore |
| 4566 | It does not actually require a cli-wand or and images! |
| 4567 | */ |
| 4568 | ssize_t |
| 4569 | list; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4570 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4571 | list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); |
| 4572 | if ( list < 0 ) { |
| 4573 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4574 | return; |
| 4575 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4576 | switch (list) |
| 4577 | { |
| 4578 | case MagickCoderOptions: |
| 4579 | { |
| 4580 | (void) ListCoderInfo((FILE *) NULL,_exception); |
| 4581 | break; |
| 4582 | } |
| 4583 | case MagickColorOptions: |
| 4584 | { |
| 4585 | (void) ListColorInfo((FILE *) NULL,_exception); |
| 4586 | break; |
| 4587 | } |
| 4588 | case MagickConfigureOptions: |
| 4589 | { |
| 4590 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
| 4591 | break; |
| 4592 | } |
| 4593 | case MagickDelegateOptions: |
| 4594 | { |
| 4595 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
| 4596 | break; |
| 4597 | } |
| 4598 | case MagickFontOptions: |
| 4599 | { |
| 4600 | (void) ListTypeInfo((FILE *) NULL,_exception); |
| 4601 | break; |
| 4602 | } |
| 4603 | case MagickFormatOptions: |
| 4604 | (void) ListMagickInfo((FILE *) NULL,_exception); |
| 4605 | break; |
| 4606 | case MagickLocaleOptions: |
| 4607 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
| 4608 | break; |
| 4609 | case MagickLogOptions: |
| 4610 | (void) ListLogInfo((FILE *) NULL,_exception); |
| 4611 | break; |
| 4612 | case MagickMagicOptions: |
| 4613 | (void) ListMagicInfo((FILE *) NULL,_exception); |
| 4614 | break; |
| 4615 | case MagickMimeOptions: |
| 4616 | (void) ListMimeInfo((FILE *) NULL,_exception); |
| 4617 | break; |
| 4618 | case MagickModuleOptions: |
| 4619 | (void) ListModuleInfo((FILE *) NULL,_exception); |
| 4620 | break; |
| 4621 | case MagickPolicyOptions: |
| 4622 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
| 4623 | break; |
| 4624 | case MagickResourceOptions: |
| 4625 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
| 4626 | break; |
| 4627 | case MagickThresholdOptions: |
| 4628 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
| 4629 | break; |
| 4630 | default: |
| 4631 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
| 4632 | _exception); |
| 4633 | break; |
| 4634 | } |
| 4635 | return; |
| 4636 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4637 | |
| 4638 | #if 0 |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4639 | // Other 'special' options this should handle |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 4640 | // "region" "reset" "arg" |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4641 | if ( ( process_flags & ProcessUnknownOptionError ) != 0 ) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4642 | #endif |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4643 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4644 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4645 | #undef _image_info |
| 4646 | #undef _images |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4647 | #undef _exception |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4648 | #undef IfNormalOp |
| 4649 | #undef IfPlusOp |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4650 | } |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4651 | |
| 4652 | /* |
| 4653 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4654 | % % |
| 4655 | % % |
| 4656 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4657 | + C L I O p t i o n % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4658 | % % |
| 4659 | % % |
| 4660 | % % |
| 4661 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4662 | % |
| 4663 | % CLIOption() Processes the given option using the given CLI Magick Wand. |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4664 | % The option arguments can be variable in number, though at this time no more |
| 4665 | % that two is actually used by any option (this may change). Excess options |
| 4666 | % are simply ignored. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4667 | % |
| 4668 | % If the cli_wand->command pointer is non-null, then it is assumed that the |
| 4669 | % option has already been search for up from the CommandOptions[] table in |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4670 | % "MagickCore/options.c" using GetCommandOptionInfo(). If not set this |
| 4671 | % routine will do the lookup instead. The pointer is reset afterward. |
| 4672 | % |
| 4673 | % This action allows the caller to lookup and pre-handle any 'special' |
| 4674 | % options, (such as implicit reads) before calling this general option |
| 4675 | % handler to deal with 'standard' command line options. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4676 | % |
| 4677 | % The format of the CLIOption method is: |
| 4678 | % |
| 4679 | % void CLIOption(MagickCLI *cli_wand,const char *option, ...) |
| 4680 | % |
| 4681 | % A description of each parameter follows: |
| 4682 | % |
| 4683 | % o cli_wand: the main CLI Wand to use. |
| 4684 | % |
| 4685 | % o option: The special option (with any switch char) to process |
| 4686 | % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4687 | % o args: any required arguments for an option (variable number) |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4688 | % |
| 4689 | % Example Usage... |
| 4690 | % |
| 4691 | % CLIoption(cli_wand,"-read","rose:"); |
| 4692 | % CLIoption(cli_wand,"-virtual-pixel","transparent"); |
| 4693 | % CLIoption(cli_wand,"-distort","SRT:","30"); |
| 4694 | % CLIoption(cli_wand,"-write","rotated_rose.png"); |
| 4695 | % |
| 4696 | */ |
| 4697 | WandExport void CLIOption(MagickCLI *cli_wand,const char *option,...) |
| 4698 | { |
| 4699 | const char |
| 4700 | *arg1, |
| 4701 | *arg2; |
| 4702 | |
| 4703 | CommandOptionFlags |
| 4704 | option_type; |
| 4705 | |
| 4706 | assert(cli_wand != (MagickCLI *) NULL); |
| 4707 | assert(cli_wand->signature == WandSignature); |
| 4708 | assert(cli_wand->wand.signature == WandSignature); |
| 4709 | if (IfMagickTrue(cli_wand->wand.debug)) |
| 4710 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4711 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4712 | do { /* Break Code Block for error handling */ |
| 4713 | |
| 4714 | /* get information about option */ |
| 4715 | if ( cli_wand->command == (const OptionInfo *) NULL ) |
| 4716 | cli_wand->command = GetCommandOptionInfo(option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4717 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4718 | (void) FormatLocaleFile(stderr, "CLIOption \"%s\" matched \"%s\"\n", |
| 4719 | option, cli_wand->command->mnemonic ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4720 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4721 | option_type=(CommandOptionFlags) cli_wand->command->flags; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4722 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4723 | if ( option_type == UndefinedOptionFlag ) |
| 4724 | CLIWandExceptionReturn(OptionFatalError,"UnrecognizedOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4725 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4726 | assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4727 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4728 | /* depreciated options */ |
| 4729 | if ( (option_type & DeprecateOptionFlag) != 0 ) |
| 4730 | CLIWandExceptionBreak(OptionError,"DeprecatedOptionNoCode",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4731 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4732 | /* options that this module does not handle */ |
| 4733 | if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) |
| 4734 | CLIWandExceptionBreak(OptionFatalError,"InvalidUseOfOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4735 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4736 | /* Get argument strings from VarArgs |
| 4737 | How can you determine arguments is enough was supplied? */ |
| 4738 | { size_t |
| 4739 | count = cli_wand->command->type; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4740 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4741 | va_list |
| 4742 | operands; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4743 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4744 | va_start(operands,option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4745 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4746 | arg1=arg2=NULL; |
| 4747 | if ( count >= 1 ) |
| 4748 | arg1=(const char *) va_arg(operands, const char *); |
| 4749 | if ( count >= 2 ) |
| 4750 | arg2=(const char *) va_arg(operands, const char *); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4751 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4752 | va_end(operands); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4753 | |
anthony | 52cb3df | 2012-04-24 03:29:32 +0000 | [diff] [blame] | 4754 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4755 | (void) FormatLocaleFile(stderr, |
| 4756 | "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n", |
| 4757 | option,(long) count,option_type,arg1,arg2); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4758 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame^] | 4759 | } |
| 4760 | |
| 4761 | /* |
| 4762 | Call the appropriate option handler |
| 4763 | */ |
| 4764 | |
| 4765 | /* FUTURE: this is temporary - get 'settings' to handle distribution of |
| 4766 | settings to images attributes,proprieties,artifacts */ |
| 4767 | if ( cli_wand->wand.images != (Image *)NULL ) |
| 4768 | SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, |
| 4769 | cli_wand->wand.exception); |
| 4770 | |
| 4771 | if ( (option_type & SettingOptionFlags) != 0 ) { |
| 4772 | CLISettingOptionInfo(cli_wand, option, arg1, arg2); |
| 4773 | // FUTURE: Sync Specific Settings into Image Properities (not global) |
| 4774 | } |
| 4775 | |
| 4776 | /* Operators that do not need images - read, write, stack, clone */ |
| 4777 | if ( (option_type & NoImageOperatorFlag) != 0) |
| 4778 | CLINoImageOperator(cli_wand, option, arg1, arg2); |
| 4779 | |
| 4780 | /* FUTURE: The not a setting part below is a temporary hack due to |
| 4781 | * some options being both a Setting and a Simple operator. |
| 4782 | * Specifically -monitor, -depth, and -colorspace */ |
| 4783 | if ( cli_wand->wand.images == (Image *)NULL ) |
| 4784 | if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) && |
| 4785 | ((option_type & SettingOptionFlags) == 0 )) /* temp hack */ |
| 4786 | CLIWandExceptionBreak(OptionError,"NoImagesFound",option); |
| 4787 | |
| 4788 | /* Operators work on single images, and needs a loop over the images */ |
| 4789 | if ( (option_type & SimpleOperatorFlag) != 0) |
| 4790 | CLISimpleOperatorImages(cli_wand, option, arg1, arg2); |
| 4791 | |
| 4792 | /* Operators that work on the image list as a whole */ |
| 4793 | if ( (option_type & ListOperatorFlag) != 0 ) |
| 4794 | CLIListOperatorImages(cli_wand, option, arg1, arg2); |
| 4795 | |
| 4796 | } while (0); /* end Break code block */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4797 | |
| 4798 | cli_wand->command = (const OptionInfo *) NULL; /* prevent re-use later */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4799 | } |