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 | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 369 | + C L I S e t t i n g O p t i o n I n f o % |
| 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 | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 400 | % Example usage... |
| 401 | % |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 402 | % CLISettingOptionInfo(cli_wand, "-background", "Red", NULL); // set value |
| 403 | % CLISettingOptionInfo(cli_wand, "-adjoin", NULL, NULL); // set boolean |
| 404 | % CLISettingOptionInfo(cli_wand, "+adjoin", NULL, NULL); // unset |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 405 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 406 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 407 | % |
| 408 | % argc,argv |
| 409 | % i=index in argv |
| 410 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 411 | % option_info = GetCommandOptionInfo(argv[i]); |
| 412 | % count=option_info->type; |
| 413 | % option_type=option_info->flags; |
| 414 | % |
| 415 | % if ( (option_type & SettingOperatorOptionFlags) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 416 | % CLISettingOptionInfo(cli_wand, argv[i], |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 417 | % (count>=1) ? argv[i+1] : (char *)NULL, |
| 418 | % (count>=2) ? argv[i+2] : (char *)NULL); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 419 | % i += count+1; |
| 420 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 421 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 422 | WandExport void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 423 | const char *option,const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 424 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 425 | ssize_t |
| 426 | parse; /* option argument parsing (string to value table lookup) */ |
| 427 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 428 | assert(cli_wand != (MagickCLI *) NULL); |
| 429 | assert(cli_wand->signature == WandSignature); |
| 430 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 431 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 432 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 433 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 434 | #define _image_info (cli_wand->wand.image_info) |
| 435 | #define _exception (cli_wand->wand.exception) |
| 436 | #define _draw_info (cli_wand->draw_info) |
| 437 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 438 | #define IfSetOption (*option=='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 439 | #define ArgBoolean IsMagickTrue(IfSetOption) |
| 440 | #define ArgBooleanNot IsMagickFalse(IfSetOption) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 441 | #define ArgBooleanString (IfSetOption?"true":"false") |
| 442 | #define ArgOption(def) (IfSetOption?arg1:(const char *)(def)) |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 443 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 444 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 445 | { |
| 446 | case 'a': |
| 447 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 448 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 449 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 450 | _image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 451 | break; |
| 452 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 453 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 454 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 455 | CLIWandWarnDepreciated("-draw 'affine ...'"); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 456 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 457 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 458 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 459 | GetAffineMatrix(&_draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 460 | break; |
| 461 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 462 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 463 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 464 | _image_info->antialias = |
| 465 | _draw_info->stroke_antialias = |
| 466 | _draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 467 | break; |
| 468 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 469 | if (LocaleCompare("attenuate",option+1) == 0) |
| 470 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 471 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 472 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 473 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 474 | break; |
| 475 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 476 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +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 | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 479 | break; |
| 480 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 481 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 482 | } |
| 483 | case 'b': |
| 484 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 485 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 486 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 487 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 488 | _image_info only used directly for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 489 | SyncImageSettings() used to set per-image attribute. |
| 490 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 491 | FUTURE: if _image_info->background_color is not set then |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 492 | we should fall back to per-image background_color |
| 493 | |
| 494 | At this time -background will 'wipe out' the per-image |
| 495 | background color! |
| 496 | |
| 497 | Better error handling of QueryColorCompliance() needed. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 498 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 499 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 500 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 501 | &_image_info->background_color,_exception); |
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("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 505 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 506 | /* FUTURE: bias OBSOLETED, replaced by Artifact "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 507 | as it is actually rarely used except in direct convolve operations |
| 508 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 509 | |
| 510 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 511 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 512 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 513 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 514 | (void) SetImageOption(_image_info,"convolve:bias",ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 515 | break; |
| 516 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 517 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 518 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 519 | /* Used as a image chromaticity setting |
| 520 | SyncImageSettings() used to set per-image attribute. |
| 521 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 522 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 523 | break; |
| 524 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 525 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 526 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 527 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 528 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 529 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 530 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 531 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 532 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 533 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 534 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 535 | break; |
| 536 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 537 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 538 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 539 | /* FUTURE: both _image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 540 | SyncImageSettings() used to set per-image attribute. |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 541 | Better error checking of QueryColorCompliance(). |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 542 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 543 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 544 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 545 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 546 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 547 | &_image_info->border_color,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 548 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 549 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 550 | break; |
| 551 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 552 | (void) DeleteImageOption(_image_info,option+1); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 553 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 554 | &_image_info->border_color,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 555 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 556 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 557 | break; |
| 558 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 559 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 560 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 561 | CLIWandWarnDepreciated("-undercolor"); |
| 562 | CLISettingOptionInfo(cli_wand,"-undercolor",arg1, arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 563 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 564 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 565 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 566 | } |
| 567 | case 'c': |
| 568 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 569 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 570 | { |
| 571 | MagickSizeType |
| 572 | limit; |
| 573 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 574 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 575 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 576 | limit=MagickResourceInfinity; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 577 | if (LocaleCompare("unlimited",arg1) != 0) |
| 578 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 579 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 580 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 581 | break; |
| 582 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 583 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 584 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 585 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 586 | break; |
| 587 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 588 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 589 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 590 | arg1=ArgOption("default"); |
| 591 | parse=ParseChannelOption(arg1); |
| 592 | if (parse < 0) |
| 593 | CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType", |
| 594 | option,arg1); |
| 595 | _image_info->channel=(ChannelType) parse; |
| 596 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 597 | break; |
| 598 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 599 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 600 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 601 | /* Setting used for new images via AquireImage() |
| 602 | But also used as a SimpleImageOperator |
| 603 | Undefined colorspace means don't modify images on |
| 604 | read or as a operation */ |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 605 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 606 | ArgOption("undefined")); |
| 607 | if (parse < 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 608 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 609 | option,arg1); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 610 | _image_info->colorspace=(ColorspaceType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 611 | break; |
| 612 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 613 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 614 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 615 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 616 | break; |
| 617 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 618 | if (LocaleCompare("compose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 619 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 620 | /* FUTURE: _image_info should be used, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 621 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 622 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 623 | This setting should NOT be used to set image 'compose' |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 624 | "-layer" operators shoud use _image_info if defined otherwise |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 625 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 626 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 627 | parse = ParseCommandOption(MagickComposeOptions,MagickFalse, |
| 628 | ArgOption("undefined")); |
| 629 | if (parse < 0) |
| 630 | CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", |
| 631 | option,arg1); |
| 632 | _image_info->compose=(CompositeOperator) 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 | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 636 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 637 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 638 | /* FUTURE: What should be used? _image_info or ImageOption ??? |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 639 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 640 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 641 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 642 | The coders appears to use _image_info, not Image_Option |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 643 | however the image attribute (for save) is set from the |
| 644 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 645 | |
| 646 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 647 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 648 | parse = ParseCommandOption(MagickCompressOptions,MagickFalse, |
| 649 | ArgOption("undefined")); |
| 650 | if (parse < 0) |
| 651 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", |
| 652 | option,arg1); |
| 653 | _image_info->compression=(CompressionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 654 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 655 | break; |
| 656 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 657 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 658 | } |
| 659 | case 'd': |
| 660 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 661 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 662 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 663 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 664 | arg1=ArgOption("none"); |
| 665 | parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); |
| 666 | if (parse < 0) |
| 667 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", |
| 668 | option,arg1); |
| 669 | (void) SetLogEventMask(arg1); |
| 670 | _image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 671 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 672 | break; |
| 673 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 674 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 675 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 676 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 677 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 678 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 679 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 680 | else |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 681 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 682 | break; |
| 683 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 684 | /* DefineImageOption() equals SetImageOption() but with '=' */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 685 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 686 | (void) DefineImageOption(_image_info,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 687 | else if (IsMagickFalse(DeleteImageOption(_image_info,arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 688 | CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 689 | break; |
| 690 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 691 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 692 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 693 | /* Only used for new images via AcquireImage() |
| 694 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 695 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 696 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 697 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 698 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 699 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 700 | break; |
| 701 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 702 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 703 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 704 | /* FUTURE: strings used in _image_info attr and _draw_info! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 705 | Basically as density can be in a XxY form! |
| 706 | |
| 707 | SyncImageSettings() used to set per-image attribute. |
| 708 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 709 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 710 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 711 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 712 | (void) CloneString(&_image_info->density,ArgOption(NULL)); |
| 713 | (void) CloneString(&_draw_info->density,_image_info->density); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 714 | break; |
| 715 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 716 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 717 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 718 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 719 | SyncImageSettings() used to set per-image attribute. |
| 720 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 721 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 722 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 723 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 724 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 725 | break; |
| 726 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 727 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 728 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 729 | /* Image Option is only used to set _draw_info */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 730 | arg1=ArgOption("undefined"); |
| 731 | parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); |
| 732 | if (parse < 0) |
| 733 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", |
| 734 | option,arg1); |
| 735 | _draw_info->direction=(DirectionType) parse; |
| 736 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 737 | break; |
| 738 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 739 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 740 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 741 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); |
| 742 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 743 | break; |
| 744 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 745 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 746 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 747 | /* only used in setting new images */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 748 | arg1=ArgOption("undefined"); |
| 749 | parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); |
| 750 | if (parse < 0) |
| 751 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", |
| 752 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 753 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 754 | break; |
| 755 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 756 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 757 | { |
| 758 | /* FUTURE: this is only used by CompareImages() which is used |
| 759 | only by the "compare" CLI program at this time. */ |
| 760 | arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD); |
| 761 | if (IfMagickFalse(IsGeometry(arg1))) |
| 762 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 763 | (void) SetImageOption(_image_info,option+1,arg1); |
| 764 | break; |
| 765 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 766 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 767 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 768 | /* _image_info attr (on/off), _quantize_info attr (on/off) |
| 769 | but also ImageInfo and _quantize_info method! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 770 | FUTURE: merge the duality of the dithering options |
| 771 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 772 | _image_info->dither = _quantize_info->dither = ArgBoolean; |
| 773 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); |
| 774 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 775 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 776 | if (_quantize_info->dither_method == NoDitherMethod) |
| 777 | _image_info->dither = _quantize_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 778 | break; |
| 779 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 780 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 781 | } |
| 782 | case 'e': |
| 783 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 784 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 785 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 786 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); |
| 787 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 788 | break; |
| 789 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 790 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 791 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 792 | /* Both _image_info attr and ImageInfo */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 793 | arg1 = ArgOption("undefined"); |
| 794 | parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); |
| 795 | if (parse < 0) |
| 796 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", |
| 797 | option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 798 | /* FUTURE: check alloc/free of endian string! - remove? */ |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 799 | _image_info->endian=(EndianType) (*arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 800 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 801 | break; |
| 802 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 803 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 804 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 805 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 806 | break; |
| 807 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 808 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 809 | } |
| 810 | case 'f': |
| 811 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 812 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 813 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 814 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 815 | break; |
| 816 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 817 | if (LocaleCompare("fill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 818 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 819 | /* Set "fill" OR "fill-pattern" in _draw_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 820 | The original fill color is preserved if a fill-pattern is given. |
| 821 | That way it does not effect other operations that directly using |
| 822 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 823 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 824 | MagickBooleanType |
| 825 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 826 | |
| 827 | ExceptionInfo |
| 828 | *sans; |
| 829 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 830 | PixelInfo |
| 831 | color; |
| 832 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 833 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 834 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 835 | if (_draw_info->fill_pattern != (Image *) NULL) |
| 836 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 837 | |
| 838 | /* is it a color or a image? -- ignore exceptions */ |
| 839 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 840 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 841 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 842 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 843 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 844 | _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 845 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 846 | _draw_info->fill=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 847 | break; |
| 848 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 849 | if (LocaleCompare("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 850 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 851 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 852 | arg1 = ArgOption("undefined"); |
| 853 | parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); |
| 854 | if (parse < 0) |
| 855 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", |
| 856 | option,arg1); |
| 857 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 858 | break; |
| 859 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 860 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 861 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 862 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); |
| 863 | (void) CloneString(&_image_info->font,_draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 864 | break; |
| 865 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 866 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 867 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 868 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 869 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 870 | register const char |
| 871 | *q; |
| 872 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 873 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 874 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 875 | _image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 876 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 877 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 878 | break; |
| 879 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 880 | if (LocaleCompare("fuzz",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 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 883 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 884 | SyncImageSettings() used to set per-image attribute. |
| 885 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 886 | FUTURE: Can't find anything else using _image_info->fuzz directly! |
| 887 | remove direct sttribute from image_info |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 888 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 889 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 890 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 891 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 892 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 893 | QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 894 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 895 | break; |
| 896 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 897 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 898 | } |
| 899 | case 'g': |
| 900 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 901 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 902 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 903 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 904 | arg1 = ArgOption("none"); |
| 905 | parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); |
| 906 | if (parse < 0) |
| 907 | CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", |
| 908 | option,arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 909 | _draw_info->gravity=(GravityType) parse; |
anthony | e849097 | 2012-04-03 13:16:01 +0000 | [diff] [blame] | 910 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 911 | break; |
| 912 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 913 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 914 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 915 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 916 | SyncImageSettings() used to set per-image attribute. |
| 917 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 918 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 919 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 920 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 921 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 922 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 923 | break; |
| 924 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 925 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 926 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 927 | case 'h': |
| 928 | { |
| 929 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 930 | { |
| 931 | /* FUTURE: this is only used by CompareImages() which is used |
| 932 | only by the "compare" CLI program at this time. */ |
| 933 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 934 | break; |
| 935 | } |
| 936 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
| 937 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 938 | case 'i': |
| 939 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 940 | if (LocaleCompare("intent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 941 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 942 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 943 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 944 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 945 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 946 | arg1 = ArgOption("indefined"); |
| 947 | parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); |
| 948 | if (parse < 0) |
| 949 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", |
| 950 | option,arg1); |
| 951 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 952 | break; |
| 953 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 954 | if (LocaleCompare("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 955 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 956 | /* _image_info is directly used by coders (so why an image setting?) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 957 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 958 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 959 | arg1 = ArgOption("undefined"); |
| 960 | parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); |
| 961 | if (parse < 0) |
| 962 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", |
| 963 | option,arg1); |
| 964 | _image_info->interlace=(InterlaceType) parse; |
| 965 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 966 | break; |
| 967 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 968 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 969 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 970 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 971 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 972 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 973 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 974 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 975 | break; |
| 976 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 977 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 978 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 979 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 980 | arg1 = ArgOption("undefined"); |
| 981 | parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); |
| 982 | if (parse < 0) |
| 983 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", |
| 984 | option,arg1); |
| 985 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 986 | break; |
| 987 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 988 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 989 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 990 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 991 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 992 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 993 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 994 | break; |
| 995 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 996 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 997 | } |
| 998 | case 'k': |
| 999 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1000 | if (LocaleCompare("kerning",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1001 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1002 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1003 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1004 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1005 | _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1006 | break; |
| 1007 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1008 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1009 | } |
| 1010 | case 'l': |
| 1011 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1012 | if (LocaleCompare("label",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1013 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1014 | /* only used for new images - not in SyncImageOptions() */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1015 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1016 | break; |
| 1017 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1018 | if (LocaleCompare("limit",option+1) == 0) |
| 1019 | { |
| 1020 | MagickSizeType |
| 1021 | limit; |
| 1022 | |
| 1023 | limit=MagickResourceInfinity; |
| 1024 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 1025 | if ( parse < 0 ) |
| 1026 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 1027 | option,arg1); |
| 1028 | if (LocaleCompare("unlimited",arg2) != 0) |
| 1029 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
| 1030 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
| 1031 | break; |
| 1032 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1033 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1034 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1035 | if (IfSetOption) { |
| 1036 | if ((strchr(arg1,'%') == (char *) NULL)) |
| 1037 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1038 | (void) SetLogFormat(arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1039 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1040 | break; |
| 1041 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1042 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1043 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1044 | /* FUTURE: this is only used by CompareImages() which is used |
| 1045 | only by the "compare" CLI program at this time. */ |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1046 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1047 | break; |
| 1048 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1049 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1050 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1051 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1052 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1053 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1054 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1055 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1056 | break; |
| 1057 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1058 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1059 | } |
| 1060 | case 'm': |
| 1061 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1062 | if (LocaleCompare("mattecolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1063 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1064 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1065 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1066 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1067 | &_image_info->matte_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1068 | break; |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1069 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1070 | if (LocaleCompare("metric",option+1) == 0) |
| 1071 | { |
| 1072 | /* FUTURE: this is only used by CompareImages() which is used |
| 1073 | only by the "compare" CLI program at this time. */ |
| 1074 | parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1); |
| 1075 | if ( parse < 0 ) |
| 1076 | CLIWandExceptArgBreak(OptionError,"UnrecognizedMetricType", |
| 1077 | option,arg1); |
| 1078 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1079 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1080 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1081 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1082 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1083 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1084 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1085 | break; |
| 1086 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1087 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1088 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1089 | /* Setting (used by some input coders!) -- why? |
| 1090 | Warning: This is also Special '-type' SimpleOperator |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1091 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1092 | _image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1093 | break; |
| 1094 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1095 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1096 | } |
| 1097 | case 'o': |
| 1098 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1099 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1100 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1101 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1102 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1103 | FUTURE: make set meta-data operator instead. |
| 1104 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1105 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1106 | parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
| 1107 | ArgOption("undefined")); |
| 1108 | if (parse < 0) |
| 1109 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", |
| 1110 | option,arg1); |
| 1111 | _image_info->orientation=(OrientationType)parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1112 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1113 | break; |
| 1114 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1115 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1116 | } |
| 1117 | case 'p': |
| 1118 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1119 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1120 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1121 | /* Only used for new images and image generators. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1122 | SyncImageSettings() used to set per-image attribute. ????? |
| 1123 | That last is WRONG!!!! |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1124 | FUTURE: adjust named 'page' sizes according density |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1125 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1126 | char |
| 1127 | *canonical_page, |
| 1128 | page[MaxTextExtent]; |
| 1129 | |
| 1130 | const char |
| 1131 | *image_option; |
| 1132 | |
| 1133 | MagickStatusType |
| 1134 | flags; |
| 1135 | |
| 1136 | RectangleInfo |
| 1137 | geometry; |
| 1138 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1139 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1140 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1141 | (void) DeleteImageOption(_image_info,option+1); |
| 1142 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1143 | break; |
| 1144 | } |
| 1145 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1146 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1147 | if (image_option != (const char *) NULL) |
| 1148 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1149 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1150 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1151 | canonical_page=DestroyString(canonical_page); |
| 1152 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1153 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1154 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1155 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1156 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1157 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1158 | (void) SetImageOption(_image_info,option+1,page); |
| 1159 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1160 | break; |
| 1161 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1162 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1163 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1164 | _image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1165 | break; |
| 1166 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1167 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1168 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1169 | if (IfSetOption) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1170 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1171 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1172 | _image_info->pointsize = |
| 1173 | _draw_info->pointsize = |
| 1174 | StringToDouble(arg1,(char **) NULL); |
| 1175 | } |
| 1176 | else { |
| 1177 | _image_info->pointsize=0.0; /* unset pointsize */ |
| 1178 | _draw_info->pointsize=12.0; |
| 1179 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1180 | break; |
| 1181 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1182 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1183 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1184 | arg1=ArgOption("-1"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1185 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1186 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1187 | (void) SetMagickPrecision(StringToInteger(arg1)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1188 | break; |
| 1189 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1190 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1191 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1192 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1193 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1194 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1195 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1196 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1197 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1198 | break; |
| 1199 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1200 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1201 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1202 | } |
| 1203 | case 'q': |
| 1204 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1205 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1206 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1207 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1208 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1209 | _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1) |
| 1210 | : UNDEFINED_COMPRESSION_QUALITY; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1211 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1212 | break; |
| 1213 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1214 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1215 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1216 | /* Just a set direct in _quantize_info */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1217 | arg1=ArgOption("undefined"); |
| 1218 | parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
| 1219 | if (parse < 0) |
| 1220 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 1221 | option,arg1); |
| 1222 | _quantize_info->colorspace=(ColorspaceType)parse; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1223 | break; |
| 1224 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1225 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1226 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1227 | /* FUTURE: if two -quiet is performed you can not do +quiet! |
| 1228 | This needs to be checked over thoughly. |
| 1229 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1230 | static WarningHandler |
| 1231 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1232 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1233 | WarningHandler |
| 1234 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1235 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1236 | if ( tmp != (WarningHandler) NULL) |
| 1237 | warning_handler = tmp; /* remember the old handler */ |
| 1238 | if (!IfSetOption) /* set the old handler */ |
| 1239 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1240 | break; |
| 1241 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1242 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1243 | } |
| 1244 | case 'r': |
| 1245 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1246 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1247 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1248 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1249 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1250 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1251 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1252 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1253 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1254 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1255 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1256 | break; |
| 1257 | } |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1258 | if (LocaleCompare("regard-warnings",option+1) == 0) |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 1259 | /* FUTURE: to be replaced by a 'fatal-level' type setting */ |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1260 | break; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1261 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1262 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1263 | /* _draw_info only setting */ |
| 1264 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1265 | break; |
| 1266 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1267 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
| 1268 | { |
| 1269 | /* link image and setting stacks - option is itself saved on stack! */ |
| 1270 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1271 | break; |
| 1272 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1273 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1274 | } |
| 1275 | case 's': |
| 1276 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1277 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1278 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1279 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1280 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1281 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1282 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1283 | break; |
| 1284 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1285 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1286 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1287 | /* SyncImageSettings() used to set this as a per-image attribute. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1288 | What ??? Why ???? |
| 1289 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1290 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1291 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1292 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1293 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1294 | break; |
| 1295 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1296 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1297 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1298 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1299 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame] | 1300 | SetRandomSecretKey( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1301 | IfSetOption ? (size_t) StringToUnsignedLong(arg1) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1302 | : (size_t) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1303 | break; |
| 1304 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1305 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1306 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1307 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1308 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1309 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1310 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1311 | break; |
| 1312 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1313 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1314 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1315 | arg1=ArgOption("undefined"); |
| 1316 | parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1); |
| 1317 | if (parse < 0) |
| 1318 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStretchType", |
| 1319 | option,arg1); |
| 1320 | _draw_info->stretch=(StretchType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1321 | break; |
| 1322 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1323 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1324 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1325 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1326 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1327 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1328 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1329 | MagickBooleanType |
| 1330 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1331 | |
| 1332 | ExceptionInfo |
| 1333 | *sans; |
| 1334 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1335 | PixelInfo |
| 1336 | color; |
| 1337 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1338 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1339 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1340 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1341 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1342 | |
| 1343 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1344 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1345 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1346 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1347 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1348 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1349 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1350 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1351 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1352 | break; |
| 1353 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1354 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1355 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1356 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1357 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1358 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1359 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1360 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1361 | break; |
| 1362 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1363 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1364 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1365 | arg1=ArgOption("undefined"); |
| 1366 | parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1); |
| 1367 | if (parse < 0) |
| 1368 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStyleType", |
| 1369 | option,arg1); |
| 1370 | _draw_info->style=(StyleType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1371 | break; |
| 1372 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1373 | #if 0 |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1374 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 1375 | { |
| 1376 | /* FUTURE: this is only used by CompareImages() which is used |
| 1377 | only by the "compare" CLI program at this time. */ |
| 1378 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1379 | break; |
| 1380 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1381 | #endif |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1382 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1383 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1384 | /* FUTURE: syncronize to storage - but what does that mean? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1385 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1386 | break; |
| 1387 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1388 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1389 | } |
| 1390 | case 't': |
| 1391 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1392 | if (LocaleCompare("taint",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 | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1395 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1396 | break; |
| 1397 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1398 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1399 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1400 | /* FUTURE: move _image_info string to option splay-tree |
| 1401 | Other than "montage" what uses "texture" ???? |
| 1402 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1403 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1404 | break; |
| 1405 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1406 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1407 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1408 | _draw_info->fill_pattern=IfSetOption |
| 1409 | ?GetImageCache(_image_info,arg1,_exception) |
| 1410 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1411 | break; |
| 1412 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1413 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1414 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1415 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1416 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1417 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1418 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1419 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1420 | break; |
| 1421 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1422 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1423 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1424 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1425 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1426 | SyncImageSettings() used to set per-image attribute. |
| 1427 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1428 | Note that +transparent-color, means fall-back to image |
| 1429 | attribute so ImageOption is deleted, not set to a default. |
| 1430 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1431 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1432 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1433 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1434 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1435 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1436 | break; |
| 1437 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1438 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1439 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1440 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1441 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1442 | break; |
| 1443 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1444 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1445 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1446 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1447 | parse=ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 1448 | ArgOption("undefined")); |
| 1449 | if (parse < 0) |
| 1450 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageType", |
| 1451 | option,arg1); |
| 1452 | _image_info->type=(ImageType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1453 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1454 | break; |
| 1455 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1456 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1457 | } |
| 1458 | case 'u': |
| 1459 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1460 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1461 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1462 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1463 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1464 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1465 | break; |
| 1466 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1467 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1468 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1469 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1470 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1471 | FUTURE: this probably should be part of the density setting |
| 1472 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1473 | parse=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
| 1474 | ArgOption("undefined")); |
| 1475 | if (parse < 0) |
| 1476 | CLIWandExceptArgBreak(OptionError,"UnrecognizedUnitsType", |
| 1477 | option,arg1); |
| 1478 | _image_info->units=(ResolutionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1479 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1480 | break; |
| 1481 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1482 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1483 | } |
| 1484 | case 'v': |
| 1485 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1486 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1487 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1488 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1489 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1490 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1491 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1492 | _image_info->verbose= ArgBoolean; |
| 1493 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1494 | break; |
| 1495 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1496 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1497 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1498 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1499 | Only used by coder FPX |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1500 | And it only tests existance, not its content! |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1501 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1502 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1503 | break; |
| 1504 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1505 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1506 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1507 | /* SyncImageSettings() used to set per-image attribute. |
| 1508 | This is VERY deep in the image caching structure. |
| 1509 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1510 | parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 1511 | ArgOption("undefined")); |
| 1512 | if (parse < 0) |
| 1513 | CLIWandExceptArgBreak(OptionError,"UnrecognizedVirtualPixelMethod", |
| 1514 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1515 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1516 | break; |
| 1517 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1518 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1519 | } |
| 1520 | case 'w': |
| 1521 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1522 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1523 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1524 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1525 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1526 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1527 | arg1=ArgOption("all"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1528 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1529 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1530 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1531 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1532 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1533 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1534 | if (_draw_info->weight <= 800) |
| 1535 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1536 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1537 | if (_draw_info->weight >= 100) |
| 1538 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1539 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1540 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1541 | break; |
| 1542 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1543 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1544 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1545 | /* Used as a image chromaticity setting |
| 1546 | SyncImageSettings() used to set per-image attribute. |
| 1547 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1548 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1549 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1550 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1551 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1552 | break; |
| 1553 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1554 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1555 | } |
| 1556 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1557 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1558 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1559 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1560 | #undef _image_info |
| 1561 | #undef _exception |
| 1562 | #undef _draw_info |
| 1563 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1564 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1565 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1566 | #undef ArgBooleanNot |
| 1567 | #undef ArgBooleanString |
| 1568 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1569 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1570 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1571 | } |
| 1572 | |
| 1573 | /* |
| 1574 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1575 | % % |
| 1576 | % % |
| 1577 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1578 | + 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] | 1579 | % % |
| 1580 | % % |
| 1581 | % % |
| 1582 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1583 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1584 | % WandSimpleOperatorImages() applys one simple image operation given to all |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1585 | % the images in the CLI wand, with the settings that was previously saved in |
| 1586 | % the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1587 | % |
| 1588 | % 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] | 1589 | % extra settings that were already saved in the wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1590 | % |
anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1591 | % The format of the WandSimpleOperatorImage method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1592 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1593 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1594 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1595 | % |
| 1596 | % A description of each parameter follows: |
| 1597 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1598 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1599 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1600 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1601 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1602 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1603 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1604 | % Any problems will be added to the 'exception' entry of the given wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1605 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1606 | % Example usage... |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1607 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1608 | % CLISimpleOperatorImages(cli_wand, "-crop","100x100+20+30",NULL); |
| 1609 | % CLISimpleOperatorImages(cli_wand, "+repage",NULL,NULL); |
| 1610 | % CLISimpleOperatorImages(cli_wand, "+distort","SRT","45"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1611 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1612 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1613 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1614 | % cli_wand |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1615 | % argc,argv |
| 1616 | % i=index in argv |
| 1617 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 1618 | % option_info = GetCommandOptionInfo(argv[i]); |
| 1619 | % count=option_info->type; |
| 1620 | % option_type=option_info->flags; |
| 1621 | % |
| 1622 | % if ( (option_type & SimpleOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1623 | % CLISimpleOperatorImages(cli_wand, argv[i], |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1624 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 1625 | % count>=2 ? argv[i+2] : (char *)NULL ); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1626 | % i += count+1; |
| 1627 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1628 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1629 | |
| 1630 | /* |
| 1631 | Internal subrountine to apply one simple image operation to the current |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1632 | image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1633 | |
| 1634 | The image in the list may be modified in three different ways... |
| 1635 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1636 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1637 | * one image replace by a list of images (-separate and -crop only!) |
| 1638 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1639 | In each case the result replaces the single original image in the list, as |
| 1640 | well as the pointer to the modified image (last image added if replaced by a |
| 1641 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1642 | |
| 1643 | As the image pointed to may be replaced, the first image in the list may |
| 1644 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1645 | return the Image pointer to the first image in list. |
| 1646 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1647 | static void CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1648 | const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1649 | { |
| 1650 | Image * |
| 1651 | new_image; |
| 1652 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1653 | GeometryInfo |
| 1654 | geometry_info; |
| 1655 | |
| 1656 | RectangleInfo |
| 1657 | geometry; |
| 1658 | |
| 1659 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1660 | flags; |
| 1661 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1662 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1663 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1664 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 1665 | #define _image_info (cli_wand->wand.image_info) |
| 1666 | #define _image (cli_wand->wand.images) |
| 1667 | #define _exception (cli_wand->wand.exception) |
| 1668 | #define _draw_info (cli_wand->draw_info) |
| 1669 | #define _quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1670 | #define IfNormalOp (*option=='-') |
| 1671 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1672 | #define normal_op IsMagickTrue(IfNormalOp) |
| 1673 | #define plus_alt_op IsMagickFalse(IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1674 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1675 | assert(cli_wand != (MagickCLI *) NULL); |
| 1676 | assert(cli_wand->signature == WandSignature); |
| 1677 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1678 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1679 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1680 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1681 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1682 | (void) SyncImageSettings(_image_info,_image,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1683 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1684 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1685 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1686 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1687 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1688 | /* FUTURE: We may need somthing a little more optimized than this! |
| 1689 | Perhaps, do the 'sync' if 'settings tainted' before next operator. |
| 1690 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1691 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1692 | { |
| 1693 | case 'a': |
| 1694 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1695 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1696 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1697 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1698 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1699 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1700 | if ((flags & SigmaValue) == 0) |
| 1701 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1702 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1703 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1704 | break; |
| 1705 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1706 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1707 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1708 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1709 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1710 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1711 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1712 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1713 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1714 | break; |
| 1715 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1716 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1717 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1718 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1719 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1720 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1721 | if ((flags & SigmaValue) == 0) |
| 1722 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1723 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1724 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1725 | break; |
| 1726 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1727 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1728 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1729 | parse=ParseCommandOption(MagickAlphaOptions,MagickFalse,arg1); |
| 1730 | if (parse < 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1731 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelType", |
| 1732 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1733 | (void) SetImageAlphaChannel(_image,(AlphaChannelType)parse, |
| 1734 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1735 | break; |
| 1736 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1737 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1738 | { |
| 1739 | char |
| 1740 | *text, |
| 1741 | geometry[MaxTextExtent]; |
| 1742 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1743 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1744 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1745 | if ((flags & RhoValue) == 0) |
| 1746 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1747 | if ((flags & SigmaValue) == 0) |
| 1748 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1749 | text=InterpretImageProperties(_image_info,_image,arg2, |
| 1750 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1751 | if (text == (char *) NULL) |
| 1752 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1753 | (void) CloneString(&_draw_info->text,text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1754 | text=DestroyString(text); |
| 1755 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1756 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1757 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1758 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1759 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1760 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1761 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1762 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1763 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1764 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1765 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1766 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1767 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1768 | break; |
| 1769 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1770 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1771 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1772 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1773 | break; |
| 1774 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1775 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1776 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1777 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1778 | break; |
| 1779 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1780 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1781 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1782 | /* This should probably be a MagickCore function */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1783 | switch (_image->orientation) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1784 | { |
| 1785 | case TopRightOrientation: |
| 1786 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1787 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1788 | break; |
| 1789 | } |
| 1790 | case BottomRightOrientation: |
| 1791 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1792 | new_image=RotateImage(_image,180.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1793 | break; |
| 1794 | } |
| 1795 | case BottomLeftOrientation: |
| 1796 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1797 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1798 | break; |
| 1799 | } |
| 1800 | case LeftTopOrientation: |
| 1801 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1802 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1803 | break; |
| 1804 | } |
| 1805 | case RightTopOrientation: |
| 1806 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1807 | new_image=RotateImage(_image,90.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1808 | break; |
| 1809 | } |
| 1810 | case RightBottomOrientation: |
| 1811 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1812 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1813 | break; |
| 1814 | } |
| 1815 | case LeftBottomOrientation: |
| 1816 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1817 | new_image=RotateImage(_image,270.0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1818 | break; |
| 1819 | } |
| 1820 | default: |
| 1821 | break; |
| 1822 | } |
| 1823 | if (new_image != (Image *) NULL) |
| 1824 | new_image->orientation=TopLeftOrientation; |
| 1825 | break; |
| 1826 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1827 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1828 | } |
| 1829 | case 'b': |
| 1830 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1831 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1832 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1833 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1834 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1835 | (void) BlackThresholdImage(_image,arg1,_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("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1839 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1840 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1841 | if (IfNormalOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1842 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1843 | if ((flags & RhoValue) == 0) |
| 1844 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1845 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1846 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1847 | break; |
| 1848 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1849 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1850 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1851 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1852 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1853 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1854 | if ((flags & SigmaValue) == 0) |
| 1855 | geometry_info.sigma=1.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1856 | new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1857 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1858 | break; |
| 1859 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1860 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1861 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1862 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1863 | compose; |
| 1864 | |
| 1865 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1866 | value; |
| 1867 | |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1868 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 1869 | if ((flags & RhoValue) == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1870 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1871 | if ((flags & SigmaValue) == 0) |
| 1872 | geometry.height=geometry.width; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1873 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1874 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1875 | if (value != (const char *) NULL) |
| 1876 | compose=(CompositeOperator) ParseCommandOption( |
| 1877 | MagickComposeOptions,MagickFalse,value); |
| 1878 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1879 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1880 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1881 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1882 | break; |
| 1883 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1884 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1885 | { |
| 1886 | double |
| 1887 | brightness, |
| 1888 | contrast; |
| 1889 | |
| 1890 | GeometryInfo |
| 1891 | geometry_info; |
| 1892 | |
| 1893 | MagickStatusType |
| 1894 | flags; |
| 1895 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1896 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1897 | if ((flags & RhoValue) == 0) |
| 1898 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1899 | brightness=geometry_info.rho; |
| 1900 | contrast=0.0; |
| 1901 | if ((flags & SigmaValue) != 0) |
| 1902 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1903 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1904 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1905 | break; |
| 1906 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1907 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1908 | } |
| 1909 | case 'c': |
| 1910 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1911 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1912 | { |
| 1913 | char |
| 1914 | *color_correction_collection; |
| 1915 | |
| 1916 | /* |
| 1917 | Color correct with a color decision list. |
| 1918 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1919 | color_correction_collection=FileToString(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1920 | if (color_correction_collection == (char *) NULL) |
| 1921 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1922 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 1923 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1924 | break; |
| 1925 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1926 | if (LocaleCompare("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1927 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1928 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1929 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1930 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1931 | if ((flags & SigmaValue) == 0) |
| 1932 | geometry_info.sigma=1.0; |
| 1933 | if ((flags & XiValue) == 0) |
| 1934 | geometry_info.xi=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1935 | new_image=CharcoalImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1936 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1937 | break; |
| 1938 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1939 | if (LocaleCompare("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1940 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1941 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1942 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1943 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 1944 | new_image=ChopImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1945 | break; |
| 1946 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1947 | if (LocaleCompare("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1948 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1949 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1950 | break; |
| 1951 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1952 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1953 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1954 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1955 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1956 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1957 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1958 | break; |
| 1959 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1960 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1961 | { |
| 1962 | CacheView |
| 1963 | *mask_view; |
| 1964 | |
| 1965 | Image |
| 1966 | *mask_image; |
| 1967 | |
| 1968 | register Quantum |
| 1969 | *restrict q; |
| 1970 | |
| 1971 | register ssize_t |
| 1972 | x; |
| 1973 | |
| 1974 | ssize_t |
| 1975 | y; |
| 1976 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1977 | if (IfPlusOp) { |
| 1978 | /* "+clip-mask" Remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1979 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1980 | break; |
| 1981 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1982 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1983 | if (mask_image == (Image *) NULL) |
| 1984 | break; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1985 | if (IfMagickFalse(SetImageStorageClass(mask_image,DirectClass,_exception))) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1986 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1987 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1988 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1989 | mask_view=AcquireCacheView(mask_image); |
| 1990 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1991 | { |
| 1992 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1993 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1994 | if (q == (Quantum *) NULL) |
| 1995 | break; |
| 1996 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1997 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1998 | if (IfMagickFalse(mask_image->matte)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1999 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 2000 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2001 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2002 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
| 2003 | q+=GetPixelChannels(mask_image); |
| 2004 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2005 | if (IfMagickFalse(SyncCacheViewAuthenticPixels(mask_view,_exception))) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2006 | break; |
| 2007 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2008 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2009 | mask_view=DestroyCacheView(mask_view); |
| 2010 | mask_image->matte=MagickTrue; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2011 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2012 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2013 | break; |
| 2014 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2015 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2016 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2017 | (void) ClipImagePath(_image,arg1,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2018 | break; |
| 2019 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2020 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2021 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2022 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2023 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2024 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2025 | break; |
| 2026 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2027 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2028 | { |
| 2029 | KernelInfo |
| 2030 | *kernel; |
| 2031 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2032 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2033 | if (kernel == (KernelInfo *) NULL) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2034 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2035 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2036 | kernel=DestroyKernelInfo(kernel); |
| 2037 | break; |
| 2038 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2039 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2040 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2041 | /* Reduce the number of colors in the image. |
| 2042 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2043 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2044 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2045 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2046 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2047 | if ((_image->storage_class == DirectClass) || |
| 2048 | _image->colors > _quantize_info->number_colors) |
| 2049 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2050 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2051 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2052 | break; |
| 2053 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2054 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2055 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2056 | /* WARNING: this is both a image_info setting (already done) |
| 2057 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2058 | |
| 2059 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2060 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2061 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2062 | Note that +colorspace sets "undefined" or no effect on |
| 2063 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2064 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2065 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2066 | (void) TransformImageColorspace(_image, |
| 2067 | IfNormalOp ? _image_info->colorspace : RGBColorspace, |
| 2068 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2069 | break; |
| 2070 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2071 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2072 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2073 | CLIWandWarnDepreciated(normal_op?"-level":"+level"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2074 | (void) ContrastImage(_image,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2075 | break; |
| 2076 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2077 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2078 | { |
| 2079 | double |
| 2080 | black_point, |
| 2081 | white_point; |
| 2082 | |
| 2083 | MagickStatusType |
| 2084 | flags; |
| 2085 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2086 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2087 | if ((flags & RhoValue) == 0) |
| 2088 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2089 | black_point=geometry_info.rho; |
| 2090 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2091 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2092 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2093 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2094 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2095 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2096 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2097 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2098 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2099 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2100 | break; |
| 2101 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2102 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2103 | { |
| 2104 | KernelInfo |
| 2105 | *kernel_info; |
| 2106 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2107 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2108 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2109 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2110 | new_image=MorphologyImage(_image,ConvolveMorphology,1,kernel_info, |
| 2111 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2112 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2113 | break; |
| 2114 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2115 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2116 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2117 | /* WARNING: This can generate multiple images! */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2118 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2119 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2120 | new_image=CropImageToTiles(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2121 | break; |
| 2122 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2123 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2124 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2125 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2126 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2127 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2128 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2129 | break; |
| 2130 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2131 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2132 | } |
| 2133 | case 'd': |
| 2134 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2135 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2136 | { |
| 2137 | StringInfo |
| 2138 | *passkey; |
| 2139 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2140 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2141 | if (passkey == (StringInfo *) NULL) |
| 2142 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2143 | |
| 2144 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2145 | passkey=DestroyStringInfo(passkey); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2146 | break; |
| 2147 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2148 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2149 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2150 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2151 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2152 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2153 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2154 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2155 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2156 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2157 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2158 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2159 | break; |
| 2160 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2161 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2162 | { |
| 2163 | double |
| 2164 | threshold; |
| 2165 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2166 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2167 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2168 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2169 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2170 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2171 | else |
| 2172 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2173 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2174 | break; |
| 2175 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2176 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2177 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2178 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2179 | break; |
| 2180 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2181 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2182 | { |
| 2183 | char |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2184 | *arg; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2185 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2186 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2187 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2188 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2189 | ssize_t |
| 2190 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2191 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2192 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2193 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2194 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2195 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2196 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2197 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2198 | double |
| 2199 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2200 | /* Special Case - Argument is actually a resize geometry! |
| 2201 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2202 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2203 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2204 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2205 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2206 | option,arg2); |
| 2207 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2208 | resize_args[0]=(double) geometry.width; |
| 2209 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2210 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2211 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2212 | break; |
| 2213 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2214 | /* allow percent escapes in argument string */ |
| 2215 | arg=InterpretImageProperties(_image_info,_image,arg2,_exception); |
| 2216 | if (arg == (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2217 | break; |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2218 | /* convert argument string into an array of doubles */ |
| 2219 | args = StringToArrayOfDoubles(arg,&count,_exception); |
| 2220 | arg=DestroyString(arg); |
| 2221 | if (args == (double *)NULL ) |
| 2222 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2223 | |
| 2224 | new_image=DistortImage(_image,(DistortImageMethod) parse,count,args, |
| 2225 | plus_alt_op,_exception); |
| 2226 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2227 | break; |
| 2228 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2229 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2230 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2231 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2232 | (void) DrawImage(_image,_draw_info,_exception); |
| 2233 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2234 | break; |
| 2235 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2236 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2237 | } |
| 2238 | case 'e': |
| 2239 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2240 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2241 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2242 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2243 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2244 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2245 | if ((flags & SigmaValue) == 0) |
| 2246 | geometry_info.sigma=1.0; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2247 | new_image=EdgeImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2248 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2249 | break; |
| 2250 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2251 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2252 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2253 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame^] | 2254 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2255 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2256 | if ((flags & SigmaValue) == 0) |
| 2257 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2258 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2259 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2260 | break; |
| 2261 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2262 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2263 | { |
| 2264 | StringInfo |
| 2265 | *passkey; |
| 2266 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2267 | passkey=FileToStringInfo(arg1,~0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2268 | if (passkey != (StringInfo *) NULL) |
| 2269 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2270 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2271 | passkey=DestroyStringInfo(passkey); |
| 2272 | } |
| 2273 | break; |
| 2274 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2275 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2276 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2277 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2278 | break; |
| 2279 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2280 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2281 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2282 | (void) EqualizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2283 | break; |
| 2284 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2285 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2286 | { |
| 2287 | double |
| 2288 | constant; |
| 2289 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2290 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2291 | if ( parse < 0 ) |
| 2292 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2293 | option,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2294 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2295 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2296 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2297 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2298 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2299 | break; |
| 2300 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2301 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2302 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2303 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2304 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2305 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2306 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2307 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2308 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2309 | geometry.height=_image->rows; |
| 2310 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2311 | break; |
| 2312 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2313 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2314 | } |
| 2315 | case 'f': |
| 2316 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2317 | if (LocaleCompare("features",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2318 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2319 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2320 | if (IfPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2321 | (void) DeleteImageArtifact(_image,"identify:features"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2322 | break; |
| 2323 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2324 | (void) SetImageArtifact(_image,"identify:features","true"); |
| 2325 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2326 | break; |
| 2327 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2328 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2329 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2330 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2331 | break; |
| 2332 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2333 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2334 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2335 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2336 | break; |
| 2337 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2338 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2339 | { |
| 2340 | PixelInfo |
| 2341 | target; |
| 2342 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2343 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2344 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2345 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2346 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2347 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
| 2348 | geometry.y,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2349 | break; |
| 2350 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2351 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2352 | { |
| 2353 | FrameInfo |
| 2354 | frame_info; |
| 2355 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2356 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2357 | compose; |
| 2358 | |
| 2359 | const char* |
| 2360 | value; |
| 2361 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2362 | value=GetImageOption(_image_info,"compose"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2363 | if (value != (const char *) NULL) |
| 2364 | compose=(CompositeOperator) ParseCommandOption( |
| 2365 | MagickComposeOptions,MagickFalse,value); |
| 2366 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2367 | compose=OverCompositeOp; /* use Over not _image->compose */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2368 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2369 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2370 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2371 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2372 | frame_info.width=geometry.width; |
| 2373 | frame_info.height=geometry.height; |
| 2374 | if ((flags & HeightValue) == 0) |
| 2375 | frame_info.height=geometry.width; |
| 2376 | frame_info.outer_bevel=geometry.x; |
| 2377 | frame_info.inner_bevel=geometry.y; |
| 2378 | frame_info.x=(ssize_t) frame_info.width; |
| 2379 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2380 | frame_info.width=_image->columns+2*frame_info.width; |
| 2381 | frame_info.height=_image->rows+2*frame_info.height; |
| 2382 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2383 | break; |
| 2384 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2385 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2386 | { |
| 2387 | char |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2388 | *arg; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2389 | |
| 2390 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2391 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2392 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2393 | ssize_t |
| 2394 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2395 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2396 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2397 | if ( parse < 0 ) |
| 2398 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2399 | option,arg1); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2400 | /* allow percent escapes in argument string */ |
| 2401 | arg=InterpretImageProperties(_image_info,_image,arg2,_exception); |
| 2402 | if (arg == (char *) NULL) |
| 2403 | break; |
| 2404 | /* convert argument string into an array of doubles */ |
| 2405 | args = StringToArrayOfDoubles(arg,&count,_exception); |
| 2406 | arg=DestroyString(arg); |
| 2407 | if (args == (double *)NULL ) |
| 2408 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2409 | |
| 2410 | (void) FunctionImage(_image,(MagickFunction)parse,count,args, |
| 2411 | _exception); |
| 2412 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2413 | break; |
| 2414 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2415 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2416 | } |
| 2417 | case 'g': |
| 2418 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2419 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2420 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2421 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2422 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2423 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2424 | (void) GammaImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2425 | _exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2426 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2427 | _image->gamma=StringToDouble(arg1,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2428 | break; |
| 2429 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2430 | if (LocaleCompare("gaussian-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2431 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2432 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame^] | 2433 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2434 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2435 | if ((flags & SigmaValue) == 0) |
| 2436 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2437 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2438 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2439 | break; |
| 2440 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2441 | if (LocaleCompare("gaussian",option+1) == 0) |
| 2442 | { |
| 2443 | CLIWandWarnDepreciated("-gaussian-blur"); |
| 2444 | CLISimpleOperatorImage(cli_wand,"-gaussian-blur",arg1,NULL); |
| 2445 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2446 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2447 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2448 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2449 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2450 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2451 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2452 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2453 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2454 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2455 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2456 | if (_image->geometry != (char *) NULL) |
| 2457 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2458 | break; |
| 2459 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2460 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2461 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2462 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2463 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2464 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2465 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2466 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2467 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2468 | break; |
| 2469 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2470 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2471 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2472 | case 'i': |
| 2473 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2474 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2475 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2476 | const char |
| 2477 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2478 | *text; |
| 2479 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2480 | format=GetImageOption(_image_info,"format"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2481 | if (format == (char *) NULL) |
| 2482 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2483 | (void) IdentifyImage(_image,stdout,_image_info->verbose, |
| 2484 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2485 | break; |
| 2486 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2487 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2488 | if (text == (char *) NULL) |
| 2489 | break; |
| 2490 | (void) fputs(text,stdout); |
| 2491 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2492 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2493 | break; |
| 2494 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2495 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2496 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame^] | 2497 | flags=ParseGeometry(arg1,&geometry_info); |
| 2498 | if ((flags & RhoValue) == 0) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2499 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame^] | 2500 | new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate, |
| 2501 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2502 | break; |
| 2503 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2504 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2505 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2506 | /* FUTURE: New to IMv7 |
| 2507 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2508 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2509 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2510 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2511 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2512 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2513 | break; |
| 2514 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2515 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2516 | } |
| 2517 | case 'l': |
| 2518 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2519 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2520 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2521 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2522 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2523 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2524 | if ((flags & PercentValue) != 0) |
| 2525 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2526 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2527 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2528 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2529 | break; |
| 2530 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2531 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2532 | { |
| 2533 | MagickRealType |
| 2534 | black_point, |
| 2535 | gamma, |
| 2536 | white_point; |
| 2537 | |
| 2538 | MagickStatusType |
| 2539 | flags; |
| 2540 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2541 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2542 | if ((flags & RhoValue) == 0) |
| 2543 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2544 | black_point=geometry_info.rho; |
| 2545 | white_point=(MagickRealType) QuantumRange; |
| 2546 | if ((flags & SigmaValue) != 0) |
| 2547 | white_point=geometry_info.sigma; |
| 2548 | gamma=1.0; |
| 2549 | if ((flags & XiValue) != 0) |
| 2550 | gamma=geometry_info.xi; |
| 2551 | if ((flags & PercentValue) != 0) |
| 2552 | { |
| 2553 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2554 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2555 | } |
| 2556 | if ((flags & SigmaValue) == 0) |
| 2557 | white_point=(MagickRealType) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2558 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2559 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2560 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2561 | (void) LevelImage(_image,black_point,white_point,gamma,_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("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2565 | { |
| 2566 | char |
| 2567 | token[MaxTextExtent]; |
| 2568 | |
| 2569 | const char |
| 2570 | *p; |
| 2571 | |
| 2572 | PixelInfo |
| 2573 | black_point, |
| 2574 | white_point; |
| 2575 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2576 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2577 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2578 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2579 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2580 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2581 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2582 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2583 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2584 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2585 | GetMagickToken(p,&p,token); |
| 2586 | if (*token == '\0') |
| 2587 | white_point=black_point; /* set everything to that color */ |
| 2588 | else |
| 2589 | { |
| 2590 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2591 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2592 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2593 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2594 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2595 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2596 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2597 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2598 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2599 | (void) LevelImageColors(_image,&black_point,&white_point, |
| 2600 | plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2601 | break; |
| 2602 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2603 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2604 | { |
| 2605 | double |
| 2606 | black_point, |
| 2607 | white_point; |
| 2608 | |
| 2609 | MagickStatusType |
| 2610 | flags; |
| 2611 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2612 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2613 | if ((flags & RhoValue) == 0) |
| 2614 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2615 | black_point=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2616 | white_point=(MagickRealType) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2617 | if ((flags & SigmaValue) != 0) |
| 2618 | white_point=geometry_info.sigma; |
| 2619 | if ((flags & PercentValue) != 0) |
| 2620 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2621 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2622 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2623 | } |
| 2624 | if ((flags & SigmaValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2625 | white_point=(MagickRealType) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2626 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2627 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2628 | break; |
| 2629 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2630 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2631 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2632 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2633 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2634 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2635 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2636 | if ((flags & XValue) == 0) |
| 2637 | geometry.x=1; |
| 2638 | if ((flags & YValue) == 0) |
| 2639 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2640 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2641 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2642 | break; |
| 2643 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2644 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2645 | } |
| 2646 | case 'm': |
| 2647 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2648 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2649 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2650 | CLIWandWarnDepreciated("-remap"); |
| 2651 | CLISimpleOperatorImage(cli_wand,"-remap",NULL,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2652 | break; |
| 2653 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2654 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2655 | { |
| 2656 | Image |
| 2657 | *mask; |
| 2658 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2659 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2660 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2661 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2662 | break; |
| 2663 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2664 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2665 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2666 | if (mask == (Image *) NULL) |
| 2667 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2668 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2669 | mask=DestroyImage(mask); |
| 2670 | break; |
| 2671 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2672 | if (LocaleCompare("matte",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2673 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2674 | CLIWandWarnDepreciated(IfNormalOp?"-alpha Set":"-alpha Off"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2675 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2676 | DeactivateAlphaChannel, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2677 | break; |
| 2678 | } |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2679 | if (LocaleCompare("median",option+1) == 0) |
| 2680 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2681 | CLIWandWarnDepreciated("-statistic Median"); |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2682 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2683 | break; |
| 2684 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2685 | if (LocaleCompare("mode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2686 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2687 | /* FUTURE: note this is also a special "montage" option */ |
| 2688 | CLIWandWarnDepreciated("-statistic Mode"); |
| 2689 | CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2690 | break; |
| 2691 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2692 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2693 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2694 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2695 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2696 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2697 | break; |
| 2698 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2699 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2700 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2701 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2702 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2703 | break; |
| 2704 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2705 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2706 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2707 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2708 | break; |
| 2709 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2710 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2711 | { |
| 2712 | char |
| 2713 | token[MaxTextExtent]; |
| 2714 | |
| 2715 | const char |
| 2716 | *p; |
| 2717 | |
| 2718 | KernelInfo |
| 2719 | *kernel; |
| 2720 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2721 | ssize_t |
| 2722 | iterations; |
| 2723 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2724 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2725 | GetMagickToken(p,&p,token); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2726 | parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
| 2727 | if ( parse < 0 ) |
| 2728 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2729 | option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2730 | iterations=1L; |
| 2731 | GetMagickToken(p,&p,token); |
| 2732 | if ((*p == ':') || (*p == ',')) |
| 2733 | GetMagickToken(p,&p,token); |
| 2734 | if ((*p != '\0')) |
| 2735 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2736 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2737 | if (kernel == (KernelInfo *) NULL) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2738 | CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel", |
| 2739 | option,arg2); |
| 2740 | new_image=MorphologyImage(_image,(MorphologyMethod)parse, |
| 2741 | iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2742 | kernel=DestroyKernelInfo(kernel); |
| 2743 | break; |
| 2744 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2745 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2746 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2747 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2748 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2749 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2750 | if ((flags & SigmaValue) == 0) |
| 2751 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2752 | new_image=MotionBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2753 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2754 | break; |
| 2755 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2756 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2757 | } |
| 2758 | case 'n': |
| 2759 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2760 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2761 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2762 | (void) NegateImage(_image, plus_alt_op, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2763 | break; |
| 2764 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2765 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2766 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2767 | double |
| 2768 | attenuate; |
| 2769 | |
| 2770 | const char* |
| 2771 | value; |
| 2772 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2773 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2774 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2775 | CLIWandWarnDepreciated("-statistic NonPeak"); |
| 2776 | CLISimpleOperatorImage(cli_wand,"-statistic","NonPeak",arg1); |
| 2777 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2778 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2779 | parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1); |
| 2780 | if ( parse < 0 ) |
| 2781 | CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType", |
| 2782 | option,arg1); |
| 2783 | attenuate=1.0; |
| 2784 | value=GetImageOption(_image_info,"attenuate"); |
| 2785 | if (value != (const char *) NULL) |
| 2786 | attenuate=StringToDouble(value,(char **) NULL); |
| 2787 | new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate, |
| 2788 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2789 | break; |
| 2790 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2791 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2792 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2793 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2794 | break; |
| 2795 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2796 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2797 | } |
| 2798 | case 'o': |
| 2799 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2800 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2801 | { |
| 2802 | PixelInfo |
| 2803 | target; |
| 2804 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2805 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 2806 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,plus_alt_op, |
| 2807 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2808 | break; |
| 2809 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2810 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2811 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2812 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2813 | break; |
| 2814 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2815 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2816 | } |
| 2817 | case 'p': |
| 2818 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2819 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2820 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2821 | flags=ParseGeometry(arg1,&geometry_info); |
| 2822 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2823 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2824 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2825 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2826 | break; |
| 2827 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2828 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2829 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2830 | const char |
| 2831 | *caption; |
| 2832 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2833 | double |
| 2834 | angle; |
| 2835 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2836 | if (IfPlusOp) { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2837 | RandomInfo |
| 2838 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2839 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2840 | random_info=AcquireRandomInfo(); |
| 2841 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2842 | random_info=DestroyRandomInfo(random_info); |
| 2843 | } |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2844 | else { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2845 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2846 | if ((flags & RhoValue) == 0) |
| 2847 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2848 | angle=geometry_info.rho; |
| 2849 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2850 | caption=GetImageProperty(_image,"caption",_exception); |
| 2851 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 2852 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2853 | break; |
| 2854 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2855 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2856 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2857 | flags=ParseGeometry(arg1,&geometry_info); |
| 2858 | if ((flags & RhoValue) == 0) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2859 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2860 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
| 2861 | _quantize_info->dither,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2862 | break; |
| 2863 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2864 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2865 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2866 | /* FUTURE: should be a 'Genesis' option? |
| 2867 | Option however is also in WandSettingOptionInfo() |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2868 | Why??? |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2869 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2870 | parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1); |
| 2871 | if ( parse < 0 ) |
| 2872 | CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType", |
| 2873 | option,arg1); |
| 2874 | new_image=PreviewImage(_image,(PreviewType)parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2875 | break; |
| 2876 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2877 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2878 | { |
| 2879 | const char |
| 2880 | *name; |
| 2881 | |
| 2882 | const StringInfo |
| 2883 | *profile; |
| 2884 | |
| 2885 | Image |
| 2886 | *profile_image; |
| 2887 | |
| 2888 | ImageInfo |
| 2889 | *profile_info; |
| 2890 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2891 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2892 | { /* Remove a profile from the _image. */ |
| 2893 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 2894 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2895 | break; |
| 2896 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2897 | /* Associate a profile with the _image. */ |
| 2898 | profile_info=CloneImageInfo(_image_info); |
| 2899 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2900 | if (profile != (StringInfo *) NULL) |
| 2901 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2902 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2903 | profile_info=DestroyImageInfo(profile_info); |
| 2904 | if (profile_image == (Image *) NULL) |
| 2905 | { |
| 2906 | StringInfo |
| 2907 | *profile; |
| 2908 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2909 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2910 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2911 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2912 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2913 | if (profile != (StringInfo *) NULL) |
| 2914 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2915 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2916 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2917 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2918 | profile=DestroyStringInfo(profile); |
| 2919 | } |
| 2920 | profile_info=DestroyImageInfo(profile_info); |
| 2921 | break; |
| 2922 | } |
| 2923 | ResetImageProfileIterator(profile_image); |
| 2924 | name=GetNextImageProfile(profile_image); |
| 2925 | while (name != (const char *) NULL) |
| 2926 | { |
| 2927 | profile=GetImageProfile(profile_image,name); |
| 2928 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2929 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 2930 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2931 | name=GetNextImageProfile(profile_image); |
| 2932 | } |
| 2933 | profile_image=DestroyImage(profile_image); |
| 2934 | break; |
| 2935 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2936 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2937 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2938 | case 'r': |
| 2939 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2940 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2941 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2942 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2943 | if ((flags & RhoValue) == 0) |
| 2944 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2945 | new_image=RadialBlurImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2946 | break; |
| 2947 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2948 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2949 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2950 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2951 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2952 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2953 | if ((flags & SigmaValue) == 0) |
| 2954 | geometry.height=geometry.width; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2955 | (void) RaiseImage(_image,&geometry,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2956 | break; |
| 2957 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2958 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2959 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2960 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2961 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2962 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2963 | break; |
| 2964 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2965 | if (LocaleCompare("recolor",option+1) == 0) |
| 2966 | { |
| 2967 | CLIWandWarnDepreciated("-color-matrix"); |
| 2968 | CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL); |
| 2969 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2970 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2971 | { |
| 2972 | Image |
| 2973 | *remap_image; |
| 2974 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2975 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2976 | if (remap_image == (Image *) NULL) |
| 2977 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2978 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2979 | remap_image=DestroyImage(remap_image); |
| 2980 | break; |
| 2981 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2982 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2983 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2984 | if (IfNormalOp) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2985 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2986 | if (IfMagickFalse(IsGeometry(arg1))) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2987 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 2988 | arg1); |
| 2989 | (void) ResetImagePage(_image,arg1); |
| 2990 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2991 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2992 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2993 | break; |
| 2994 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2995 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2996 | { |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 2997 | /* FUTURE: Roll into a resize special operation */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2998 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2999 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3000 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3001 | if ((flags & SigmaValue) == 0) |
| 3002 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3003 | new_image=ResampleImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3004 | geometry_info.sigma,_image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3005 | break; |
| 3006 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3007 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3008 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3009 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3010 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3011 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3012 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3013 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3014 | break; |
| 3015 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3016 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3017 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3018 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3019 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3020 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3021 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3022 | break; |
| 3023 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3024 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3025 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3026 | flags=ParseGeometry(arg1,&geometry_info); |
| 3027 | if ((flags & RhoValue) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3028 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | ad255a0 | 2012-04-19 15:02:01 +0000 | [diff] [blame] | 3029 | if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows)) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3030 | break; |
| 3031 | if ((flags & LessValue) != 0 && (_image->columns >= _image->rows)) |
| 3032 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3033 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3034 | break; |
| 3035 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3036 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3037 | } |
| 3038 | case 's': |
| 3039 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3040 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3041 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3042 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3043 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3044 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3045 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3046 | new_image=SampleImage(_image,geometry.width,geometry.height, |
| 3047 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3048 | break; |
| 3049 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3050 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3051 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3052 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3053 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3054 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3055 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3056 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3057 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3058 | break; |
| 3059 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3060 | if (LocaleCompare("segment",option+1) == 0) |
| 3061 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3062 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3063 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3064 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3065 | if ((flags & SigmaValue) == 0) |
| 3066 | geometry_info.sigma=1.0; |
| 3067 | (void) SegmentImage(_image,_image->colorspace, |
| 3068 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3069 | _exception); |
| 3070 | break; |
| 3071 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3072 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3073 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3074 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3075 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3076 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3077 | if ((flags & SigmaValue) == 0) |
| 3078 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3079 | if ((flags & PercentValue) != 0) |
| 3080 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3081 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3082 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3083 | break; |
| 3084 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3085 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3086 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3087 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3088 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3089 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3090 | break; |
| 3091 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3092 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3093 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3094 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3095 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3096 | new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1, |
| 3097 | (double) QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3098 | break; |
| 3099 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3100 | if (LocaleCompare("set",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3101 | { |
| 3102 | char |
| 3103 | *value; |
| 3104 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3105 | if (IfPlusOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3106 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3107 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3108 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3109 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3110 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3111 | (void) DeleteImageOption(_image_info,arg1+7); |
| 3112 | (void) DeleteImageArtifact(_image,arg1+7); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3113 | } |
| 3114 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3115 | (void) DeleteImageProperty(_image,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3116 | break; |
| 3117 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3118 | value=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3119 | if (value == (char *) NULL) |
| 3120 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3121 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3122 | (void) SetImageRegistry(StringRegistryType,arg1+9,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3123 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3124 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3125 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3126 | (void) SetImageOption(_image_info,arg1+7,value); |
| 3127 | (void) SetImageArtifact(_image,arg1+7,value); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3128 | } |
| 3129 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3130 | (void) SetImageProperty(_image,arg1,value,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3131 | value=DestroyString(value); |
| 3132 | break; |
| 3133 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3134 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3135 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3136 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3137 | if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0)) |
| 3138 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3139 | new_image=ShadeImage(_image,normal_op,geometry_info.rho, |
| 3140 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3141 | break; |
| 3142 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3143 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3144 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3145 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3146 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3147 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3148 | if ((flags & SigmaValue) == 0) |
| 3149 | geometry_info.sigma=1.0; |
| 3150 | if ((flags & XiValue) == 0) |
| 3151 | geometry_info.xi=4.0; |
| 3152 | if ((flags & PsiValue) == 0) |
| 3153 | geometry_info.psi=4.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3154 | new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3155 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3156 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3157 | break; |
| 3158 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3159 | if (LocaleCompare("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3160 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3161 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3162 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3163 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3164 | if ((flags & SigmaValue) == 0) |
| 3165 | geometry_info.sigma=1.0; |
| 3166 | if ((flags & XiValue) == 0) |
| 3167 | geometry_info.xi=0.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3168 | new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3169 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3170 | break; |
| 3171 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3172 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3173 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3174 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3175 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3176 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3177 | new_image=ShaveImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3178 | break; |
| 3179 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3180 | if (LocaleCompare("shear",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3181 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3182 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3183 | if ((flags & RhoValue) == 0) |
| 3184 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3185 | if ((flags & SigmaValue) == 0) |
| 3186 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3187 | new_image=ShearImage(_image,geometry_info.rho, |
| 3188 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3189 | break; |
| 3190 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3191 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3192 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3193 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3194 | if ((flags & RhoValue) == 0) |
| 3195 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3196 | if ((flags & SigmaValue) == 0) |
| 3197 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3198 | if ((flags & PercentValue) != 0) |
| 3199 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3200 | 100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3201 | (void) SigmoidalContrastImage(_image,normal_op,geometry_info.rho, |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 3202 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3203 | break; |
| 3204 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3205 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3206 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3207 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3208 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3209 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3210 | if ((flags & SigmaValue) == 0) |
| 3211 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3212 | new_image=SketchImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3213 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3214 | break; |
| 3215 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3216 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3217 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3218 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3219 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3220 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3221 | QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3222 | break; |
| 3223 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3224 | if (LocaleCompare("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3225 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3226 | char |
| 3227 | *arguments; |
| 3228 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3229 | parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1); |
| 3230 | if ( parse < 0 ) |
| 3231 | CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod", |
| 3232 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3233 | arguments=InterpretImageProperties(_image_info,_image,arg2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3234 | if (arguments == (char *) NULL) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3235 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
| 3236 | new_image=SparseColorOption(_image,(SparseColorMethod)parse, |
| 3237 | arguments,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3238 | arguments=DestroyString(arguments); |
| 3239 | break; |
| 3240 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3241 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3242 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3243 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3244 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame^] | 3245 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3246 | new_image=SpliceImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3247 | break; |
| 3248 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3249 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3250 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame^] | 3251 | flags=ParseGeometry(arg1,&geometry_info); |
| 3252 | if ((flags & RhoValue) == 0) |
| 3253 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3254 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3255 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3256 | break; |
| 3257 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3258 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3259 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3260 | parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1); |
| 3261 | if ( parse < 0 ) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3262 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStatisticType", |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3263 | option,arg1); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3264 | flags=ParseGeometry(arg2,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3265 | if ((flags & RhoValue) == 0) |
| 3266 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3267 | if ((flags & SigmaValue) == 0) |
| 3268 | geometry_info.sigma=geometry_info.rho; |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3269 | new_image=StatisticImage(_image,(StatisticType)parse, |
| 3270 | (size_t) geometry_info.rho,(size_t) geometry_info.sigma, |
| 3271 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3272 | break; |
| 3273 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3274 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3275 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3276 | (void) StripImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3277 | break; |
| 3278 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3279 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3280 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame^] | 3281 | flags=ParseGeometry(arg2,&geometry_info); |
| 3282 | if ((flags & RhoValue) == 0) |
| 3283 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3284 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3285 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3286 | break; |
| 3287 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3288 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3289 | } |
| 3290 | case 't': |
| 3291 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3292 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3293 | { |
| 3294 | double |
| 3295 | threshold; |
| 3296 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3297 | threshold=(double) QuantumRange/2; |
| 3298 | if (normal_op) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3299 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3300 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3301 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3302 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3303 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3304 | break; |
| 3305 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3306 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3307 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3308 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3309 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3310 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3311 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3312 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3313 | break; |
| 3314 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3315 | if (LocaleCompare("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3316 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3317 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3318 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3319 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3320 | break; |
| 3321 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3322 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3323 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3324 | CLIWandWarnDepreciated("+distort AffineProjection"); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3325 | new_image=AffineTransformImage(_image,&_draw_info->affine,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3326 | break; |
| 3327 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3328 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3329 | { |
| 3330 | PixelInfo |
| 3331 | target; |
| 3332 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3333 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3334 | (void) TransparentPaintImage(_image,&target,(Quantum) |
| 3335 | TransparentAlpha,plus_alt_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3336 | break; |
| 3337 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3338 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3339 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3340 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3341 | break; |
| 3342 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3343 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3344 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3345 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3346 | break; |
| 3347 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3348 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3349 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3350 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3351 | break; |
| 3352 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3353 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3354 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3355 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3356 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3357 | break; |
| 3358 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3359 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3360 | } |
| 3361 | case 'u': |
| 3362 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3363 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3364 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3365 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? |
| 3366 | Option is not documented, bt appears to be for "identify". |
| 3367 | We may need a identify specific verbose! |
| 3368 | */ |
| 3369 | if (plus_alt_op) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3370 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3371 | break; |
| 3372 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3373 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3374 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3375 | break; |
| 3376 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3377 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3378 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3379 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3380 | break; |
| 3381 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3382 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3383 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3384 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3385 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3386 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3387 | if ((flags & SigmaValue) == 0) |
| 3388 | geometry_info.sigma=1.0; |
| 3389 | if ((flags & XiValue) == 0) |
| 3390 | geometry_info.xi=1.0; |
| 3391 | if ((flags & PsiValue) == 0) |
| 3392 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3393 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
| 3394 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3395 | break; |
| 3396 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3397 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3398 | } |
| 3399 | case 'v': |
| 3400 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3401 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3402 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3403 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3404 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3405 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3406 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3407 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3408 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3409 | break; |
| 3410 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3411 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3412 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3413 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3414 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3415 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3416 | if ((flags & SigmaValue) == 0) |
| 3417 | geometry_info.sigma=1.0; |
| 3418 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3419 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3420 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3421 | geometry_info.psi=0.1*_image->rows; |
| 3422 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3423 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3424 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3425 | break; |
| 3426 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3427 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3428 | } |
| 3429 | case 'w': |
| 3430 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3431 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3432 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3433 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3434 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3435 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3436 | if ((flags & SigmaValue) == 0) |
| 3437 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3438 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3439 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3440 | break; |
| 3441 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3442 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3443 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3444 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3445 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3446 | (void) WhiteThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3447 | break; |
| 3448 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3449 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3450 | } |
| 3451 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3452 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3453 | } |
| 3454 | /* |
| 3455 | Replace current image with any image that was generated |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3456 | and set image point to last image (so image->next is correct) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3457 | */ |
| 3458 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3459 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3460 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3461 | return; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3462 | #undef _image_info |
| 3463 | #undef _draw_info |
| 3464 | #undef _quantize_info |
| 3465 | #undef _image |
| 3466 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3467 | #undef IfNormalOp |
| 3468 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3469 | #undef normal_op |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3470 | #undef plus_alt_op |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3471 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3472 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3473 | WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3474 | const char *option, const char *arg1, const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3475 | { |
| 3476 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3477 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3478 | i; |
| 3479 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3480 | assert(cli_wand != (MagickCLI *) NULL); |
| 3481 | assert(cli_wand->signature == WandSignature); |
| 3482 | assert(cli_wand->wand.signature == WandSignature); |
| 3483 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3484 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3485 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3486 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3487 | #if !USE_WAND_METHODS |
| 3488 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3489 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3490 | n=GetImageListLength(cli_wand->wand.images); |
| 3491 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3492 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3493 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3494 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3495 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3496 | break; |
| 3497 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3498 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3499 | assert( i == n ); |
| 3500 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3501 | #else |
| 3502 | MagickResetIterator(&cli_wand->wand); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3503 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3504 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3505 | MagickResetIterator(&cli_wand->wand); |
| 3506 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3507 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3508 | } |
| 3509 | |
| 3510 | /* |
| 3511 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3512 | % % |
| 3513 | % % |
| 3514 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3515 | + 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] | 3516 | % % |
| 3517 | % % |
| 3518 | % % |
| 3519 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3520 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3521 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3522 | % entire image list as a whole. The result is often a complete replacment |
| 3523 | % 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] | 3524 | % |
| 3525 | % The format of the MogrifyImage method is: |
| 3526 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3527 | % void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3528 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3529 | % |
| 3530 | % A description of each parameter follows: |
| 3531 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3532 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3533 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3534 | % o option: The option string for the operation |
| 3535 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3536 | % o arg1, arg2: optional argument strings to the operation |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3537 | % arg2 is currently not used |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3538 | % |
| 3539 | % Example usage... |
| 3540 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3541 | % CLIListOperatorImages(cli_wand,MagickFalse,"-duplicate", "3", NULL); |
| 3542 | % CLIListOperatorImages(cli_wand,MagickTrue, "+append", NULL, NULL); |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3543 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 3544 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3545 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3546 | % cli_wand |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3547 | % argc,argv |
| 3548 | % i=index in argv |
| 3549 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 3550 | % option_info = GetCommandOptionInfo(argv[i]); |
| 3551 | % count=option_info->type; |
| 3552 | % option_type=option_info->flags; |
| 3553 | % |
| 3554 | % if ( (option_type & ListOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3555 | % CLIListOperatorImages(cli_wand,argv[i], |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3556 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 3557 | % count>=2 ? argv[i+2] : (char *)NULL ); |
| 3558 | % i += count+1; |
| 3559 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3560 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3561 | WandExport void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3562 | const char *option,const char *arg1, const char *magick_unused(arg2)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3563 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3564 | ssize_t |
| 3565 | parse; |
| 3566 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3567 | Image |
| 3568 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3569 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3570 | #define _image_info (cli_wand->wand.image_info) |
| 3571 | #define _images (cli_wand->wand.images) |
| 3572 | #define _exception (cli_wand->wand.exception) |
| 3573 | #define _draw_info (cli_wand->draw_info) |
| 3574 | #define _quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3575 | #define IfNormalOp (*option=='-') |
| 3576 | #define IfPlusOp (*option!='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3577 | #define normal_op IsMagickTrue(IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3578 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3579 | assert(cli_wand != (MagickCLI *) NULL); |
| 3580 | assert(cli_wand->signature == WandSignature); |
| 3581 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3582 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3583 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3584 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3585 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3586 | (void) SyncImagesSettings(_image_info,_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3587 | |
| 3588 | new_images=NewImageList(); |
| 3589 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3590 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3591 | { |
| 3592 | case 'a': |
| 3593 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3594 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3595 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3596 | new_images=AppendImages(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3597 | break; |
| 3598 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3599 | if (LocaleCompare("average",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3600 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3601 | CLIWandWarnDepreciated("-evaluate-sequence Mean"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3602 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3603 | break; |
| 3604 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3605 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3606 | } |
| 3607 | case 'c': |
| 3608 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3609 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3610 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3611 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3612 | break; |
| 3613 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3614 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3615 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3616 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3617 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3618 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3619 | /* FUTURE - make this a compose option, and thus can be used |
| 3620 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3621 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3622 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3623 | new_images=RemoveFirstImageFromList(&_images); |
| 3624 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3625 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3626 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3627 | break; |
cristy | e52fb5e | 2012-04-06 23:30:20 +0000 | [diff] [blame] | 3628 | (void) ClutImage(new_images,clut_image,new_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3629 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3630 | break; |
| 3631 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3632 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3633 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3634 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3635 | break; |
| 3636 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3637 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3638 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3639 | /* FUTURE - this may be replaced by a 'channel' method */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3640 | new_images=CombineImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3641 | break; |
| 3642 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3643 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3644 | { |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3645 | CompositeOperator |
| 3646 | compose; |
| 3647 | |
| 3648 | const char* |
| 3649 | value; |
| 3650 | |
| 3651 | MagickBooleanType |
| 3652 | clip_to_self; |
| 3653 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3654 | Image |
| 3655 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3656 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3657 | |
| 3658 | RectangleInfo |
| 3659 | geometry; |
| 3660 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3661 | /* Compose value from "-compose" option only */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3662 | value=GetImageOption(_image_info,"compose"); |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3663 | if (value == (const char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3664 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3665 | else |
| 3666 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 3667 | MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3668 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3669 | /* Get "clip-to-self" expert setting (false is normal) */ |
cristy | ca0e82c | 2012-04-10 11:53:24 +0000 | [diff] [blame] | 3670 | value=GetImageOption(_image_info,"compose:clip-to-self"); |
| 3671 | if (value == (const char *) NULL) |
| 3672 | clip_to_self=MagickTrue; |
| 3673 | else |
| 3674 | clip_to_self=IsStringTrue(GetImageOption(_image_info, |
| 3675 | "compose:clip-to-self")); /* if this is true */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3676 | value=GetImageOption(_image_info,"compose:outside-overlay"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3677 | if (value != (const char *) NULL) { /* or this false */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3678 | /* FUTURE: depreciate warning for "compose:outside-overlay"*/ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3679 | clip_to_self= IsMagickFalse(IsStringNotFalse(value)); |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3680 | } |
| 3681 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3682 | new_images=RemoveFirstImageFromList(&_images); |
| 3683 | source_image=RemoveFirstImageFromList(&_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3684 | if (source_image == (Image *) NULL) |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3685 | break; /* FUTURE - produce Exception, rather than silent fail */ |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3686 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3687 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3688 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3689 | source_image->geometry,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3690 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3691 | SetGeometry(source_image,&geometry); |
| 3692 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3693 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
| 3694 | new_images->gravity, &geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3695 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3696 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3697 | if (mask_image != (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3698 | { /* handle a third write mask image */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3699 | if ((compose == DisplaceCompositeOp) || |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3700 | (compose == DistortCompositeOp)) { |
| 3701 | /* Merge Y displacement into X displace/distort map. */ |
| 3702 | (void) CompositeImage(source_image,mask_image, |
| 3703 | CopyGreenCompositeOp,MagickTrue,0,0,_exception); |
| 3704 | mask_image=DestroyImage(mask_image); |
| 3705 | } |
| 3706 | else { |
| 3707 | /* Set a blending mask for the composition. */ |
| 3708 | (void) NegateImage(mask_image,MagickFalse,_exception); |
| 3709 | (void) SetImageMask(new_images,mask_image,_exception); |
| 3710 | mask_image=DestroyImage(mask_image); |
| 3711 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3712 | } |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3713 | (void) CompositeImage(new_images,source_image,compose,clip_to_self, |
| 3714 | geometry.x,geometry.y,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3715 | (void) SetImageMask(new_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3716 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3717 | break; |
| 3718 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3719 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3720 | } |
| 3721 | case 'd': |
| 3722 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3723 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3724 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3725 | CLIWandWarnDepreciated("-layer CompareAny"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3726 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3727 | break; |
| 3728 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3729 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3730 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3731 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3732 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3733 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3734 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3735 | break; |
| 3736 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3737 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3738 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3739 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3740 | { |
| 3741 | const char |
| 3742 | *p; |
| 3743 | |
| 3744 | size_t |
| 3745 | number_duplicates; |
| 3746 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3747 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3748 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3749 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3750 | number_duplicates=(size_t) StringToLong(arg1); |
| 3751 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3752 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3753 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3754 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3755 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3756 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3757 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3758 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3759 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3760 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3761 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3762 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3763 | break; |
| 3764 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3765 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3766 | } |
| 3767 | case 'e': |
| 3768 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3769 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3770 | { |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3771 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3772 | if ( parse < 0 ) |
| 3773 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3774 | option,arg1); |
| 3775 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
| 3776 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3777 | break; |
| 3778 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3779 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3780 | } |
| 3781 | case 'f': |
| 3782 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3783 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3784 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3785 | new_images=ForwardFourierTransformImage(_images,normal_op,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3786 | break; |
| 3787 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3788 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3789 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3790 | /* REDIRECTED to use -layers flatten instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3791 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3792 | break; |
| 3793 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3794 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3795 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3796 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3797 | break; |
| 3798 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3799 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3800 | } |
| 3801 | case 'h': |
| 3802 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3803 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3804 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3805 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3806 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3807 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3808 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3809 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3810 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3811 | new_images=RemoveFirstImageFromList(&_images); |
| 3812 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3813 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3814 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3815 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3816 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3817 | break; |
| 3818 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3819 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3820 | } |
| 3821 | case 'i': |
| 3822 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3823 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3824 | { |
| 3825 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3826 | *magnitude_image, |
| 3827 | *phase_image; |
| 3828 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3829 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3830 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3831 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3832 | if (phase_image == (Image *) NULL) |
| 3833 | break; |
| 3834 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3835 | normal_op,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3836 | magnitude_image=DestroyImage(magnitude_image); |
| 3837 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3838 | break; |
| 3839 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3840 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3841 | { |
| 3842 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3843 | *insert_image, |
| 3844 | *index_image; |
| 3845 | |
| 3846 | ssize_t |
| 3847 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3848 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3849 | if (IfNormalOp && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3850 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3851 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3852 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3853 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3854 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3855 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3856 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3857 | PrependImageToList(&_images,insert_image); |
| 3858 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3859 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3860 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3861 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3862 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3863 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3864 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3865 | InsertImageInList(&index_image,insert_image); |
| 3866 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3867 | _images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3868 | break; |
| 3869 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3870 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3871 | } |
| 3872 | case 'l': |
| 3873 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3874 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3875 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3876 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3877 | if ( parse < 0 ) |
| 3878 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3879 | option,arg1); |
| 3880 | switch ((ImageLayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3881 | { |
| 3882 | case CoalesceLayer: |
| 3883 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3884 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3885 | break; |
| 3886 | } |
| 3887 | case CompareAnyLayer: |
| 3888 | case CompareClearLayer: |
| 3889 | case CompareOverlayLayer: |
| 3890 | default: |
| 3891 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3892 | new_images=CompareImagesLayers(_images,(ImageLayerMethod) parse, |
| 3893 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3894 | break; |
| 3895 | } |
| 3896 | case MergeLayer: |
| 3897 | case FlattenLayer: |
| 3898 | case MosaicLayer: |
| 3899 | case TrimBoundsLayer: |
| 3900 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3901 | new_images=MergeImageLayers(_images,(ImageLayerMethod) parse, |
| 3902 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3903 | break; |
| 3904 | } |
| 3905 | case DisposeLayer: |
| 3906 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3907 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3908 | break; |
| 3909 | } |
| 3910 | case OptimizeImageLayer: |
| 3911 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3912 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3913 | break; |
| 3914 | } |
| 3915 | case OptimizePlusLayer: |
| 3916 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3917 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3918 | break; |
| 3919 | } |
| 3920 | case OptimizeTransLayer: |
| 3921 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3922 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3923 | break; |
| 3924 | } |
| 3925 | case RemoveDupsLayer: |
| 3926 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3927 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3928 | break; |
| 3929 | } |
| 3930 | case RemoveZeroLayer: |
| 3931 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3932 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3933 | break; |
| 3934 | } |
| 3935 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3936 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3937 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3938 | if (new_images == (Image *) NULL) |
| 3939 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3940 | _images=DestroyImageList(_images); |
| 3941 | _images=OptimizeImageLayers(new_images,_exception); |
| 3942 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3943 | break; |
| 3944 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3945 | OptimizeImageTransparency(_images,_exception); |
| 3946 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 3947 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3948 | break; |
| 3949 | } |
| 3950 | case CompositeLayer: |
| 3951 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3952 | Image |
| 3953 | *source; |
| 3954 | |
| 3955 | RectangleInfo |
| 3956 | geometry; |
| 3957 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3958 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3959 | compose; |
| 3960 | |
| 3961 | const char* |
| 3962 | value; |
| 3963 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3964 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3965 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3966 | if (value != (const char *) NULL) |
| 3967 | compose=(CompositeOperator) ParseCommandOption( |
| 3968 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3969 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3970 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3971 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3972 | while (source != (Image *) NULL) |
| 3973 | { |
| 3974 | source=GetNextImageInList(source); |
| 3975 | if ((source != (Image *) NULL) && |
| 3976 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 3977 | break; |
| 3978 | } |
| 3979 | if (source != (Image *) NULL) |
| 3980 | { |
| 3981 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 3982 | (GetNextImageInList(source) == (Image *) NULL)) |
| 3983 | source=(Image *) NULL; |
| 3984 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3985 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3986 | source=SplitImageList(source->previous); |
| 3987 | DeleteImageFromList(&source); |
| 3988 | } |
| 3989 | } |
| 3990 | if (source == (Image *) NULL) |
| 3991 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3992 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3993 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3994 | break; |
| 3995 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3996 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3997 | SetGeometry(_images,&geometry); |
| 3998 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3999 | geometry.width=source->page.width != 0 ? |
| 4000 | source->page.width : source->columns; |
| 4001 | geometry.height=source->page.height != 0 ? |
| 4002 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4003 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 4004 | _images->page.width : _images->columns, |
| 4005 | _images->page.height != 0 ? _images->page.height : |
| 4006 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4007 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4008 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4009 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 4010 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4011 | source=DestroyImageList(source); |
| 4012 | break; |
| 4013 | } |
| 4014 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4015 | break; |
| 4016 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4017 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4018 | } |
| 4019 | case 'm': |
| 4020 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4021 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4022 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 4023 | CLIWandWarnDepreciated("+remap"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4024 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4025 | break; |
| 4026 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4027 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4028 | { |
| 4029 | Image |
| 4030 | *morph_image; |
| 4031 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4032 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 4033 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4034 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4035 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4036 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4037 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4038 | _images=DestroyImageList(_images); |
| 4039 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4040 | break; |
| 4041 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4042 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4043 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4044 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 4045 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4046 | break; |
| 4047 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4048 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4049 | } |
| 4050 | case 'p': |
| 4051 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4052 | if (LocaleCompare("print",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4053 | { |
| 4054 | char |
| 4055 | *string; |
| 4056 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4057 | string=InterpretImageProperties(_image_info,_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4058 | if (string == (char *) NULL) |
| 4059 | break; |
| 4060 | (void) FormatLocaleFile(stdout,"%s",string); |
| 4061 | string=DestroyString(string); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4062 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4063 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4064 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4065 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 4066 | /* FUTURE: better parsing using ScriptToken() from string ??? */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4067 | char |
| 4068 | **arguments; |
| 4069 | |
| 4070 | int |
| 4071 | j, |
| 4072 | number_arguments; |
| 4073 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4074 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4075 | if (arguments == (char **) NULL) |
| 4076 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4077 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4078 | { |
| 4079 | char |
| 4080 | breaker, |
| 4081 | quote, |
| 4082 | *token; |
| 4083 | |
| 4084 | const char |
| 4085 | *arguments; |
| 4086 | |
| 4087 | int |
| 4088 | next, |
| 4089 | status; |
| 4090 | |
| 4091 | size_t |
| 4092 | length; |
| 4093 | |
| 4094 | TokenInfo |
| 4095 | *token_info; |
| 4096 | |
| 4097 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4098 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4099 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4100 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4101 | token=(char *) NULL; |
| 4102 | if (~length >= (MaxTextExtent-1)) |
| 4103 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4104 | sizeof(*token)); |
| 4105 | if (token == (char *) NULL) |
| 4106 | break; |
| 4107 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4108 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4109 | token_info=AcquireTokenInfo(); |
| 4110 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4111 | "\"",'\0',&breaker,&next,"e); |
| 4112 | token_info=DestroyTokenInfo(token_info); |
| 4113 | if (status == 0) |
| 4114 | { |
| 4115 | const char |
| 4116 | *argv; |
| 4117 | |
| 4118 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4119 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4120 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4121 | } |
| 4122 | token=DestroyString(token); |
| 4123 | break; |
| 4124 | } |
| 4125 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4126 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4127 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4128 | for (j=0; j < number_arguments; j++) |
| 4129 | arguments[j]=DestroyString(arguments[j]); |
| 4130 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4131 | break; |
| 4132 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4133 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4134 | } |
| 4135 | case 'r': |
| 4136 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4137 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4138 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4139 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4140 | break; |
| 4141 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4142 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4143 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4144 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4145 | break; |
| 4146 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4147 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4148 | } |
| 4149 | case 's': |
| 4150 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4151 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4152 | { |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4153 | /* FUTURE: this option needs more work to make better */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4154 | ssize_t |
| 4155 | offset; |
| 4156 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4157 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 4158 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4159 | offset=(ssize_t) StringToLong(arg1); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4160 | new_images=SmushImages(_images,normal_op,offset,_exception); |
| 4161 | break; |
| 4162 | } |
| 4163 | if (LocaleCompare("subimage",option+1) == 0) |
| 4164 | { |
| 4165 | Image |
| 4166 | *base_image, |
| 4167 | *compare_image; |
| 4168 | |
| 4169 | const char * |
| 4170 | value; |
| 4171 | |
| 4172 | MetricType |
| 4173 | metric; |
| 4174 | |
| 4175 | double |
| 4176 | similarity; |
| 4177 | |
| 4178 | RectangleInfo |
| 4179 | offset; |
| 4180 | |
| 4181 | base_image=GetImageFromList(_images,0); |
| 4182 | compare_image=GetImageFromList(_images,1); |
| 4183 | |
| 4184 | /* Comparision Metric */ |
| 4185 | metric=UndefinedMetric; |
| 4186 | value=GetImageOption(_image_info,"metric"); |
| 4187 | if (value != (const char *) NULL) |
| 4188 | metric=(MetricType) ParseCommandOption(MagickMetricOptions, |
| 4189 | MagickFalse,value); |
| 4190 | |
| 4191 | new_images=SimilarityImage(base_image,compare_image,metric, |
| 4192 | &offset,&similarity,_exception); |
| 4193 | |
| 4194 | if ( new_images != (Image *)NULL ) { |
| 4195 | char |
| 4196 | result[MaxTextExtent]; |
| 4197 | |
| 4198 | (void) FormatLocaleString(result,MaxTextExtent,"%lf",similarity); |
| 4199 | (void) SetImageProperty(new_images,"subimage:similarity",result, |
| 4200 | _exception); |
| 4201 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4202 | (long) offset.x); |
| 4203 | (void) SetImageProperty(new_images,"subimage:x",result, |
| 4204 | _exception); |
| 4205 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4206 | (long) offset.y); |
| 4207 | (void) SetImageProperty(new_images,"subimage:y",result, |
| 4208 | _exception); |
| 4209 | (void) FormatLocaleString(result,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 4210 | (unsigned long) offset.width,(unsigned long) offset.height, |
| 4211 | (long) offset.x,(long) offset.y); |
| 4212 | (void) SetImageProperty(new_images,"subimage:offset",result, |
| 4213 | _exception); |
| 4214 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4215 | break; |
| 4216 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4217 | if (LocaleCompare("swap",option+1) == 0) { |
| 4218 | Image |
| 4219 | *p, |
| 4220 | *q, |
| 4221 | *swap; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4222 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4223 | ssize_t |
| 4224 | index, |
| 4225 | swap_index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4226 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4227 | index=-1; |
| 4228 | swap_index=-2; |
| 4229 | if (IfNormalOp) { |
| 4230 | GeometryInfo |
| 4231 | geometry_info; |
| 4232 | |
| 4233 | MagickStatusType |
| 4234 | flags; |
| 4235 | |
| 4236 | swap_index=(-1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4237 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame^] | 4238 | if ((flags & RhoValue) != 0) |
| 4239 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4240 | index=(ssize_t) geometry_info.rho; |
| 4241 | if ((flags & SigmaValue) != 0) |
| 4242 | swap_index=(ssize_t) geometry_info.sigma; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4243 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4244 | p=GetImageFromList(_images,index); |
| 4245 | q=GetImageFromList(_images,swap_index); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4246 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) { |
| 4247 | if (IfNormalOp) |
| 4248 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1) |
| 4249 | else |
| 4250 | CLIWandExceptionBreak(OptionError,"TwoOrMoreImagesRequired",option); |
| 4251 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4252 | if (p == q) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4253 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4254 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4255 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
| 4256 | ReplaceImageInList(&q,swap); |
| 4257 | _images=GetFirstImageInList(q); |
| 4258 | break; |
| 4259 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4260 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4261 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4262 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4263 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4264 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4265 | if (new_images == (Image *) NULL) |
| 4266 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4267 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4268 | if (_images != (Image *) NULL) |
| 4269 | _images=DestroyImageList(_images); |
| 4270 | _images=GetFirstImageInList(new_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4271 | return; |
| 4272 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4273 | #undef _image_info |
| 4274 | #undef _images |
| 4275 | #undef _exception |
| 4276 | #undef _draw_info |
| 4277 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4278 | #undef IfNormalOp |
| 4279 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4280 | #undef normal_op |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4281 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4282 | |
| 4283 | /* |
| 4284 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4285 | % % |
| 4286 | % % |
| 4287 | % % |
| 4288 | + C L I S p e c i a l O p e r a t i o n s % |
| 4289 | % % |
| 4290 | % % |
| 4291 | % % |
| 4292 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4293 | % |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4294 | % CLISpecialOperator() Applies operations that may not actually need images |
| 4295 | % in an image list wen it is applied. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4296 | % |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4297 | % The classic operators of this type is -read, which actually creates images |
| 4298 | % even when no images are present. Or image stack operators, which can be |
| 4299 | % applied to empty image lists. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4300 | % |
| 4301 | % Note: unlike other Operators, these may involve other special 'option' |
| 4302 | % character prefixes, other than simply '-' or '+'. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4303 | % |
| 4304 | % The format of the CLISpecialOption method is: |
| 4305 | % |
| 4306 | % void CLISpecialOption(MagickCLI *cli_wand,const char *option, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4307 | % const char *arg1) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4308 | % |
| 4309 | % A description of each parameter follows: |
| 4310 | % |
| 4311 | % o cli_wand: the main CLI Wand to use. |
| 4312 | % |
| 4313 | % o option: The special option (with any switch char) to process |
| 4314 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4315 | % o arg1: Argument for option, if required |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4316 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4317 | % Example Usage... |
| 4318 | % |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4319 | % CLISpecialOperator(cli_wand,"-read","rose:"); |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4320 | % |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4321 | % Or for handling command line arguments EG: +/-option ["arg1"] |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4322 | % |
| 4323 | % cli_wand |
| 4324 | % argc,argv |
| 4325 | % i=index in argv |
| 4326 | % |
| 4327 | % option_info = GetCommandOptionInfo(argv[i]); |
| 4328 | % count=option_info->type; |
| 4329 | % option_type=option_info->flags; |
| 4330 | % |
| 4331 | % if ( (option_type & SpecialOptionFlag) != 0 ) |
| 4332 | % CLISpecialOperator(cli_wand,argv[i], |
| 4333 | % count>=1 ? argv[i+1] : (char *)NULL); |
| 4334 | % i += count+1; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4335 | % |
| 4336 | */ |
| 4337 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4338 | WandExport void CLISpecialOperator(MagickCLI *cli_wand, |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4339 | const char *option, const char *arg1) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4340 | { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4341 | #define _image_info (cli_wand->wand.image_info) |
| 4342 | #define _images (cli_wand->wand.images) |
| 4343 | #define _exception (cli_wand->wand.exception) |
| 4344 | #define IfNormalOp (*option=='-') |
| 4345 | #define IfPlusOp (*option!='-') |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4346 | |
| 4347 | assert(cli_wand != (MagickCLI *) NULL); |
| 4348 | assert(cli_wand->signature == WandSignature); |
| 4349 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4350 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4351 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4352 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4353 | if(_images != (Image *)NULL) |
| 4354 | (void) SyncImagesSettings(cli_wand->wand.image_info,_images,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4355 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4356 | /* |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4357 | No-op options (ignore these) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4358 | */ |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4359 | if (LocaleCompare("noop",option+1) == 0) /* no argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4360 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4361 | if (LocaleCompare("sans",option+1) == 0) /* one argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4362 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4363 | if (LocaleCompare("sans0",option+1) == 0) /* no argument */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4364 | return; |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4365 | if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4366 | return; |
| 4367 | /* |
| 4368 | Image Reading |
| 4369 | */ |
| 4370 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4371 | ( LocaleCompare("--",option) == 0 ) ) { |
| 4372 | int |
| 4373 | argc; |
| 4374 | char |
| 4375 | **argv; |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4376 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4377 | ssize_t |
| 4378 | i; |
| 4379 | |
| 4380 | /* Expand the filename argument (meta-characters or "@filelist" ) */ |
| 4381 | argc = 1; |
cristy | e71f294 | 2012-04-04 11:07:05 +0000 | [diff] [blame] | 4382 | argv = (char **) &arg1; |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4383 | MagickBooleanType |
| 4384 | status=ExpandFilenames(&argc,&argv); |
| 4385 | |
| 4386 | if (IfMagickFalse(status)) |
| 4387 | CLIWandExceptArgReturn(ResourceLimitError,"MemoryAllocationFailed", |
| 4388 | option,GetExceptionMessage(errno)); |
| 4389 | |
| 4390 | /* loop over expanded list reading images */ |
| 4391 | for (i=0; i<argc; i++) { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4392 | #if !USE_WAND_METHODS |
| 4393 | Image * |
| 4394 | new_images; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4395 | if (IfMagickTrue(_image_info->ping)) |
| 4396 | new_images=PingImages(_image_info,argv[i],_exception); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4397 | else |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4398 | new_images=ReadImages(_image_info,argv[i],_exception); |
| 4399 | AppendImageToList(&_images, new_images); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4400 | #else |
| 4401 | /* read images using MagickWand method - no ping */ |
| 4402 | /* This is not working! - it locks up in a CPU loop! */ |
| 4403 | MagickSetLastIterator(&cli_wand->wand); |
| 4404 | MagickReadImage(&cli_wand->wand,arg1); |
| 4405 | MagickSetFirstIterator(&cli_wand->wand); |
| 4406 | #endif |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4407 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4408 | /* FUTURE: how do I free the expanded filename arguments??? */ |
| 4409 | |
| 4410 | return; |
| 4411 | } |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4412 | /* |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 4413 | Image Writing (no-images present is valid in specific cases) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4414 | */ |
| 4415 | if (LocaleCompare("write",option+1) == 0) { |
| 4416 | char |
| 4417 | key[MaxTextExtent]; |
| 4418 | |
| 4419 | Image |
| 4420 | *write_images; |
| 4421 | |
| 4422 | ImageInfo |
| 4423 | *write_info; |
| 4424 | |
| 4425 | /* Need images, unless a "null:" output coder is used */ |
| 4426 | if ( cli_wand->wand.images == (Image *) NULL ) { |
anthony | a9e4f5d | 2012-04-12 06:44:02 +0000 | [diff] [blame] | 4427 | if ( LocaleCompare(arg1,"null:") == 0 ) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4428 | return; |
| 4429 | CLIWandExceptArgReturn(OptionError,"NoImagesForWrite",option,arg1); |
| 4430 | } |
| 4431 | |
| 4432 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
| 4433 | (void) DeleteImageRegistry(key); |
| 4434 | write_images=_images; |
| 4435 | if (IfPlusOp) |
| 4436 | write_images=CloneImageList(_images,_exception); |
| 4437 | write_info=CloneImageInfo(_image_info); |
| 4438 | (void) WriteImages(write_info,write_images,arg1,_exception); |
| 4439 | write_info=DestroyImageInfo(write_info); |
| 4440 | if (IfPlusOp) |
| 4441 | write_images=DestroyImageList(write_images); |
| 4442 | return; |
| 4443 | } |
| 4444 | /* |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4445 | Parenthesis and Brace operations |
| 4446 | */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4447 | if (LocaleCompare("(",option) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4448 | /* stack 'push' images */ |
| 4449 | Stack |
| 4450 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4451 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4452 | size_t |
| 4453 | size; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4454 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4455 | size=0; |
| 4456 | node=cli_wand->image_list_stack; |
| 4457 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4458 | size++; |
| 4459 | if ( size >= MAX_STACK_DEPTH ) |
| 4460 | CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option); |
| 4461 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4462 | if (node == (Stack *) NULL) |
| 4463 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4464 | "MemoryAllocationFailed",option); |
| 4465 | node->data = (void *)cli_wand->wand.images; |
| 4466 | cli_wand->wand.images = NewImageList(); |
| 4467 | node->next = cli_wand->image_list_stack; |
| 4468 | cli_wand->image_list_stack = node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4469 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4470 | /* handle respect-parenthesis */ |
| 4471 | if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info, |
| 4472 | "respect-parenthesis")))) |
| 4473 | option="{"; /* fall-thru so as to push image settings too */ |
| 4474 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4475 | return; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4476 | } |
| 4477 | if (LocaleCompare("{",option) == 0) { |
| 4478 | /* stack 'push' of image_info settings */ |
| 4479 | Stack |
| 4480 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4481 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4482 | size_t |
| 4483 | size; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4484 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4485 | size=0; |
| 4486 | node=cli_wand->image_info_stack; |
| 4487 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4488 | size++; |
| 4489 | if ( size >= MAX_STACK_DEPTH ) |
| 4490 | CLIWandExceptionReturn(OptionError,"CurlyBracesNestedTooDeeply",option); |
| 4491 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4492 | if (node == (Stack *) NULL) |
| 4493 | CLIWandExceptionReturn(ResourceLimitFatalError, |
| 4494 | "MemoryAllocationFailed",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4495 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4496 | node->data = (void *)cli_wand->wand.image_info; |
| 4497 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
| 4498 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
| 4499 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4500 | option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4501 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4502 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4503 | return; |
| 4504 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4505 | |
| 4506 | node->next = cli_wand->image_info_stack; |
| 4507 | cli_wand->image_info_stack = node; |
| 4508 | |
| 4509 | return; |
| 4510 | } |
| 4511 | if (LocaleCompare(")",option) == 0) { |
| 4512 | /* pop images from stack */ |
| 4513 | Stack |
| 4514 | *node; |
| 4515 | |
| 4516 | node = (Stack *)cli_wand->image_list_stack; |
| 4517 | if ( node == (Stack *)NULL) |
| 4518 | CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option); |
| 4519 | cli_wand->image_list_stack = node->next; |
| 4520 | |
| 4521 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4522 | cli_wand->wand.images= (Image *)node->data; |
| 4523 | node = (Stack *)RelinquishMagickMemory(node); |
| 4524 | |
| 4525 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
| 4526 | node = cli_wand->image_info_stack; |
| 4527 | if ( node != (Stack *)NULL) |
| 4528 | { |
| 4529 | if (IfMagickTrue(IsStringTrue(GetImageOption( |
| 4530 | cli_wand->wand.image_info,"respect-parenthesis")))) |
| 4531 | option="}"; /* fall-thru so as to pop image settings too */ |
| 4532 | else |
| 4533 | return; |
| 4534 | } |
| 4535 | else |
| 4536 | return; |
| 4537 | } |
| 4538 | if (LocaleCompare("}",option) == 0) { |
| 4539 | /* pop image_info settings from stack */ |
| 4540 | Stack |
| 4541 | *node; |
| 4542 | |
| 4543 | node = (Stack *)cli_wand->image_info_stack; |
| 4544 | if ( node == (Stack *)NULL) |
| 4545 | CLIWandExceptionReturn(OptionError,"UnbalancedCurlyBraces",option); |
| 4546 | cli_wand->image_info_stack = node->next; |
| 4547 | |
| 4548 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
| 4549 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4550 | node = (Stack *)RelinquishMagickMemory(node); |
| 4551 | |
| 4552 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4553 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4554 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4555 | |
| 4556 | return; |
| 4557 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4558 | if (LocaleCompare("clone",option+1) == 0) { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4559 | Image |
| 4560 | *new_images; |
| 4561 | |
| 4562 | if (*option == '+') |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4563 | arg1="-1"; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4564 | if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4565 | CLIWandExceptionReturn(OptionError,"InvalidArgument",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4566 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4567 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4568 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4569 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4570 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); |
| 4571 | new_images=CloneImages(new_images,arg1,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4572 | if (new_images == (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4573 | CLIWandExceptionReturn(OptionError,"NoSuchImage",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4574 | AppendImageToList(&_images,new_images); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4575 | return; |
| 4576 | } |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4577 | /* |
| 4578 | Informational Operations |
| 4579 | */ |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4580 | if (LocaleCompare("version",option+1) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4581 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
| 4582 | GetMagickVersion((size_t *) NULL)); |
| 4583 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 4584 | GetMagickCopyright()); |
| 4585 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 4586 | GetMagickFeatures()); |
| 4587 | return; |
| 4588 | } |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 4589 | if (LocaleCompare("list",option+1) == 0) { |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4590 | /* FUTURE: This should really be built into the MagickCore |
| 4591 | It does not actually require a cli-wand or and images! |
| 4592 | */ |
| 4593 | ssize_t |
| 4594 | list; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4595 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4596 | list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); |
| 4597 | if ( list < 0 ) { |
| 4598 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4599 | return; |
| 4600 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4601 | switch (list) |
| 4602 | { |
| 4603 | case MagickCoderOptions: |
| 4604 | { |
| 4605 | (void) ListCoderInfo((FILE *) NULL,_exception); |
| 4606 | break; |
| 4607 | } |
| 4608 | case MagickColorOptions: |
| 4609 | { |
| 4610 | (void) ListColorInfo((FILE *) NULL,_exception); |
| 4611 | break; |
| 4612 | } |
| 4613 | case MagickConfigureOptions: |
| 4614 | { |
| 4615 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
| 4616 | break; |
| 4617 | } |
| 4618 | case MagickDelegateOptions: |
| 4619 | { |
| 4620 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
| 4621 | break; |
| 4622 | } |
| 4623 | case MagickFontOptions: |
| 4624 | { |
| 4625 | (void) ListTypeInfo((FILE *) NULL,_exception); |
| 4626 | break; |
| 4627 | } |
| 4628 | case MagickFormatOptions: |
| 4629 | (void) ListMagickInfo((FILE *) NULL,_exception); |
| 4630 | break; |
| 4631 | case MagickLocaleOptions: |
| 4632 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
| 4633 | break; |
| 4634 | case MagickLogOptions: |
| 4635 | (void) ListLogInfo((FILE *) NULL,_exception); |
| 4636 | break; |
| 4637 | case MagickMagicOptions: |
| 4638 | (void) ListMagicInfo((FILE *) NULL,_exception); |
| 4639 | break; |
| 4640 | case MagickMimeOptions: |
| 4641 | (void) ListMimeInfo((FILE *) NULL,_exception); |
| 4642 | break; |
| 4643 | case MagickModuleOptions: |
| 4644 | (void) ListModuleInfo((FILE *) NULL,_exception); |
| 4645 | break; |
| 4646 | case MagickPolicyOptions: |
| 4647 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
| 4648 | break; |
| 4649 | case MagickResourceOptions: |
| 4650 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
| 4651 | break; |
| 4652 | case MagickThresholdOptions: |
| 4653 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
| 4654 | break; |
| 4655 | default: |
| 4656 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
| 4657 | _exception); |
| 4658 | break; |
| 4659 | } |
| 4660 | return; |
| 4661 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4662 | |
| 4663 | #if 0 |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4664 | // Other 'special' options this should handle |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 4665 | // "region" "reset" "arg" |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4666 | if ( ( process_flags & ProcessUnknownOptionError ) != 0 ) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4667 | #endif |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4668 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4669 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4670 | #undef _image_info |
| 4671 | #undef _images |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4672 | #undef _exception |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4673 | #undef IfNormalOp |
| 4674 | #undef IfPlusOp |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4675 | } |