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 | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 53 | #include "MagickWand/operation.h" |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 54 | #include "MagickWand/operation-private.h" |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 55 | #include "MagickWand/wand.h" |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 56 | #include "MagickCore/monitor-private.h" |
| 57 | #include "MagickCore/thread-private.h" |
| 58 | #include "MagickCore/string-private.h" |
| 59 | |
| 60 | /* |
| 61 | Define declarations. |
| 62 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 63 | #define USE_WAND_METHODS 0 |
| 64 | #define MAX_STACK_DEPTH 32 |
| 65 | #define UNDEFINED_COMPRESSION_QUALITY 0UL |
| 66 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 67 | /* |
| 68 | Constant declaration. (temporary exports) |
| 69 | */ |
| 70 | static const char |
| 71 | BackgroundColor[] = "#fff", /* white */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 72 | BorderColor[] = "#dfdfdf", /* sRGB gray */ |
| 73 | MatteColor[] = "#bdbdbd"; /* slightly darker gray */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 74 | |
| 75 | /* |
| 76 | ** Function to report on the progress of image operations |
| 77 | */ |
| 78 | static MagickBooleanType MonitorProgress(const char *text, |
| 79 | const MagickOffsetType offset,const MagickSizeType extent, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 80 | void *wand_unused(cli_wandent_data)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 81 | { |
| 82 | char |
| 83 | message[MaxTextExtent], |
| 84 | tag[MaxTextExtent]; |
| 85 | |
| 86 | const char |
| 87 | *locale_message; |
| 88 | |
| 89 | register char |
| 90 | *p; |
| 91 | |
| 92 | if (extent < 2) |
| 93 | return(MagickTrue); |
| 94 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 95 | p=strrchr(tag,'/'); |
| 96 | if (p != (char *) NULL) |
| 97 | *p='\0'; |
| 98 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
| 99 | locale_message=GetLocaleMessage(message); |
| 100 | if (locale_message == message) |
| 101 | locale_message=tag; |
| 102 | if (p == (char *) NULL) |
| 103 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 104 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 105 | (100L*offset/(extent-1))); |
| 106 | else |
| 107 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
| 108 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 109 | (100L*offset/(extent-1))); |
| 110 | if (offset == (MagickOffsetType) (extent-1)) |
| 111 | (void) FormatLocaleFile(stderr,"\n"); |
| 112 | (void) fflush(stderr); |
| 113 | return(MagickTrue); |
| 114 | } |
| 115 | |
| 116 | /* |
| 117 | ** GetImageCache() will read an image into a image cache if not already |
| 118 | ** present then return the image that is in the cache under that filename. |
| 119 | */ |
| 120 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 121 | ExceptionInfo *exception) |
| 122 | { |
| 123 | char |
| 124 | key[MaxTextExtent]; |
| 125 | |
| 126 | ExceptionInfo |
| 127 | *sans_exception; |
| 128 | |
| 129 | Image |
| 130 | *image; |
| 131 | |
| 132 | ImageInfo |
| 133 | *read_info; |
| 134 | |
| 135 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
| 136 | sans_exception=AcquireExceptionInfo(); |
| 137 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 138 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 139 | if (image != (Image *) NULL) |
| 140 | return(image); |
| 141 | read_info=CloneImageInfo(image_info); |
| 142 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 143 | image=ReadImage(read_info,exception); |
| 144 | read_info=DestroyImageInfo(read_info); |
| 145 | if (image != (Image *) NULL) |
| 146 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 147 | return(image); |
| 148 | } |
| 149 | |
| 150 | /* |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 151 | SparseColorOption() parse the complex -sparse-color argument into an |
| 152 | an array of floating point values than call SparseColorImage(). |
| 153 | Argument is a complex mix of floating-point pixel coodinates, and color |
| 154 | specifications (or direct floating point numbers). The number of floats |
| 155 | needed to represent a color varies depending on teh current channel |
| 156 | setting. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 157 | |
| 158 | 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] | 159 | */ |
| 160 | static Image *SparseColorOption(const Image *image, |
| 161 | const SparseColorMethod method,const char *arguments, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 162 | ExceptionInfo *exception) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 163 | { |
| 164 | char |
| 165 | token[MaxTextExtent]; |
| 166 | |
| 167 | const char |
| 168 | *p; |
| 169 | |
| 170 | double |
| 171 | *sparse_arguments; |
| 172 | |
| 173 | Image |
| 174 | *sparse_image; |
| 175 | |
| 176 | PixelInfo |
| 177 | color; |
| 178 | |
| 179 | MagickBooleanType |
| 180 | error; |
| 181 | |
| 182 | register size_t |
| 183 | x; |
| 184 | |
| 185 | size_t |
| 186 | number_arguments, |
| 187 | number_colors; |
| 188 | |
| 189 | assert(image != (Image *) NULL); |
| 190 | assert(image->signature == MagickSignature); |
| 191 | if (image->debug != MagickFalse) |
| 192 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 193 | assert(exception != (ExceptionInfo *) NULL); |
| 194 | assert(exception->signature == MagickSignature); |
| 195 | /* |
| 196 | Limit channels according to image - and add up number of color channel. |
| 197 | */ |
| 198 | number_colors=0; |
| 199 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 200 | number_colors++; |
| 201 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 202 | number_colors++; |
| 203 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 204 | number_colors++; |
| 205 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 206 | (image->colorspace == CMYKColorspace)) |
| 207 | number_colors++; |
| 208 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
| 209 | (image->matte != MagickFalse)) |
| 210 | number_colors++; |
| 211 | |
| 212 | /* |
| 213 | Read string, to determine number of arguments needed, |
| 214 | */ |
| 215 | p=arguments; |
| 216 | x=0; |
| 217 | while( *p != '\0' ) |
| 218 | { |
| 219 | GetMagickToken(p,&p,token); |
| 220 | if ( token[0] == ',' ) continue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 221 | if ( isalpha((int) token[0]) || token[0] == '#' ) |
| 222 | x += number_colors; /* color argument found */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 223 | else { |
| 224 | x++; /* floating point argument */ |
| 225 | } |
| 226 | } |
| 227 | error=MagickTrue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 228 | /* control points and color values */ |
| 229 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 230 | number_arguments=x; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 231 | if ( error ) { |
| 232 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 233 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 234 | "Invalid number of Arguments"); |
| 235 | return( (Image *)NULL); |
| 236 | } |
| 237 | |
| 238 | /* Allocate and fill in the floating point arguments */ |
| 239 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 240 | sizeof(*sparse_arguments)); |
| 241 | if (sparse_arguments == (double *) NULL) { |
| 242 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 243 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 244 | return( (Image *)NULL); |
| 245 | } |
| 246 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 247 | sizeof(*sparse_arguments)); |
| 248 | p=arguments; |
| 249 | x=0; |
| 250 | while( *p != '\0' && x < number_arguments ) { |
| 251 | /* X coordinate */ |
| 252 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 253 | if ( token[0] == '\0' ) break; |
| 254 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 255 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 256 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 257 | "Color found, instead of X-coord"); |
| 258 | error = MagickTrue; |
| 259 | break; |
| 260 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 261 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 262 | /* Y coordinate */ |
| 263 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 264 | if ( token[0] == '\0' ) break; |
| 265 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 266 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 267 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 268 | "Color found, instead of Y-coord"); |
| 269 | error = MagickTrue; |
| 270 | break; |
| 271 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 272 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 273 | /* color name or function given in string argument */ |
| 274 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 275 | if ( token[0] == '\0' ) break; |
| 276 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 277 | /* Color string given */ |
| 278 | (void) QueryColorCompliance(token,AllCompliance,&color, |
| 279 | exception); |
| 280 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 281 | sparse_arguments[x++] = QuantumScale*color.red; |
| 282 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 283 | sparse_arguments[x++] = QuantumScale*color.green; |
| 284 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 285 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 286 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 287 | (image->colorspace == CMYKColorspace)) |
| 288 | sparse_arguments[x++] = QuantumScale*color.black; |
| 289 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
| 290 | (image->matte != MagickFalse)) |
| 291 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 292 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 293 | else { |
| 294 | /* Colors given as a set of floating point values - experimental */ |
| 295 | /* NB: token contains the first floating point value to use! */ |
| 296 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 297 | { |
| 298 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 299 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 300 | break; |
| 301 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 302 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 303 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 304 | if ((GetPixelGreenTraits(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 */ |
| 311 | } |
| 312 | if ((GetPixelBlueTraits(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 (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 321 | (image->colorspace == CMYKColorspace)) |
| 322 | { |
| 323 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 324 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 325 | break; |
| 326 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 327 | token[0] = ','; /* used this token - get another */ |
| 328 | } |
| 329 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
| 330 | (image->matte != MagickFalse)) |
| 331 | { |
| 332 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 333 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 334 | break; |
| 335 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 336 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 337 | } |
| 338 | } |
| 339 | } |
| 340 | if ( number_arguments != x && !error ) { |
| 341 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 342 | "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 343 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 344 | return( (Image *)NULL); |
| 345 | } |
| 346 | if ( error ) |
| 347 | return( (Image *)NULL); |
| 348 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 349 | /* Call the Sparse Color Interpolation function with the parsed arguments */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 350 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 351 | exception); |
| 352 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 353 | return( sparse_image ); |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 358 | % % |
| 359 | % % |
| 360 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 361 | + A c q u i r e W a n d C L I % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 362 | % % |
| 363 | % % |
| 364 | % % |
| 365 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 366 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 367 | % AcquireMagickCLI() creates a new CLI wand (an expanded form of Magick |
| 368 | % Wand). The given image_info and exception is included as is if provided. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 369 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 370 | % Use DestroyMagickCLI() to dispose of the CLI wand when it is no longer |
| 371 | % needed. |
| 372 | % |
| 373 | % The format of the NewMagickWand method is: |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 374 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 375 | % MagickCLI *AcquireMagickCLI(ImageInfo *image_info, |
| 376 | % ExceptionInfo *exception) |
| 377 | % |
| 378 | */ |
| 379 | WandExport MagickCLI *AcquireMagickCLI(ImageInfo *image_info, |
| 380 | ExceptionInfo *exception) |
| 381 | { |
| 382 | MagickCLI |
| 383 | *cli_wand; |
| 384 | |
| 385 | /* precaution - as per NewMagickWand() */ |
| 386 | { |
| 387 | size_t depth = MAGICKCORE_QUANTUM_DEPTH; |
| 388 | const char *quantum = GetMagickQuantumDepth(&depth); |
| 389 | if (depth != MAGICKCORE_QUANTUM_DEPTH) |
| 390 | ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); |
| 391 | } |
| 392 | |
| 393 | /* allocate memory for MgaickCLI */ |
| 394 | cli_wand=(MagickCLI *) AcquireMagickMemory(sizeof(*cli_wand)); |
| 395 | if (cli_wand == (MagickCLI *) NULL) |
| 396 | { |
| 397 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 398 | GetExceptionMessage(errno)); |
| 399 | return((MagickCLI *)NULL); |
| 400 | } |
| 401 | |
| 402 | /* Initialize Wand Part of MagickCLI |
| 403 | FUTURE: this is a repeat of code from NewMagickWand() |
| 404 | However some parts may be given fro man external source! |
| 405 | */ |
| 406 | cli_wand->wand.id=AcquireWandId(); |
| 407 | (void) FormatLocaleString(cli_wand->wand.name,MaxTextExtent, |
| 408 | "%s-%.20g","MagickWandCLI", (double) cli_wand->wand.id); |
| 409 | cli_wand->wand.images=NewImageList(); |
| 410 | if ( image_info == (ImageInfo *)NULL) |
| 411 | cli_wand->wand.image_info=AcquireImageInfo(); |
| 412 | else |
| 413 | cli_wand->wand.image_info=image_info; |
| 414 | if ( exception == (ExceptionInfo *)NULL) |
| 415 | cli_wand->wand.exception=AcquireExceptionInfo(); |
| 416 | else |
| 417 | cli_wand->wand.exception=exception; |
| 418 | cli_wand->wand.debug=IsEventLogging(); |
| 419 | cli_wand->wand.signature=WandSignature; |
| 420 | |
| 421 | /* Initialize CLI Part of MagickCLI */ |
| 422 | cli_wand->draw_info=CloneDrawInfo(cli_wand->wand.image_info,(DrawInfo *) NULL); |
| 423 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 424 | cli_wand->image_list_stack=(Stack *)NULL; |
| 425 | cli_wand->image_info_stack=(Stack *)NULL; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 426 | cli_wand->location="'%s' at unknown location"; |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame^] | 427 | cli_wand->filename=cli_wand->wand.name; |
anthony | 1cdc5b7 | 2012-03-03 02:31:18 +0000 | [diff] [blame] | 428 | cli_wand->line=0; |
| 429 | cli_wand->column=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 430 | cli_wand->signature=WandSignature; |
| 431 | |
| 432 | if (cli_wand->wand.debug != MagickFalse) |
| 433 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 434 | return(cli_wand); |
| 435 | } |
| 436 | |
| 437 | /* |
| 438 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 439 | % % |
| 440 | % % |
| 441 | % % |
| 442 | + D e s t r o y W a n d C L I % |
| 443 | % % |
| 444 | % % |
| 445 | % % |
| 446 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 447 | % |
| 448 | % DestroyMagickCLI() destorys everything in a CLI wand, including image_info |
| 449 | % and any exceptions, if still present in the wand. |
| 450 | % |
| 451 | % The format of the NewMagickWand method is: |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 452 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 453 | % MagickWand *DestroyMagickCLI() |
| 454 | % Exception *exception) |
| 455 | % |
| 456 | */ |
| 457 | WandExport MagickCLI *DestroyMagickCLI(MagickCLI *cli_wand) |
| 458 | { |
| 459 | Stack |
| 460 | *node; |
| 461 | |
| 462 | assert(cli_wand != (MagickCLI *) NULL); |
| 463 | assert(cli_wand->signature == WandSignature); |
| 464 | assert(cli_wand->wand.signature == WandSignature); |
| 465 | if (cli_wand->wand.debug != MagickFalse) |
| 466 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 467 | |
| 468 | /* Destroy CLI part of MagickCLI */ |
| 469 | if (cli_wand->draw_info != (DrawInfo *) NULL ) |
| 470 | cli_wand->draw_info=DestroyDrawInfo(cli_wand->draw_info); |
| 471 | if (cli_wand->quantize_info != (QuantizeInfo *) NULL ) |
| 472 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 473 | while(cli_wand->image_list_stack != (Stack *)NULL) |
| 474 | { |
| 475 | node=cli_wand->image_list_stack; |
| 476 | cli_wand->image_list_stack=node->next; |
| 477 | (void) DestroyImageList((Image *)node->data); |
| 478 | (void) RelinquishMagickMemory(node); |
| 479 | } |
| 480 | while(cli_wand->image_info_stack != (Stack *)NULL) |
| 481 | { |
| 482 | node=cli_wand->image_info_stack; |
| 483 | cli_wand->image_info_stack=node->next; |
| 484 | (void) DestroyImageInfo((ImageInfo *)node->data); |
| 485 | (void) RelinquishMagickMemory(node); |
| 486 | } |
| 487 | cli_wand->signature=(~WandSignature); |
| 488 | |
| 489 | /* Destroy Wand part MagickCLI */ |
| 490 | cli_wand->wand.images=DestroyImageList(cli_wand->wand.images); |
| 491 | if (cli_wand->wand.image_info != (ImageInfo *) NULL ) |
| 492 | cli_wand->wand.image_info=DestroyImageInfo(cli_wand->wand.image_info); |
| 493 | if (cli_wand->wand.exception != (ExceptionInfo *) NULL ) |
| 494 | cli_wand->wand.exception=DestroyExceptionInfo(cli_wand->wand.exception); |
| 495 | RelinquishWandId(cli_wand->wand.id); |
| 496 | cli_wand->wand.signature=(~WandSignature); |
| 497 | |
| 498 | return((MagickCLI *)NULL); |
| 499 | } |
| 500 | |
| 501 | /* |
| 502 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 503 | % % |
| 504 | % % |
| 505 | % % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 506 | + C L I C a t c h E x c e p t i o n % |
| 507 | % % |
| 508 | % % |
| 509 | % % |
| 510 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 511 | % |
| 512 | % CLICatchException() will report exceptions, either just non-fatal warnings |
| 513 | % only, or all errors, according to 'all_execeptions' boolean argument. |
| 514 | % |
| 515 | % The function returns true is errors are fatal, in which case the caller |
| 516 | % should abort and re-call with an 'all_exceptions' argument of true before |
| 517 | % quitting. |
| 518 | % |
| 519 | % The cut-off level between fatal and non-fatal may be controlled by options |
| 520 | % (FUTURE), but defaults to 'Error' exceptions. |
| 521 | % |
| 522 | % The format of the CLICatchException method is: |
| 523 | % |
| 524 | % MagickBooleanType CLICatchException(MagickCLI *cli_wand, |
| 525 | % const MagickBooleanType all_exceptions ); |
| 526 | % |
| 527 | */ |
| 528 | WandExport MagickBooleanType CLICatchException(MagickCLI *cli_wand, |
| 529 | const MagickBooleanType all_exceptions ) |
| 530 | { |
| 531 | MagickBooleanType |
| 532 | status; |
| 533 | assert(cli_wand != (MagickCLI *) NULL); |
| 534 | assert(cli_wand->signature == WandSignature); |
| 535 | assert(cli_wand->wand.signature == WandSignature); |
| 536 | if (cli_wand->wand.debug != MagickFalse) |
| 537 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 538 | |
| 539 | // FUTURE: '-regard_warning' should make this more sensitive. |
| 540 | // Note pipelined options may like more control over this level |
| 541 | |
| 542 | status = MagickFalse; |
| 543 | if (cli_wand->wand.exception->severity > ErrorException) |
| 544 | status = MagickTrue; |
| 545 | |
| 546 | if ( status == MagickFalse || all_exceptions != MagickFalse ) |
| 547 | CatchException(cli_wand->wand.exception); /* output and clear exceptions */ |
| 548 | |
| 549 | return(status); |
| 550 | } |
| 551 | |
| 552 | /* |
| 553 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 554 | % % |
| 555 | % % |
| 556 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 557 | + C L I S e t t i n g O p t i o n I n f o % |
| 558 | % % |
| 559 | % % |
| 560 | % % |
| 561 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 562 | % |
| 563 | % CLISettingOptionInfo() applies a single settings option into a CLI wand |
| 564 | % holding the image_info, draw_info, quantize_info structures that will be |
| 565 | % used when processing the images. |
| 566 | % |
| 567 | % These options do no require images to be present in the CLI wand for them |
| 568 | % to be able to be set, in which case they will generally be applied to image |
| 569 | % that are read in later |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 570 | % |
| 571 | % Options handled by this function are listed in CommandOptions[] of |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 572 | % "option.c" that is one of "SettingOptionFlags" option flags. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 573 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 574 | % The format of the CLISettingOptionInfo method is: |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 575 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 576 | % void CLISettingOptionInfo(MagickCLI *cli_wand, |
| 577 | % const char *option, const char *arg) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 578 | % |
| 579 | % A description of each parameter follows: |
| 580 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 581 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 582 | % |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 583 | % o option: The option string to be set |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 584 | % |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 585 | % o arg: The single argument used to set this option. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 586 | % |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 587 | % Example usage... |
| 588 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 589 | % CLISettingOptionInfo(cli_wand, "-background", "Red"); // set value |
| 590 | % CLISettingOptionInfo(cli_wand, "-adjoin", NULL); // set boolean |
| 591 | % CLISettingOptionInfo(cli_wand, "+adjoin", NULL); // unset |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 592 | % |
| 593 | % Or for handling command line arguments EG: +/-option ["arg"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 594 | % |
| 595 | % argc,argv |
| 596 | % i=index in argv |
| 597 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 598 | % option_info = GetCommandOptionInfo(argv[i]); |
| 599 | % count=option_info->type; |
| 600 | % option_type=option_info->flags; |
| 601 | % |
| 602 | % if ( (option_type & SettingOperatorOptionFlags) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 603 | % CLISettingOptionInfo(cli_wand, argv[i], |
| 604 | % (count>0) ? argv[i+1] : (char *)NULL); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 605 | % i += count+1; |
| 606 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 607 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 608 | WandExport void CLISettingOptionInfo(MagickCLI *cli_wand, |
| 609 | const char *option,const char *arg) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 610 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 611 | assert(cli_wand != (MagickCLI *) NULL); |
| 612 | assert(cli_wand->signature == WandSignature); |
| 613 | assert(cli_wand->wand.signature == WandSignature); |
| 614 | if (cli_wand->wand.debug != MagickFalse) |
| 615 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 616 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 617 | #define image_info (cli_wand->wand.image_info) |
| 618 | #define exception (cli_wand->wand.exception) |
| 619 | #define draw_info (cli_wand->draw_info) |
| 620 | #define quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 621 | #define IfSetOption (*option=='-') |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 622 | #define ArgOption(def) (IfSetOption?arg:(const char *)(def)) |
| 623 | #define ArgBoolean (IfSetOption?MagickTrue:MagickFalse) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 624 | #define ArgBooleanNot (IfSetOption?MagickFalse:MagickTrue) |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 625 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 626 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 627 | { |
| 628 | case 'a': |
| 629 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 630 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 631 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 632 | image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 633 | break; |
| 634 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 635 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 636 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 637 | /* DEPRECIATED: draw_info setting only: for -draw and -transform */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 638 | if (IfSetOption) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 639 | (void) ParseAffineGeometry(arg,&draw_info->affine,exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 640 | else |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 641 | GetAffineMatrix(&draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 642 | break; |
| 643 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 644 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 645 | { |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 646 | image_info->antialias = |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 647 | draw_info->stroke_antialias = |
| 648 | draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 649 | break; |
| 650 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 651 | if (LocaleCompare("attenuate",option+1) == 0) |
| 652 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 653 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 654 | break; |
| 655 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 656 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 657 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 658 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 659 | break; |
| 660 | } |
| 661 | break; |
| 662 | } |
| 663 | case 'b': |
| 664 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 665 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 666 | { |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 667 | /* FUTURE: both image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 668 | image_info only used directly for generating new images. |
| 669 | SyncImageSettings() used to set per-image attribute. |
| 670 | |
| 671 | FUTURE: if image_info->background_color is not set then |
| 672 | we should fall back to image |
| 673 | Note that +background, means fall-back to image background |
| 674 | and only if not set fall back to BackgroundColor const. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 675 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 676 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 677 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, |
| 678 | &image_info->background_color,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 679 | break; |
| 680 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 681 | if (LocaleCompare("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 682 | { |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 683 | /* FUTURE: bias OBSOLETED, replaced by "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 684 | as it is actually rarely used except in direct convolve operations |
| 685 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 686 | |
| 687 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 688 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 689 | (void) SetImageOption(image_info,option+1,ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 690 | break; |
| 691 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 692 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 693 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 694 | /* Used as a image chromaticity setting |
| 695 | SyncImageSettings() used to set per-image attribute. |
| 696 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 697 | (void) SetImageOption(image_info,option+1, |
| 698 | IfSetOption ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 699 | break; |
| 700 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 701 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 702 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 703 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 704 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 705 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 706 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 707 | (void) SetImageOption(image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 708 | break; |
| 709 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 710 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 711 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 712 | /* FUTURE: both image_info attribute & ImageOption in use! |
| 713 | SyncImageSettings() used to set per-image attribute. |
| 714 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 715 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 716 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 717 | (void) SetImageOption(image_info,option+1,arg); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 718 | (void) QueryColorCompliance(arg,AllCompliance, |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 719 | &image_info->border_color,exception); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 720 | (void) QueryColorCompliance(arg,AllCompliance, |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 721 | &draw_info->border_color,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 722 | break; |
| 723 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 724 | (void) DeleteImageOption(image_info,option+1); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 725 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
| 726 | &image_info->border_color,exception); |
| 727 | (void) QueryColorCompliance(BorderColor,AllCompliance, |
| 728 | &draw_info->border_color,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 729 | break; |
| 730 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 731 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 732 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 733 | /* DEPRECIATED - now "undercolor" */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 734 | CLISettingOptionInfo(cli_wand,"undercolor",arg); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 735 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 736 | } |
| 737 | break; |
| 738 | } |
| 739 | case 'c': |
| 740 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 741 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 742 | { |
| 743 | MagickSizeType |
| 744 | limit; |
| 745 | |
| 746 | limit=MagickResourceInfinity; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 747 | if (LocaleCompare("unlimited",arg) != 0) |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 748 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 749 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 750 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 751 | break; |
| 752 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 753 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 754 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 755 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 756 | break; |
| 757 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 758 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 759 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 760 | /* FUTURE: -channel mask {vaules} |
| 761 | This is applied to images in SimpleImageOperator!!! |
| 762 | Move it to SyncImageSettings() - or alternative |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 763 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 764 | image_info->channel=(ChannelType) ( |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 765 | IfSetOption ? ParseChannelOption(arg) : DefaultChannels ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 766 | break; |
| 767 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 768 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 769 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 770 | /* Setting used for new images via AquireImage() |
| 771 | But also used as a SimpleImageOperator |
| 772 | Undefined colorspace means don't modify images on |
| 773 | read or as a operation */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 774 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 775 | MagickColorspaceOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 776 | break; |
| 777 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 778 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 779 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 780 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 781 | break; |
| 782 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 783 | if (LocaleCompare("compose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 784 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 785 | /* FUTURE: image_info should be used, |
| 786 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 787 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 788 | This setting should NOT be used to set image 'compose' |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 789 | "-layer" operators shoud use image_info if defined otherwise |
| 790 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 791 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 792 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 793 | image_info->compose=(CompositeOperator) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 794 | MagickComposeOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 795 | break; |
| 796 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 797 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 798 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 799 | /* FUTURE: What should be used? image_info or ImageOption ??? |
| 800 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 801 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 802 | |
| 803 | The coders appears to use image_info, not Image_Option |
| 804 | however the image attribute (for save) is set from the |
| 805 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 806 | |
| 807 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 808 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 809 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 810 | image_info->compression=(CompressionType) ParseCommandOption( |
| 811 | MagickCompressOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 812 | break; |
| 813 | } |
| 814 | break; |
| 815 | } |
| 816 | case 'd': |
| 817 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 818 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 819 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 820 | /* SyncImageSettings() used to set per-image attribute. */ |
| 821 | (void) SetLogEventMask(ArgOption("none")); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 822 | image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 823 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 824 | break; |
| 825 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 826 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 827 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 828 | /* DefineImageOption() equals SetImageOption() but with '=' |
| 829 | It does not however set individual image options. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 830 | "-set" will set individual image options as well! |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 831 | */ |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 832 | if (LocaleNCompare(arg,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 833 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 834 | if (IfSetOption) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 835 | (void) DefineImageRegistry(StringRegistryType,arg+9,exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 836 | else |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 837 | (void) DeleteImageRegistry(arg+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 838 | break; |
| 839 | } |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 840 | if (IfSetOption) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 841 | (void) DefineImageOption(image_info,arg); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 842 | else |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 843 | (void) DeleteImageOption(image_info,arg); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 844 | break; |
| 845 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 846 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 847 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 848 | /* Only used for new images via AcquireImage() |
| 849 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 850 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 851 | (void) SetImageOption(image_info,option+1,ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 852 | break; |
| 853 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 854 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 855 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 856 | /* FUTURE: strings used in image_info attr and draw_info! |
| 857 | Basically as density can be in a XxY form! |
| 858 | |
| 859 | SyncImageSettings() used to set per-image attribute. |
| 860 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 861 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 862 | (void) CloneString(&image_info->density,ArgOption(NULL)); |
| 863 | (void) CloneString(&draw_info->density,image_info->density); |
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("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 867 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 868 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 869 | SyncImageSettings() used to set per-image attribute. |
| 870 | */ |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 871 | image_info->depth=IfSetOption?StringToUnsignedLong(arg) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 872 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 873 | break; |
| 874 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 875 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 876 | { |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 877 | /* Image Option is only used to set draw_info */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 878 | (void) SetImageOption(image_info,option+1,ArgOption("undefined")); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 879 | draw_info->direction=(DirectionType) ParseCommandOption( |
| 880 | MagickDirectionOptions,MagickFalse, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 881 | ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 882 | break; |
| 883 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 884 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 885 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 886 | (void) CloneString(&image_info->server_name,ArgOption(NULL)); |
| 887 | (void) CloneString(&draw_info->server_name,image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 888 | break; |
| 889 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 890 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 891 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 892 | /* only used in setting new images */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 893 | (void) SetImageOption(image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 894 | break; |
| 895 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 896 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 897 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 898 | /* image_info attr (on/off), quantize_info attr (on/off) |
| 899 | but also ImageInfo and quantize_info method! |
| 900 | FUTURE: merge the duality of the dithering options |
| 901 | */ |
| 902 | image_info->dither = quantize_info->dither = ArgBoolean; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 903 | (void) SetImageOption(image_info,option+1,ArgOption("none")); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 904 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 905 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 906 | if (quantize_info->dither_method == NoDitherMethod) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 907 | image_info->dither = quantize_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 908 | break; |
| 909 | } |
| 910 | break; |
| 911 | } |
| 912 | case 'e': |
| 913 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 914 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 915 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 916 | (void) CloneString(&draw_info->encoding,ArgOption("undefined")); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 917 | (void) SetImageOption(image_info,option+1,draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 918 | break; |
| 919 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 920 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 921 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 922 | /* Both image_info attr and ImageInfo */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 923 | (void) SetImageOption(image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 924 | image_info->endian=(EndianType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 925 | MagickEndianOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 926 | break; |
| 927 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 928 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 929 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 930 | (void) CloneString(&image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 931 | break; |
| 932 | } |
| 933 | break; |
| 934 | } |
| 935 | case 'f': |
| 936 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 937 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 938 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 939 | (void) CloneString(&draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 940 | break; |
| 941 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 942 | if (LocaleCompare("fill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 943 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 944 | /* Set "fill" OR "fill-pattern" in draw_info |
| 945 | The original fill color is preserved if a fill-pattern is given. |
| 946 | That way it does not effect other operations that directly using |
| 947 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 948 | */ |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 949 | const char |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 950 | *value; |
| 951 | |
| 952 | MagickBooleanType |
| 953 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 954 | |
| 955 | ExceptionInfo |
| 956 | *sans; |
| 957 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 958 | PixelInfo |
| 959 | color; |
| 960 | |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 961 | value = ArgOption("none"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 962 | (void) SetImageOption(image_info,option+1,value); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 963 | if (draw_info->fill_pattern != (Image *) NULL) |
| 964 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 965 | |
| 966 | /* is it a color or a image? -- ignore exceptions */ |
| 967 | sans=AcquireExceptionInfo(); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 968 | status=QueryColorCompliance(value,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 969 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 970 | |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 971 | if (status == MagickFalse) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 972 | draw_info->fill_pattern=GetImageCache(image_info,value,exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 973 | else |
| 974 | draw_info->fill=color; |
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("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 978 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 979 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 980 | (void) SetImageOption(image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 981 | break; |
| 982 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 983 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 984 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 985 | (void) CloneString(&draw_info->font,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 986 | (void) CloneString(&image_info->font,draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 987 | break; |
| 988 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 989 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 990 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 991 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 992 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 993 | register const char |
| 994 | *q; |
| 995 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 996 | for (q=strchr(arg,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 997 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
| 998 | image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 999 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1000 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1001 | break; |
| 1002 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1003 | if (LocaleCompare("fuzz",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1004 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1005 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1006 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1007 | SyncImageSettings() used to set per-image attribute. |
| 1008 | |
| 1009 | Can't find anything else using image_info->fuzz directly! |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 1010 | */ |
| 1011 | if (IfSetOption) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 1012 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 1013 | image_info->fuzz=StringToDoubleInterval(arg,(double) |
| 1014 | QuantumRange+1.0); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1015 | (void) SetImageOption(image_info,option+1,arg); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 1016 | break; |
| 1017 | } |
| 1018 | image_info->fuzz=0.0; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1019 | (void) SetImageOption(image_info,option+1,"0"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1020 | break; |
| 1021 | } |
| 1022 | break; |
| 1023 | } |
| 1024 | case 'g': |
| 1025 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1026 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1027 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1028 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1029 | (void) SetImageOption(image_info,option+1,ArgOption("none")); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 1030 | draw_info->gravity=(GravityType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1031 | MagickGravityOptions,MagickFalse,ArgOption("none")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1032 | break; |
| 1033 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1034 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1035 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1036 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1037 | SyncImageSettings() used to set per-image attribute. |
| 1038 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1039 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1040 | (void) SetImageOption(image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1041 | break; |
| 1042 | } |
| 1043 | break; |
| 1044 | } |
| 1045 | case 'i': |
| 1046 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1047 | if (LocaleCompare("intent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1048 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1049 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1050 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1051 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1052 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1053 | (void) SetImageOption(image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1054 | break; |
| 1055 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1056 | if (LocaleCompare("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1057 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1058 | /* image_info is directly used by coders (so why an image setting?) |
| 1059 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1060 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1061 | (void) SetImageOption(image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1062 | image_info->interlace=(InterlaceType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1063 | MagickInterlaceOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1064 | break; |
| 1065 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1066 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1067 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1068 | (void) SetImageOption(image_info,option+1, ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1069 | draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
| 1070 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1071 | break; |
| 1072 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1073 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1074 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1075 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1076 | (void) SetImageOption(image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1077 | break; |
| 1078 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1079 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1080 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1081 | (void) SetImageOption(image_info,option+1, ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1082 | draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1083 | break; |
| 1084 | } |
| 1085 | break; |
| 1086 | } |
| 1087 | case 'k': |
| 1088 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1089 | if (LocaleCompare("kerning",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1090 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1091 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1092 | draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1093 | break; |
| 1094 | } |
| 1095 | break; |
| 1096 | } |
| 1097 | case 'l': |
| 1098 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1099 | if (LocaleCompare("label",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 | /* only used for new images - not in SyncImageOptions() */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1102 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1103 | break; |
| 1104 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1105 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1106 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1107 | if (IfSetOption) |
| 1108 | (void) SetLogFormat(arg); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1109 | break; |
| 1110 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1111 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1112 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1113 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1114 | (void) SetImageOption(image_info,option+1,ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1115 | break; |
| 1116 | } |
| 1117 | break; |
| 1118 | } |
| 1119 | case 'm': |
| 1120 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1121 | if (LocaleCompare("mattecolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1122 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1123 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1124 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1125 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, |
| 1126 | &image_info->matte_color,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1127 | break; |
| 1128 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1129 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1130 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1131 | (void) SetImageInfoProgressMonitor(image_info, IfSetOption? |
| 1132 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1133 | break; |
| 1134 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1135 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1136 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1137 | /* Setting (for some input coders) |
| 1138 | But also a special 'type' operator |
| 1139 | */ |
| 1140 | image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1141 | break; |
| 1142 | } |
| 1143 | break; |
| 1144 | } |
| 1145 | case 'o': |
| 1146 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1147 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1148 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1149 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1150 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1151 | FUTURE: make set meta-data operator instead. |
| 1152 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1153 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1154 | (void) SetImageOption(image_info,option+1, ArgOption(NULL)); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1155 | image_info->orientation=(InterlaceType) ParseCommandOption( |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1156 | MagickOrientationOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1157 | break; |
| 1158 | } |
| 1159 | } |
| 1160 | case 'p': |
| 1161 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1162 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1163 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1164 | /* Only used for new images and image generators |
| 1165 | SyncImageSettings() used to set per-image attribute. ????? |
| 1166 | That last is WRONG!!!! |
| 1167 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1168 | char |
| 1169 | *canonical_page, |
| 1170 | page[MaxTextExtent]; |
| 1171 | |
| 1172 | const char |
| 1173 | *image_option; |
| 1174 | |
| 1175 | MagickStatusType |
| 1176 | flags; |
| 1177 | |
| 1178 | RectangleInfo |
| 1179 | geometry; |
| 1180 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1181 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1182 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1183 | (void) DeleteImageOption(image_info,option+1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1184 | (void) CloneString(&image_info->page,(char *) NULL); |
| 1185 | break; |
| 1186 | } |
| 1187 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 1188 | image_option=GetImageOption(image_info,"page"); |
| 1189 | if (image_option != (const char *) NULL) |
| 1190 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1191 | canonical_page=GetPageGeometry(arg); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1192 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1193 | canonical_page=DestroyString(canonical_page); |
| 1194 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1195 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1196 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1197 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1198 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1199 | (long) geometry.x,(long) geometry.y); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1200 | (void) SetImageOption(image_info,option+1,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1201 | (void) CloneString(&image_info->page,page); |
| 1202 | break; |
| 1203 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1204 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1205 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1206 | image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1207 | break; |
| 1208 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1209 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1210 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1211 | image_info->pointsize=draw_info->pointsize= |
| 1212 | StringToDouble(ArgOption("12"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1213 | break; |
| 1214 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1215 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1216 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1217 | (void) SetMagickPrecision(StringToInteger(ArgOption("-1"))); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1218 | break; |
| 1219 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1220 | /* FUTURE: Only the 'preview' coder appears to use this |
| 1221 | * Depreciate the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1222 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1223 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1224 | image_info->preview_type=UndefinedPreview; |
| 1225 | if (IfSetOption) |
| 1226 | image_info->preview_type=(PreviewType) ParseCommandOption( |
| 1227 | MagickPreviewOptions,MagickFalse,arg); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1228 | break; |
| 1229 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1230 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1231 | break; |
| 1232 | } |
| 1233 | case 'q': |
| 1234 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1235 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1236 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1237 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
| 1238 | image_info->quality=UNDEFINED_COMPRESSION_QUALITY; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1239 | if (IfSetOption) |
| 1240 | image_info->quality=StringToUnsignedLong(arg); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1241 | break; |
| 1242 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1243 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1244 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1245 | /* Just a set direct in quantize_info */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1246 | quantize_info->colorspace=UndefinedColorspace; |
| 1247 | if (IfSetOption) |
| 1248 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1249 | MagickColorspaceOptions,MagickFalse,arg); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1250 | break; |
| 1251 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1252 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1253 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1254 | /* FUTURE: if two -quiet is performed you can not do +quiet! */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1255 | static WarningHandler |
| 1256 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1257 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1258 | WarningHandler |
| 1259 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1260 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1261 | if ( tmp != (WarningHandler) NULL) |
| 1262 | warning_handler = tmp; /* remember the old handler */ |
| 1263 | if (!IfSetOption) /* set the old handler */ |
| 1264 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1265 | break; |
| 1266 | } |
| 1267 | break; |
| 1268 | } |
| 1269 | case 'r': |
| 1270 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1271 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1272 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1273 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1274 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1275 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1276 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1277 | (void) SetImageOption(image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1278 | break; |
| 1279 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1280 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1281 | { |
| 1282 | /* draw_info only setting */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1283 | draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1284 | break; |
| 1285 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1286 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1287 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1288 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1289 | break; |
| 1290 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1291 | break; |
| 1292 | } |
| 1293 | case 's': |
| 1294 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1295 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1296 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1297 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1298 | (void) CloneString(&image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1299 | break; |
| 1300 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1301 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1302 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1303 | /* SyncImageSettings() used to set per-image attribute. |
| 1304 | What ??? Why ???? |
| 1305 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1306 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1307 | image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1308 | break; |
| 1309 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1310 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1311 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1312 | SeedPseudoRandomGenerator( |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1313 | IfSetOption ? (size_t) StringToUnsignedLong(arg) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1314 | : (size_t) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1315 | break; |
| 1316 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1317 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1318 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1319 | /* FUTURE: string in image_info -- convert to Option ??? |
| 1320 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1321 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1322 | (void) CloneString(&image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1323 | break; |
| 1324 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1325 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1326 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1327 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 1328 | MagickStretchOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1329 | break; |
| 1330 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1331 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1332 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1333 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1334 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1335 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1336 | */ |
| 1337 | const char |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1338 | *value; |
| 1339 | |
| 1340 | MagickBooleanType |
| 1341 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1342 | |
| 1343 | ExceptionInfo |
| 1344 | *sans; |
| 1345 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1346 | PixelInfo |
| 1347 | color; |
| 1348 | |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1349 | value = ArgOption("none"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1350 | (void) SetImageOption(image_info,option+1,value); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1351 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 1352 | draw_info->stroke_pattern=DestroyImage(draw_info->stroke_pattern); |
| 1353 | |
| 1354 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1355 | sans=AcquireExceptionInfo(); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1356 | status=QueryColorCompliance(value,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1357 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1358 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1359 | if (status == MagickFalse) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1360 | draw_info->stroke_pattern=GetImageCache(image_info,value,exception); |
| 1361 | else |
| 1362 | draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1363 | break; |
| 1364 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1365 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1366 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1367 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1368 | draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
| 1369 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1370 | break; |
| 1371 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1372 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1373 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1374 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 1375 | MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1376 | break; |
| 1377 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1378 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1379 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1380 | image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1381 | break; |
| 1382 | } |
| 1383 | break; |
| 1384 | } |
| 1385 | case 't': |
| 1386 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1387 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1388 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1389 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1390 | (void) SetImageOption(image_info,option+1, |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1391 | IfSetOption ? "true" : "false"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1392 | break; |
| 1393 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1394 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1395 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1396 | /* FUTURE: move image_info string to option splay-tree */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1397 | (void) CloneString(&image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1398 | break; |
| 1399 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1400 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1401 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1402 | draw_info->fill_pattern=IfSetOption |
| 1403 | ?GetImageCache(image_info,arg,exception) |
| 1404 | :DestroyImage(draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1405 | break; |
| 1406 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1407 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1408 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1409 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1410 | (void) SetImageOption(image_info,option+1,ArgOption("0")); |
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("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1414 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1415 | /* FUTURE: both image_info attribute & ImageOption in use! |
| 1416 | image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1417 | SyncImageSettings() used to set per-image attribute. |
| 1418 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1419 | Note that +transparent-color, means fall-back to image |
| 1420 | attribute so ImageOption is deleted, not set to a default. |
| 1421 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1422 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1423 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
| 1424 | &image_info->transparent_color,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1425 | break; |
| 1426 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1427 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1428 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1429 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1430 | quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
| 1431 | break; |
| 1432 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1433 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1434 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1435 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1436 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1437 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
| 1438 | MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1439 | break; |
| 1440 | } |
| 1441 | break; |
| 1442 | } |
| 1443 | case 'u': |
| 1444 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1445 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1446 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1447 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1448 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
| 1449 | &draw_info->undercolor,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1450 | break; |
| 1451 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1452 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1453 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1454 | /* SyncImageSettings() used to set per-image attribute. |
| 1455 | Should this effect draw_info X and Y resolution? |
| 1456 | FUTURE: this probably should be part of the density setting |
| 1457 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1458 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1459 | image_info->units=(ResolutionType) ParseCommandOption( |
| 1460 | MagickResolutionOptions,MagickFalse,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1461 | break; |
| 1462 | } |
| 1463 | break; |
| 1464 | } |
| 1465 | case 'v': |
| 1466 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1467 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1468 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1469 | /* FUTURE: Also an image artifact, set in Simple Operators. |
| 1470 | But artifact is only used in verbose output. |
| 1471 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1472 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1473 | image_info->verbose= ArgBoolean; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1474 | image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1475 | break; |
| 1476 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1477 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1478 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1479 | /* FUTURE: Convert from image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1480 | Only used by coder FPX |
| 1481 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1482 | (void) CloneString(&image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1483 | break; |
| 1484 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1485 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1486 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1487 | /* SyncImageSettings() used to set per-image attribute. |
| 1488 | This is VERY deep in the image caching structure. |
| 1489 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1490 | (void) SetImageOption(image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1491 | break; |
| 1492 | } |
| 1493 | break; |
| 1494 | } |
| 1495 | case 'w': |
| 1496 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1497 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1498 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1499 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1500 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1501 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1502 | if (!IfSetOption) |
| 1503 | break; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1504 | draw_info->weight=StringToUnsignedLong(arg); |
| 1505 | if (LocaleCompare(arg,"all") == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1506 | draw_info->weight=0; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1507 | if (LocaleCompare(arg,"bold") == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1508 | draw_info->weight=700; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1509 | if (LocaleCompare(arg,"bolder") == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1510 | if (draw_info->weight <= 800) |
| 1511 | draw_info->weight+=100; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1512 | if (LocaleCompare(arg,"lighter") == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1513 | if (draw_info->weight >= 100) |
| 1514 | draw_info->weight-=100; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1515 | if (LocaleCompare(arg,"normal") == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1516 | draw_info->weight=400; |
| 1517 | break; |
| 1518 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1519 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1520 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1521 | /* Used as a image chromaticity setting |
| 1522 | SyncImageSettings() used to set per-image attribute. |
| 1523 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1524 | (void) SetImageOption(image_info,option+1,ArgOption("0.0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1525 | break; |
| 1526 | } |
| 1527 | break; |
| 1528 | } |
| 1529 | default: |
| 1530 | break; |
| 1531 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1532 | #undef image_info |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1533 | #undef exception |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1534 | #undef draw_info |
| 1535 | #undef quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1536 | #undef IfSetOption |
| 1537 | #undef ArgOption |
| 1538 | #undef ArgBoolean |
| 1539 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1540 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1541 | } |
| 1542 | |
| 1543 | /* |
| 1544 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1545 | % % |
| 1546 | % % |
| 1547 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1548 | + 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] | 1549 | % % |
| 1550 | % % |
| 1551 | % % |
| 1552 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1553 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1554 | % WandSimpleOperatorImages() applys one simple image operation given to all |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1555 | % the images in the CLI wand, with the settings that was previously saved in |
| 1556 | % the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1557 | % |
| 1558 | % 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] | 1559 | % extra settings that were already saved in the wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1560 | % |
anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1561 | % The format of the WandSimpleOperatorImage method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1562 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1563 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1564 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1565 | % |
| 1566 | % A description of each parameter follows: |
| 1567 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1568 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1569 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1570 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1571 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1572 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1573 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1574 | % Any problems will be added to the 'exception' entry of the given wand. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1575 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1576 | % Example usage... |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1577 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1578 | % CLISimpleOperatorImages(cli_wand, "-crop","100x100+20+30",NULL); |
| 1579 | % CLISimpleOperatorImages(cli_wand, "+repage",NULL,NULL); |
| 1580 | % CLISimpleOperatorImages(cli_wand, "+distort","SRT","45"); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1581 | % |
| 1582 | % Or for handling command line arguments EG: +/-option ["arg"] |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1583 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1584 | % cli_wand |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1585 | % argc,argv |
| 1586 | % i=index in argv |
| 1587 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 1588 | % option_info = GetCommandOptionInfo(argv[i]); |
| 1589 | % count=option_info->type; |
| 1590 | % option_type=option_info->flags; |
| 1591 | % |
| 1592 | % if ( (option_type & SimpleOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1593 | % CLISimpleOperatorImages(cli_wand, argv[i], |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1594 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 1595 | % count>=2 ? argv[i+2] : (char *)NULL ); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1596 | % i += count+1; |
| 1597 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1598 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1599 | |
| 1600 | /* |
| 1601 | Internal subrountine to apply one simple image operation to the current |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1602 | image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1603 | |
| 1604 | The image in the list may be modified in three different ways... |
| 1605 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1606 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1607 | * one image replace by a list of images (-separate and -crop only!) |
| 1608 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1609 | In each case the result replaces the single original image in the list, as |
| 1610 | well as the pointer to the modified image (last image added if replaced by a |
| 1611 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1612 | |
| 1613 | As the image pointed to may be replaced, the first image in the list may |
| 1614 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1615 | return the Image pointer to the first image in list. |
| 1616 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1617 | static void CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1618 | const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1619 | { |
| 1620 | Image * |
| 1621 | new_image; |
| 1622 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1623 | GeometryInfo |
| 1624 | geometry_info; |
| 1625 | |
| 1626 | RectangleInfo |
| 1627 | geometry; |
| 1628 | |
| 1629 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1630 | flags; |
| 1631 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1632 | #define image_info (cli_wand->wand.image_info) |
| 1633 | #define image (cli_wand->wand.images) |
| 1634 | #define exception (cli_wand->wand.exception) |
| 1635 | #define draw_info (cli_wand->draw_info) |
| 1636 | #define quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1637 | #define IfNormalOp (*option=='-') |
| 1638 | #define IfPlusOp (*option!='-') |
| 1639 | #define normal_op (IfNormalOp?MagickTrue:MagickFalse) |
| 1640 | #define plus_alt_op (IfNormalOp?MagickFalse:MagickTrue) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1641 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1642 | assert(cli_wand != (MagickCLI *) NULL); |
| 1643 | assert(cli_wand->signature == WandSignature); |
| 1644 | assert(cli_wand->wand.signature == WandSignature); |
| 1645 | assert(image != (Image *) NULL); /* an image must be present */ |
| 1646 | if (cli_wand->wand.debug != MagickFalse) |
| 1647 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1648 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1649 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1650 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1651 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1652 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1653 | /* FUTURE: We may need somthing a little more optimized than this! |
| 1654 | Perhaps, do the 'sync' if 'settings tainted' before next operator. |
| 1655 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1656 | (void) SyncImageSettings(image_info,image,exception); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1657 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1658 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1659 | { |
| 1660 | case 'a': |
| 1661 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1662 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1663 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1664 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1665 | if ((flags & SigmaValue) == 0) |
| 1666 | geometry_info.sigma=1.0; |
| 1667 | if ((flags & XiValue) == 0) |
| 1668 | geometry_info.xi=0.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1669 | new_image=AdaptiveBlurImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1670 | geometry_info.sigma,geometry_info.xi,exception); |
| 1671 | break; |
| 1672 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1673 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1674 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1675 | (void) ParseRegionGeometry(image,arg1,&geometry,exception); |
| 1676 | new_image=AdaptiveResizeImage(image,geometry.width,geometry.height, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1677 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1678 | break; |
| 1679 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1680 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1681 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1682 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1683 | if ((flags & SigmaValue) == 0) |
| 1684 | geometry_info.sigma=1.0; |
| 1685 | if ((flags & XiValue) == 0) |
| 1686 | geometry_info.xi=0.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1687 | new_image=AdaptiveSharpenImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1688 | geometry_info.sigma,geometry_info.xi,exception); |
| 1689 | break; |
| 1690 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1691 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1692 | { |
| 1693 | AlphaChannelType |
| 1694 | alpha_type; |
| 1695 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1696 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1697 | MagickFalse,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1698 | (void) SetImageAlphaChannel(image,alpha_type,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1699 | break; |
| 1700 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1701 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1702 | { |
| 1703 | char |
| 1704 | *text, |
| 1705 | geometry[MaxTextExtent]; |
| 1706 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1707 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1708 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1709 | if ((flags & SigmaValue) == 0) |
| 1710 | geometry_info.sigma=geometry_info.rho; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1711 | text=InterpretImageProperties(image_info,image,arg2, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1712 | exception); |
| 1713 | if (text == (char *) NULL) |
| 1714 | break; |
| 1715 | (void) CloneString(&draw_info->text,text); |
| 1716 | text=DestroyString(text); |
| 1717 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1718 | geometry_info.xi,geometry_info.psi); |
| 1719 | (void) CloneString(&draw_info->geometry,geometry); |
| 1720 | draw_info->affine.sx=cos(DegreesToRadians( |
| 1721 | fmod(geometry_info.rho,360.0))); |
| 1722 | draw_info->affine.rx=sin(DegreesToRadians( |
| 1723 | fmod(geometry_info.rho,360.0))); |
| 1724 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 1725 | fmod(geometry_info.sigma,360.0)))); |
| 1726 | draw_info->affine.sy=cos(DegreesToRadians( |
| 1727 | fmod(geometry_info.sigma,360.0))); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1728 | (void) AnnotateImage(image,draw_info,exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1729 | GetAffineMatrix(&draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1730 | break; |
| 1731 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1732 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1733 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1734 | (void) AutoGammaImage(image,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("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1738 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1739 | (void) AutoLevelImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1740 | break; |
| 1741 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1742 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1743 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1744 | /* This should probbaly be a MagickCore function */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1745 | switch (image->orientation) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1746 | { |
| 1747 | case TopRightOrientation: |
| 1748 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1749 | new_image=FlopImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1750 | break; |
| 1751 | } |
| 1752 | case BottomRightOrientation: |
| 1753 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1754 | new_image=RotateImage(image,180.0,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1755 | break; |
| 1756 | } |
| 1757 | case BottomLeftOrientation: |
| 1758 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1759 | new_image=FlipImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1760 | break; |
| 1761 | } |
| 1762 | case LeftTopOrientation: |
| 1763 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1764 | new_image=TransposeImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1765 | break; |
| 1766 | } |
| 1767 | case RightTopOrientation: |
| 1768 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1769 | new_image=RotateImage(image,90.0,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1770 | break; |
| 1771 | } |
| 1772 | case RightBottomOrientation: |
| 1773 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1774 | new_image=TransverseImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1775 | break; |
| 1776 | } |
| 1777 | case LeftBottomOrientation: |
| 1778 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1779 | new_image=RotateImage(image,270.0,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1780 | break; |
| 1781 | } |
| 1782 | default: |
| 1783 | break; |
| 1784 | } |
| 1785 | if (new_image != (Image *) NULL) |
| 1786 | new_image->orientation=TopLeftOrientation; |
| 1787 | break; |
| 1788 | } |
| 1789 | break; |
| 1790 | } |
| 1791 | case 'b': |
| 1792 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1793 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1794 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1795 | (void) BlackThresholdImage(image,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1796 | break; |
| 1797 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1798 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1799 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1800 | geometry_info.rho=1.5; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1801 | if (IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1802 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1803 | new_image=BlueShiftImage(image,geometry_info.rho,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1804 | break; |
| 1805 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1806 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1807 | { |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1808 | /* FUTURE: use of "bias" in a blur is non-sensible */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1809 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1810 | if ((flags & SigmaValue) == 0) |
| 1811 | geometry_info.sigma=1.0; |
| 1812 | if ((flags & XiValue) == 0) |
| 1813 | geometry_info.xi=0.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1814 | new_image=BlurImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1815 | geometry_info.sigma,geometry_info.xi,exception); |
| 1816 | break; |
| 1817 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1818 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1819 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1820 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1821 | compose; |
| 1822 | |
| 1823 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1824 | value; |
| 1825 | |
| 1826 | value=GetImageOption(image_info,"compose"); |
| 1827 | if (value != (const char *) NULL) |
| 1828 | compose=(CompositeOperator) ParseCommandOption( |
| 1829 | MagickComposeOptions,MagickFalse,value); |
| 1830 | else |
| 1831 | compose=OverCompositeOp; /* use Over not image->compose */ |
| 1832 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1833 | flags=ParsePageGeometry(image,arg1,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1834 | if ((flags & SigmaValue) == 0) |
| 1835 | geometry.height=geometry.width; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1836 | new_image=BorderImage(image,&geometry,compose,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1837 | break; |
| 1838 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1839 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1840 | { |
| 1841 | double |
| 1842 | brightness, |
| 1843 | contrast; |
| 1844 | |
| 1845 | GeometryInfo |
| 1846 | geometry_info; |
| 1847 | |
| 1848 | MagickStatusType |
| 1849 | flags; |
| 1850 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1851 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1852 | brightness=geometry_info.rho; |
| 1853 | contrast=0.0; |
| 1854 | if ((flags & SigmaValue) != 0) |
| 1855 | contrast=geometry_info.sigma; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1856 | (void) BrightnessContrastImage(image,brightness,contrast, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1857 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1858 | break; |
| 1859 | } |
| 1860 | break; |
| 1861 | } |
| 1862 | case 'c': |
| 1863 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1864 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1865 | { |
| 1866 | char |
| 1867 | *color_correction_collection; |
| 1868 | |
| 1869 | /* |
| 1870 | Color correct with a color decision list. |
| 1871 | */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1872 | color_correction_collection=FileToString(arg1,~0,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1873 | if (color_correction_collection == (char *) NULL) |
| 1874 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1875 | (void) ColorDecisionListImage(image,color_correction_collection, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1876 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1877 | break; |
| 1878 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1879 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1880 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1881 | /* The "channel" setting has already been set |
anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1882 | FUTURE: This probably should be part of WandSettingOptionInfo() |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1883 | or SyncImageSettings(). |
| 1884 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1885 | SetPixelChannelMapMask(image,image_info->channel); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1886 | break; |
| 1887 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1888 | if (LocaleCompare("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1889 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1890 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1891 | if ((flags & SigmaValue) == 0) |
| 1892 | geometry_info.sigma=1.0; |
| 1893 | if ((flags & XiValue) == 0) |
| 1894 | geometry_info.xi=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1895 | new_image=CharcoalImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1896 | geometry_info.sigma,geometry_info.xi,exception); |
| 1897 | break; |
| 1898 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1899 | if (LocaleCompare("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1900 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1901 | (void) ParseGravityGeometry(image,arg1,&geometry,exception); |
| 1902 | new_image=ChopImage(image,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1903 | break; |
| 1904 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1905 | if (LocaleCompare("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1906 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1907 | (void) ClampImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1908 | break; |
| 1909 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1910 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1911 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1912 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1913 | (void) ClipImage(image,exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1914 | else /* "+mask" remove the write mask */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1915 | (void) SetImageMask(image,(Image *) NULL,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1916 | break; |
| 1917 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1918 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1919 | { |
| 1920 | CacheView |
| 1921 | *mask_view; |
| 1922 | |
| 1923 | Image |
| 1924 | *mask_image; |
| 1925 | |
| 1926 | register Quantum |
| 1927 | *restrict q; |
| 1928 | |
| 1929 | register ssize_t |
| 1930 | x; |
| 1931 | |
| 1932 | ssize_t |
| 1933 | y; |
| 1934 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1935 | if (IfPlusOp) { |
| 1936 | /* "+clip-mask" Remove the write mask */ |
| 1937 | (void) SetImageMask(image,(Image *) NULL,exception); |
| 1938 | break; |
| 1939 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1940 | mask_image=GetImageCache(image_info,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1941 | if (mask_image == (Image *) NULL) |
| 1942 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1943 | if (SetImageStorageClass(mask_image,DirectClass,exception) |
| 1944 | == MagickFalse) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1945 | break; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1946 | /* Create a write mask from cli_wandp-mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1947 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1948 | mask_view=AcquireCacheView(mask_image); |
| 1949 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1950 | { |
| 1951 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1952 | exception); |
| 1953 | if (q == (Quantum *) NULL) |
| 1954 | break; |
| 1955 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1956 | { |
| 1957 | if (mask_image->matte == MagickFalse) |
| 1958 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1959 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1960 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1961 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1962 | q+=GetPixelChannels(mask_image); |
| 1963 | } |
| 1964 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1965 | break; |
| 1966 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1967 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1968 | mask_view=DestroyCacheView(mask_view); |
| 1969 | mask_image->matte=MagickTrue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1970 | (void) SetImageMask(image,mask_image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1971 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1972 | break; |
| 1973 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1974 | if (LocaleCompare("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1975 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1976 | (void) ClipImagePath(image,arg1,normal_op,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1977 | break; |
| 1978 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1979 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1980 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1981 | new_image=ColorizeImage(image,arg1,&draw_info->fill,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1982 | break; |
| 1983 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1984 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1985 | { |
| 1986 | KernelInfo |
| 1987 | *kernel; |
| 1988 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1989 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1990 | if (kernel == (KernelInfo *) NULL) |
| 1991 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1992 | new_image=ColorMatrixImage(image,kernel,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1993 | kernel=DestroyKernelInfo(kernel); |
| 1994 | break; |
| 1995 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1996 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1997 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1998 | /* Reduce the number of colors in the image. |
| 1999 | FUTURE: also provide 'plus version with image 'color counts' |
| 2000 | */ |
| 2001 | quantize_info->number_colors=StringToUnsignedLong(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2002 | if (quantize_info->number_colors == 0) |
| 2003 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2004 | if ((image->storage_class == DirectClass) || |
| 2005 | image->colors > quantize_info->number_colors) |
| 2006 | (void) QuantizeImage(quantize_info,image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2007 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2008 | (void) CompressImageColormap(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2009 | break; |
| 2010 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2011 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2012 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2013 | /* WARNING: this is both a image_info setting (already done) |
| 2014 | and a operator to change image colorspace. |
| 2015 | |
| 2016 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2017 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2018 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2019 | Note that +colorspace sets "undefined" or no effect on |
| 2020 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2021 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2022 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2023 | (void) TransformImageColorspace(image, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2024 | IfNormalOp ? image_info->colorspace : RGBColorspace, |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 2025 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2026 | break; |
| 2027 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2028 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2029 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2030 | (void) ContrastImage(image,normal_op,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2031 | break; |
| 2032 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2033 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2034 | { |
| 2035 | double |
| 2036 | black_point, |
| 2037 | white_point; |
| 2038 | |
| 2039 | MagickStatusType |
| 2040 | flags; |
| 2041 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2042 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2043 | black_point=geometry_info.rho; |
| 2044 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2045 | black_point; |
| 2046 | if ((flags & PercentValue) != 0) |
| 2047 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2048 | black_point*=(double) image->columns*image->rows/100.0; |
| 2049 | white_point*=(double) image->columns*image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2050 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2051 | white_point=(MagickRealType) image->columns*image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2052 | white_point; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2053 | (void) ContrastStretchImage(image,black_point,white_point, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2054 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2055 | break; |
| 2056 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2057 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2058 | { |
| 2059 | KernelInfo |
| 2060 | *kernel_info; |
| 2061 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2062 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2063 | if (kernel_info == (KernelInfo *) NULL) |
| 2064 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2065 | kernel_info->bias=image->bias; |
| 2066 | new_image=ConvolveImage(image,kernel_info,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2067 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2068 | break; |
| 2069 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2070 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2071 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2072 | /* WARNING: This can generate multiple images! */ |
| 2073 | new_image=CropImageToTiles(image,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2074 | break; |
| 2075 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2076 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2077 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2078 | (void) CycleColormapImage(image,(ssize_t) StringToLong(arg1), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2079 | exception); |
| 2080 | break; |
| 2081 | } |
| 2082 | break; |
| 2083 | } |
| 2084 | case 'd': |
| 2085 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2086 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2087 | { |
| 2088 | StringInfo |
| 2089 | *passkey; |
| 2090 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2091 | passkey=FileToStringInfo(arg1,~0,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2092 | if (passkey != (StringInfo *) NULL) |
| 2093 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2094 | (void) PasskeyDecipherImage(image,passkey,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2095 | passkey=DestroyStringInfo(passkey); |
| 2096 | } |
| 2097 | break; |
| 2098 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2099 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2100 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2101 | /* The image_info->depth setting has already been set |
| 2102 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2103 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2104 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2105 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2106 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2107 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2108 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2109 | (void) SetImageDepth(image,image_info->depth,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2110 | break; |
| 2111 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2112 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2113 | { |
| 2114 | double |
| 2115 | threshold; |
| 2116 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2117 | if (IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2118 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2119 | else |
| 2120 | threshold=40.0*QuantumRange/100.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2121 | new_image=DeskewImage(image,threshold,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2122 | break; |
| 2123 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2124 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2125 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2126 | new_image=DespeckleImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2127 | break; |
| 2128 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2129 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2130 | { |
| 2131 | char |
| 2132 | *args, |
| 2133 | token[MaxTextExtent]; |
| 2134 | |
| 2135 | const char |
| 2136 | *p; |
| 2137 | |
| 2138 | DistortImageMethod |
| 2139 | method; |
| 2140 | |
| 2141 | double |
| 2142 | *arguments; |
| 2143 | |
| 2144 | register ssize_t |
| 2145 | x; |
| 2146 | |
| 2147 | size_t |
| 2148 | number_arguments; |
| 2149 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2150 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2151 | MagickFalse,arg1); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2152 | if (method == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2153 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2154 | double |
| 2155 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2156 | /* Special Case - Argument is actually a resize geometry! |
| 2157 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2158 | ** FUTURE: make a separate special resize operator |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2159 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2160 | (void) ParseRegionGeometry(image,arg2,&geometry, |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2161 | exception); |
| 2162 | resize_args[0]=(double) geometry.width; |
| 2163 | resize_args[1]=(double) geometry.height; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2164 | new_image=DistortImage(image,method,(size_t)2, |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2165 | resize_args,MagickTrue,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2166 | break; |
| 2167 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2168 | /* handle percent arguments */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2169 | args=InterpretImageProperties(image_info,image,arg2, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2170 | exception); |
| 2171 | if (args == (char *) NULL) |
| 2172 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2173 | /* convert arguments into an array of doubles |
| 2174 | FUTURE: make this a separate function. |
| 2175 | Also make use of new 'sentinal' feature to avoid need for |
| 2176 | tokenization. |
| 2177 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2178 | p=(char *) args; |
| 2179 | for (x=0; *p != '\0'; x++) |
| 2180 | { |
| 2181 | GetMagickToken(p,&p,token); |
| 2182 | if (*token == ',') |
| 2183 | GetMagickToken(p,&p,token); |
| 2184 | } |
| 2185 | number_arguments=(size_t) x; |
| 2186 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 2187 | sizeof(*arguments)); |
| 2188 | if (arguments == (double *) NULL) |
| 2189 | ThrowWandFatalException(ResourceLimitFatalError, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2190 | "MemoryAllocationFailed",image->filename); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2191 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 2192 | sizeof(*arguments)); |
| 2193 | p=(char *) args; |
| 2194 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 2195 | { |
| 2196 | GetMagickToken(p,&p,token); |
| 2197 | if (*token == ',') |
| 2198 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2199 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2200 | } |
| 2201 | args=DestroyString(args); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2202 | new_image=DistortImage(image,method,number_arguments,arguments, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2203 | plus_alt_op,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2204 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 2205 | break; |
| 2206 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2207 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2208 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2209 | (void) CloneString(&draw_info->primitive,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2210 | (void) DrawImage(image,draw_info,exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2211 | (void) CloneString(&draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2212 | break; |
| 2213 | } |
| 2214 | break; |
| 2215 | } |
| 2216 | case 'e': |
| 2217 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2218 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2219 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2220 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2221 | if ((flags & SigmaValue) == 0) |
| 2222 | geometry_info.sigma=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2223 | new_image=EdgeImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2224 | geometry_info.sigma,exception); |
| 2225 | break; |
| 2226 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2227 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2228 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2229 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2230 | if ((flags & SigmaValue) == 0) |
| 2231 | geometry_info.sigma=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2232 | new_image=EmbossImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2233 | geometry_info.sigma,exception); |
| 2234 | break; |
| 2235 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2236 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2237 | { |
| 2238 | StringInfo |
| 2239 | *passkey; |
| 2240 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2241 | passkey=FileToStringInfo(arg1,~0,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2242 | if (passkey != (StringInfo *) NULL) |
| 2243 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2244 | (void) PasskeyEncipherImage(image,passkey,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2245 | passkey=DestroyStringInfo(passkey); |
| 2246 | } |
| 2247 | break; |
| 2248 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2249 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2250 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2251 | new_image=EnhanceImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2252 | break; |
| 2253 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2254 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2255 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2256 | (void) EqualizeImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2257 | break; |
| 2258 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2259 | if (LocaleCompare("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2260 | { |
| 2261 | double |
| 2262 | constant; |
| 2263 | |
| 2264 | MagickEvaluateOperator |
| 2265 | op; |
| 2266 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2267 | op=(MagickEvaluateOperator) ParseCommandOption( |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2268 | MagickEvaluateOptions,MagickFalse,arg1); |
| 2269 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2270 | (void) EvaluateImage(image,op,constant,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2271 | break; |
| 2272 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2273 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2274 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2275 | flags=ParseGravityGeometry(image,arg1,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2276 | if (geometry.width == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2277 | geometry.width=image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2278 | if (geometry.height == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2279 | geometry.height=image->rows; |
| 2280 | new_image=ExtentImage(image,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2281 | break; |
| 2282 | } |
| 2283 | break; |
| 2284 | } |
| 2285 | case 'f': |
| 2286 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2287 | if (LocaleCompare("features",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2288 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2289 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2290 | if (IfPlusOp) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2291 | (void) DeleteImageArtifact(image,"identify:features"); |
| 2292 | break; |
| 2293 | } |
| 2294 | (void) SetImageArtifact(image,"identify:features","true"); |
| 2295 | (void) SetImageArtifact(image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2296 | break; |
| 2297 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2298 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2299 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2300 | new_image=FlipImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2301 | break; |
| 2302 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2303 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2304 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2305 | new_image=FlopImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2306 | break; |
| 2307 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2308 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2309 | { |
| 2310 | PixelInfo |
| 2311 | target; |
| 2312 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2313 | (void) ParsePageGeometry(image,arg1,&geometry,exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2314 | (void) QueryColorCompliance(arg2,AllCompliance,&target,exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2315 | (void) FloodfillPaintImage(image,draw_info,&target,geometry.x, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2316 | geometry.y,plus_alt_op,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2317 | break; |
| 2318 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2319 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2320 | { |
| 2321 | FrameInfo |
| 2322 | frame_info; |
| 2323 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2324 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2325 | compose; |
| 2326 | |
| 2327 | const char* |
| 2328 | value; |
| 2329 | |
| 2330 | value=GetImageOption(image_info,"compose"); |
| 2331 | if (value != (const char *) NULL) |
| 2332 | compose=(CompositeOperator) ParseCommandOption( |
| 2333 | MagickComposeOptions,MagickFalse,value); |
| 2334 | else |
| 2335 | compose=OverCompositeOp; /* use Over not image->compose */ |
| 2336 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2337 | flags=ParsePageGeometry(image,arg1,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2338 | frame_info.width=geometry.width; |
| 2339 | frame_info.height=geometry.height; |
| 2340 | if ((flags & HeightValue) == 0) |
| 2341 | frame_info.height=geometry.width; |
| 2342 | frame_info.outer_bevel=geometry.x; |
| 2343 | frame_info.inner_bevel=geometry.y; |
| 2344 | frame_info.x=(ssize_t) frame_info.width; |
| 2345 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2346 | frame_info.width=image->columns+2*frame_info.width; |
| 2347 | frame_info.height=image->rows+2*frame_info.height; |
| 2348 | new_image=FrameImage(image,&frame_info,compose,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("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2352 | { |
| 2353 | char |
| 2354 | *arguments, |
| 2355 | token[MaxTextExtent]; |
| 2356 | |
| 2357 | const char |
| 2358 | *p; |
| 2359 | |
| 2360 | double |
| 2361 | *parameters; |
| 2362 | |
| 2363 | MagickFunction |
| 2364 | function; |
| 2365 | |
| 2366 | register ssize_t |
| 2367 | x; |
| 2368 | |
| 2369 | size_t |
| 2370 | number_parameters; |
| 2371 | |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2372 | /* |
| 2373 | Function Modify Image Values |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2374 | FUTURE: code should be almost a duplicate of that is "distort" |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2375 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2376 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2377 | MagickFalse,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2378 | arguments=InterpretImageProperties(image_info,image,arg2, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2379 | exception); |
| 2380 | if (arguments == (char *) NULL) |
| 2381 | break; |
| 2382 | p=(char *) arguments; |
| 2383 | for (x=0; *p != '\0'; x++) |
| 2384 | { |
| 2385 | GetMagickToken(p,&p,token); |
| 2386 | if (*token == ',') |
| 2387 | GetMagickToken(p,&p,token); |
| 2388 | } |
| 2389 | number_parameters=(size_t) x; |
| 2390 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 2391 | sizeof(*parameters)); |
| 2392 | if (parameters == (double *) NULL) |
| 2393 | ThrowWandFatalException(ResourceLimitFatalError, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2394 | "MemoryAllocationFailed",image->filename); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2395 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 2396 | sizeof(*parameters)); |
| 2397 | p=(char *) arguments; |
| 2398 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 2399 | { |
| 2400 | GetMagickToken(p,&p,token); |
| 2401 | if (*token == ',') |
| 2402 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2403 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2404 | } |
| 2405 | arguments=DestroyString(arguments); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2406 | (void) FunctionImage(image,function,number_parameters,parameters, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2407 | exception); |
| 2408 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 2409 | break; |
| 2410 | } |
| 2411 | break; |
| 2412 | } |
| 2413 | case 'g': |
| 2414 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2415 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2416 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2417 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2418 | (void) GammaImage(image,StringToDouble(arg1,(char **) NULL), |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2419 | exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2420 | else |
| 2421 | image->gamma=StringToDouble(arg1,(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2422 | break; |
| 2423 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2424 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 2425 | (LocaleCompare("gaussian",option+1) == 0)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2426 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2427 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2428 | if ((flags & SigmaValue) == 0) |
| 2429 | geometry_info.sigma=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2430 | new_image=GaussianBlurImage(image,geometry_info.rho, |
cristy | d89705a | 2012-01-20 02:52:24 +0000 | [diff] [blame] | 2431 | geometry_info.sigma,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2432 | break; |
| 2433 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2434 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2435 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2436 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2437 | Record Image offset for composition. (A Setting) |
| 2438 | Resize last image. (ListOperator) |
| 2439 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2440 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2441 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2442 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2443 | { /* remove the previous composition geometry offset! */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2444 | if (image->geometry != (char *) NULL) |
| 2445 | image->geometry=DestroyString(image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2446 | break; |
| 2447 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2448 | flags=ParseRegionGeometry(image,arg1,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2449 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2450 | (void) CloneString(&image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2451 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2452 | new_image=ResizeImage(image,geometry.width,geometry.height, |
| 2453 | image->filter,image->blur,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2454 | break; |
| 2455 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2456 | break; |
| 2457 | } |
| 2458 | case 'h': |
| 2459 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2460 | if (LocaleCompare("highlight-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2461 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2462 | (void) SetImageArtifact(image,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2463 | break; |
| 2464 | } |
| 2465 | break; |
| 2466 | } |
| 2467 | case 'i': |
| 2468 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2469 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2470 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2471 | const char |
| 2472 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2473 | *text; |
| 2474 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2475 | format=GetImageOption(image_info,"format"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2476 | if (format == (char *) NULL) |
| 2477 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2478 | (void) IdentifyImage(image,stdout,image_info->verbose, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2479 | exception); |
| 2480 | break; |
| 2481 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2482 | text=InterpretImageProperties(image_info,image,format,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2483 | if (text == (char *) NULL) |
| 2484 | break; |
| 2485 | (void) fputs(text,stdout); |
| 2486 | (void) fputc('\n',stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2487 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2488 | break; |
| 2489 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2490 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2491 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2492 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2493 | new_image=ImplodeImage(image,geometry_info.rho, |
| 2494 | image->interpolate,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2495 | break; |
| 2496 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2497 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2498 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2499 | (void) ParseRegionGeometry(image,arg1,&geometry,exception); |
| 2500 | new_image=InterpolativeResizeImage(image,geometry.width, |
| 2501 | geometry.height,image->interpolate,exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2502 | break; |
| 2503 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2504 | break; |
| 2505 | } |
| 2506 | case 'l': |
| 2507 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2508 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2509 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2510 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2511 | if ((flags & PercentValue) != 0) |
| 2512 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2513 | new_image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho, |
| 2514 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
| 2515 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2516 | break; |
| 2517 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2518 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2519 | { |
| 2520 | MagickRealType |
| 2521 | black_point, |
| 2522 | gamma, |
| 2523 | white_point; |
| 2524 | |
| 2525 | MagickStatusType |
| 2526 | flags; |
| 2527 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2528 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2529 | black_point=geometry_info.rho; |
| 2530 | white_point=(MagickRealType) QuantumRange; |
| 2531 | if ((flags & SigmaValue) != 0) |
| 2532 | white_point=geometry_info.sigma; |
| 2533 | gamma=1.0; |
| 2534 | if ((flags & XiValue) != 0) |
| 2535 | gamma=geometry_info.xi; |
| 2536 | if ((flags & PercentValue) != 0) |
| 2537 | { |
| 2538 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2539 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2540 | } |
| 2541 | if ((flags & SigmaValue) == 0) |
| 2542 | white_point=(MagickRealType) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2543 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
| 2544 | (void) LevelizeImage(image,black_point,white_point,gamma,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2545 | else |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2546 | (void) LevelImage(image,black_point,white_point,gamma,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2547 | break; |
| 2548 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2549 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2550 | { |
| 2551 | char |
| 2552 | token[MaxTextExtent]; |
| 2553 | |
| 2554 | const char |
| 2555 | *p; |
| 2556 | |
| 2557 | PixelInfo |
| 2558 | black_point, |
| 2559 | white_point; |
| 2560 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2561 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2562 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2563 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2564 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 2565 | &black_point,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2566 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2567 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 2568 | &black_point,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2569 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2570 | GetMagickToken(p,&p,token); |
| 2571 | if (*token == '\0') |
| 2572 | white_point=black_point; /* set everything to that color */ |
| 2573 | else |
| 2574 | { |
| 2575 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2576 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2577 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2578 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 2579 | &white_point,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2580 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2581 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 2582 | &white_point,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2583 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2584 | (void) LevelImageColors(image,&black_point,&white_point, |
| 2585 | plus_alt_op,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2586 | break; |
| 2587 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2588 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2589 | { |
| 2590 | double |
| 2591 | black_point, |
| 2592 | white_point; |
| 2593 | |
| 2594 | MagickStatusType |
| 2595 | flags; |
| 2596 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2597 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2598 | black_point=geometry_info.rho; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2599 | white_point=(MagickRealType) image->columns*image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2600 | if ((flags & SigmaValue) != 0) |
| 2601 | white_point=geometry_info.sigma; |
| 2602 | if ((flags & PercentValue) != 0) |
| 2603 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2604 | black_point*=(double) image->columns*image->rows/100.0; |
| 2605 | white_point*=(double) image->columns*image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2606 | } |
| 2607 | if ((flags & SigmaValue) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2608 | white_point=(MagickRealType) image->columns*image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2609 | black_point; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2610 | (void) LinearStretchImage(image,black_point,white_point,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2611 | break; |
| 2612 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2613 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2614 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2615 | flags=ParseRegionGeometry(image,arg1,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2616 | if ((flags & XValue) == 0) |
| 2617 | geometry.x=1; |
| 2618 | if ((flags & YValue) == 0) |
| 2619 | geometry.y=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2620 | new_image=LiquidRescaleImage(image,geometry.width, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2621 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2622 | break; |
| 2623 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2624 | if (LocaleCompare("lowlight-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2625 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2626 | (void) SetImageArtifact(image,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2627 | break; |
| 2628 | } |
| 2629 | break; |
| 2630 | } |
| 2631 | case 'm': |
| 2632 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2633 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2634 | { |
| 2635 | Image |
| 2636 | *remap_image; |
| 2637 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2638 | /* DEPRECIATED use -remap */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2639 | remap_image=GetImageCache(image_info,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2640 | if (remap_image == (Image *) NULL) |
| 2641 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2642 | (void) RemapImage(quantize_info,image,remap_image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2643 | remap_image=DestroyImage(remap_image); |
| 2644 | break; |
| 2645 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2646 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2647 | { |
| 2648 | Image |
| 2649 | *mask; |
| 2650 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2651 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2652 | { /* Remove a mask. */ |
| 2653 | (void) SetImageMask(image,(Image *) NULL,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2654 | break; |
| 2655 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2656 | /* Set the image mask. */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2657 | mask=GetImageCache(image_info,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2658 | if (mask == (Image *) NULL) |
| 2659 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2660 | (void) SetImageMask(image,mask,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2661 | mask=DestroyImage(mask); |
| 2662 | break; |
| 2663 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2664 | if (LocaleCompare("matte",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2665 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2666 | /* DEPRECIATED */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2667 | (void) SetImageAlphaChannel(image,IfNormalOp ? SetAlphaChannel : |
| 2668 | DeactivateAlphaChannel, exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2669 | break; |
| 2670 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2671 | if (LocaleCompare("mode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2672 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2673 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2674 | if ((flags & SigmaValue) == 0) |
| 2675 | geometry_info.sigma=geometry_info.rho; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2676 | new_image=StatisticImage(image,ModeStatistic,(size_t) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2677 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
| 2678 | break; |
| 2679 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2680 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2681 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2682 | (void) ModulateImage(image,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2683 | break; |
| 2684 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2685 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2686 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2687 | (void) SetImageProgressMonitor(image, IfNormalOp ? MonitorProgress : |
| 2688 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2689 | break; |
| 2690 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2691 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2692 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2693 | (void) SetImageType(image,BilevelType,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2694 | break; |
| 2695 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2696 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2697 | { |
| 2698 | char |
| 2699 | token[MaxTextExtent]; |
| 2700 | |
| 2701 | const char |
| 2702 | *p; |
| 2703 | |
| 2704 | KernelInfo |
| 2705 | *kernel; |
| 2706 | |
| 2707 | MorphologyMethod |
| 2708 | method; |
| 2709 | |
| 2710 | ssize_t |
| 2711 | iterations; |
| 2712 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2713 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2714 | GetMagickToken(p,&p,token); |
| 2715 | method=(MorphologyMethod) ParseCommandOption( |
| 2716 | MagickMorphologyOptions,MagickFalse,token); |
| 2717 | iterations=1L; |
| 2718 | GetMagickToken(p,&p,token); |
| 2719 | if ((*p == ':') || (*p == ',')) |
| 2720 | GetMagickToken(p,&p,token); |
| 2721 | if ((*p != '\0')) |
| 2722 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2723 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2724 | if (kernel == (KernelInfo *) NULL) |
| 2725 | { |
| 2726 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2727 | OptionError,"UnabletoParseKernel","morphology"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2728 | break; |
| 2729 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2730 | new_image=MorphologyImage(image,method,iterations,kernel,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2731 | kernel=DestroyKernelInfo(kernel); |
| 2732 | break; |
| 2733 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2734 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2735 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2736 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2737 | if ((flags & SigmaValue) == 0) |
| 2738 | geometry_info.sigma=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2739 | new_image=MotionBlurImage(image,geometry_info.rho, |
| 2740 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
| 2741 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2742 | break; |
| 2743 | } |
| 2744 | break; |
| 2745 | } |
| 2746 | case 'n': |
| 2747 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2748 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2749 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2750 | (void) NegateImage(image, plus_alt_op, exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2751 | break; |
| 2752 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2753 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2754 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2755 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2756 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2757 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2758 | if ((flags & SigmaValue) == 0) |
| 2759 | geometry_info.sigma=geometry_info.rho; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2760 | new_image=StatisticImage(image,NonpeakStatistic,(size_t) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2761 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
| 2762 | } |
| 2763 | else |
| 2764 | { |
| 2765 | NoiseType |
| 2766 | noise; |
| 2767 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2768 | double |
| 2769 | attenuate; |
| 2770 | |
| 2771 | const char* |
| 2772 | value; |
| 2773 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2774 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2775 | MagickFalse,arg1), |
| 2776 | |
| 2777 | value=GetImageOption(image_info,"attenuate"); |
| 2778 | if (value != (const char *) NULL) |
| 2779 | attenuate=StringToDouble(value,(char **) NULL); |
| 2780 | else |
| 2781 | attenuate=1.0; |
| 2782 | |
| 2783 | new_image=AddNoiseImage(image,noise,attenuate,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2784 | } |
| 2785 | break; |
| 2786 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2787 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2788 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2789 | (void) NormalizeImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2790 | break; |
| 2791 | } |
| 2792 | break; |
| 2793 | } |
| 2794 | case 'o': |
| 2795 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2796 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2797 | { |
| 2798 | PixelInfo |
| 2799 | target; |
| 2800 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2801 | (void) QueryColorCompliance(arg1,AllCompliance,&target,exception); |
| 2802 | (void) OpaquePaintImage(image,&target,&draw_info->fill,plus_alt_op, |
| 2803 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2804 | break; |
| 2805 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2806 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2807 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2808 | (void) OrderedPosterizeImage(image,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2809 | break; |
| 2810 | } |
| 2811 | break; |
| 2812 | } |
| 2813 | case 'p': |
| 2814 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2815 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2816 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2817 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2818 | new_image=OilPaintImage(image,geometry_info.rho,geometry_info.sigma, |
| 2819 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2820 | break; |
| 2821 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2822 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2823 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2824 | const char |
| 2825 | *caption; |
| 2826 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2827 | double |
| 2828 | angle; |
| 2829 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2830 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2831 | { |
| 2832 | RandomInfo |
| 2833 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2834 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2835 | random_info=AcquireRandomInfo(); |
| 2836 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2837 | random_info=DestroyRandomInfo(random_info); |
| 2838 | } |
| 2839 | else |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2840 | { |
| 2841 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2842 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2843 | angle=geometry_info.rho; |
| 2844 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2845 | caption=GetImageProperty(image,"caption",exception); |
| 2846 | new_image=PolaroidImage(image,draw_info,caption,angle, |
| 2847 | image->interpolate,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2848 | break; |
| 2849 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2850 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2851 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2852 | (void) ParseGeometry(arg1,&geometry_info); |
| 2853 | (void) PosterizeImage(image,(size_t) geometry_info.rho, |
| 2854 | quantize_info->dither,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2855 | break; |
| 2856 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2857 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2858 | { |
| 2859 | PreviewType |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2860 | preview_type; |
anthony | 170fce9 | 2011-10-20 11:50:23 +0000 | [diff] [blame] | 2861 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2862 | /* FUTURE: should be a 'Genesis' option? |
| 2863 | Option however is also in WandSettingOptionInfo() |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2864 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2865 | preview_type=UndefinedPreview; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2866 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2867 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2868 | MagickFalse,arg1); |
| 2869 | new_image=PreviewImage(image,preview_type,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2870 | break; |
| 2871 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2872 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2873 | { |
| 2874 | const char |
| 2875 | *name; |
| 2876 | |
| 2877 | const StringInfo |
| 2878 | *profile; |
| 2879 | |
| 2880 | Image |
| 2881 | *profile_image; |
| 2882 | |
| 2883 | ImageInfo |
| 2884 | *profile_info; |
| 2885 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2886 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2887 | { /* Remove a profile from the image. */ |
| 2888 | (void) ProfileImage(image,arg1,(const unsigned char *) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2889 | NULL,0,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2890 | break; |
| 2891 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2892 | /* Associate a profile with the image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2893 | profile_info=CloneImageInfo(image_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2894 | profile=GetImageProfile(image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2895 | if (profile != (StringInfo *) NULL) |
| 2896 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2897 | profile_image=GetImageCache(profile_info,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2898 | profile_info=DestroyImageInfo(profile_info); |
| 2899 | if (profile_image == (Image *) NULL) |
| 2900 | { |
| 2901 | StringInfo |
| 2902 | *profile; |
| 2903 | |
| 2904 | profile_info=CloneImageInfo(image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2905 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2906 | MaxTextExtent); |
| 2907 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2908 | if (profile != (StringInfo *) NULL) |
| 2909 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2910 | (void) ProfileImage(image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2911 | GetStringInfoDatum(profile),(size_t) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2912 | GetStringInfoLength(profile),exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2913 | profile=DestroyStringInfo(profile); |
| 2914 | } |
| 2915 | profile_info=DestroyImageInfo(profile_info); |
| 2916 | break; |
| 2917 | } |
| 2918 | ResetImageProfileIterator(profile_image); |
| 2919 | name=GetNextImageProfile(profile_image); |
| 2920 | while (name != (const char *) NULL) |
| 2921 | { |
| 2922 | profile=GetImageProfile(profile_image,name); |
| 2923 | if (profile != (StringInfo *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2924 | (void) ProfileImage(image,name,GetStringInfoDatum(profile), |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2925 | (size_t) GetStringInfoLength(profile),exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2926 | name=GetNextImageProfile(profile_image); |
| 2927 | } |
| 2928 | profile_image=DestroyImage(profile_image); |
| 2929 | break; |
| 2930 | } |
| 2931 | break; |
| 2932 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2933 | case 'r': |
| 2934 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2935 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2936 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2937 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2938 | new_image=RadialBlurImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2939 | geometry_info.sigma,exception); |
| 2940 | break; |
| 2941 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2942 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2943 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2944 | flags=ParsePageGeometry(image,arg1,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2945 | if ((flags & SigmaValue) == 0) |
| 2946 | geometry.height=geometry.width; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2947 | (void) RaiseImage(image,&geometry,normal_op,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2948 | break; |
| 2949 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2950 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2951 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2952 | (void) RandomThresholdImage(image,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2953 | break; |
| 2954 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2955 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2956 | { |
| 2957 | Image |
| 2958 | *remap_image; |
| 2959 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2960 | remap_image=GetImageCache(image_info,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2961 | if (remap_image == (Image *) NULL) |
| 2962 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2963 | (void) RemapImage(quantize_info,image,remap_image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2964 | remap_image=DestroyImage(remap_image); |
| 2965 | break; |
| 2966 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2967 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2968 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2969 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2970 | (void) ResetImagePage(image,arg1); |
| 2971 | else |
| 2972 | (void) ParseAbsoluteGeometry("0x0+0+0",&image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2973 | break; |
| 2974 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2975 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2976 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2977 | /* FUTURE: remove blur arguemnt - no longer used */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2978 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2979 | if ((flags & SigmaValue) == 0) |
| 2980 | geometry_info.sigma=geometry_info.rho; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2981 | new_image=ResampleImage(image,geometry_info.rho, |
| 2982 | geometry_info.sigma,image->filter,image->blur,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2983 | break; |
| 2984 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2985 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2986 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 2987 | /* FUTURE: remove blur argument - no longer used */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2988 | (void) ParseRegionGeometry(image,arg1,&geometry,exception); |
| 2989 | new_image=ResizeImage(image,geometry.width,geometry.height, |
| 2990 | image->filter,image->blur,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2991 | break; |
| 2992 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2993 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2994 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2995 | (void) ParsePageGeometry(image,arg1,&geometry,exception); |
| 2996 | new_image=RollImage(image,geometry.x,geometry.y,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2997 | break; |
| 2998 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2999 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3000 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3001 | if (strchr(arg1,'>') != (char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3002 | if (image->columns <= image->rows) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3003 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3004 | if (strchr(arg1,'<') != (char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3005 | if (image->columns >= image->rows) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3006 | break; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 3007 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3008 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3009 | new_image=RotateImage(image,geometry_info.rho,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3010 | break; |
| 3011 | } |
| 3012 | break; |
| 3013 | } |
| 3014 | case 's': |
| 3015 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3016 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3017 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3018 | (void) ParseRegionGeometry(image,arg1,&geometry,exception); |
| 3019 | new_image=SampleImage(image,geometry.width,geometry.height, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3020 | exception); |
| 3021 | break; |
| 3022 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3023 | if (LocaleCompare("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3024 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3025 | (void) ParseRegionGeometry(image,arg1,&geometry,exception); |
| 3026 | new_image=ScaleImage(image,geometry.width,geometry.height, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3027 | exception); |
| 3028 | break; |
| 3029 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3030 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3031 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3032 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3033 | if ((flags & PercentValue) != 0) |
| 3034 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3035 | new_image=SelectiveBlurImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3036 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
| 3037 | break; |
| 3038 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3039 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3040 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3041 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3042 | /* FUTURE - this may be replaced by a "-channel" method */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3043 | new_image=SeparateImages(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3044 | break; |
| 3045 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3046 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3047 | { |
| 3048 | double |
| 3049 | threshold; |
| 3050 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3051 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3052 | new_image=SepiaToneImage(image,threshold,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3053 | break; |
| 3054 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3055 | if (LocaleCompare("segment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3056 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3057 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3058 | if ((flags & SigmaValue) == 0) |
| 3059 | geometry_info.sigma=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3060 | (void) SegmentImage(image,image->colorspace, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3061 | image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3062 | exception); |
| 3063 | break; |
| 3064 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3065 | if (LocaleCompare("set",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3066 | { |
| 3067 | char |
| 3068 | *value; |
| 3069 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3070 | if (IfPlusOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3071 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3072 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3073 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3074 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3075 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3076 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3077 | (void) DeleteImageOption(image_info,arg1+7); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3078 | (void) DeleteImageArtifact(image,arg1+7); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3079 | } |
| 3080 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3081 | (void) DeleteImageProperty(image,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3082 | break; |
| 3083 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3084 | value=InterpretImageProperties(image_info,image,arg2, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3085 | exception); |
| 3086 | if (value == (char *) NULL) |
| 3087 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3088 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 3089 | (void) SetImageRegistry(StringRegistryType,arg1+9,value, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3090 | exception); |
| 3091 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3092 | if (LocaleNCompare(arg1,"option:",7) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3093 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3094 | (void) SetImageOption(image_info,arg1+7,value); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3095 | (void) SetImageArtifact(image,arg1+7,value); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3096 | } |
| 3097 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3098 | (void) SetImageProperty(image,arg1,value,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3099 | value=DestroyString(value); |
| 3100 | break; |
| 3101 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3102 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3103 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3104 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3105 | if ((flags & SigmaValue) == 0) |
| 3106 | geometry_info.sigma=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3107 | new_image=ShadeImage(image,normal_op,geometry_info.rho, |
| 3108 | geometry_info.sigma,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3109 | break; |
| 3110 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3111 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3112 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3113 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3114 | if ((flags & SigmaValue) == 0) |
| 3115 | geometry_info.sigma=1.0; |
| 3116 | if ((flags & XiValue) == 0) |
| 3117 | geometry_info.xi=4.0; |
| 3118 | if ((flags & PsiValue) == 0) |
| 3119 | geometry_info.psi=4.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3120 | new_image=ShadowImage(image,geometry_info.rho, |
| 3121 | geometry_info.sigma,image->bias,(ssize_t) |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 3122 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), |
| 3123 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3124 | break; |
| 3125 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3126 | if (LocaleCompare("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3127 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3128 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3129 | if ((flags & SigmaValue) == 0) |
| 3130 | geometry_info.sigma=1.0; |
| 3131 | if ((flags & XiValue) == 0) |
| 3132 | geometry_info.xi=0.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3133 | new_image=SharpenImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3134 | geometry_info.sigma,geometry_info.xi,exception); |
| 3135 | break; |
| 3136 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3137 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3138 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3139 | flags=ParsePageGeometry(image,arg1,&geometry,exception); |
| 3140 | new_image=ShaveImage(image,&geometry,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("shear",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 | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3146 | if ((flags & SigmaValue) == 0) |
| 3147 | geometry_info.sigma=geometry_info.rho; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3148 | new_image=ShearImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3149 | geometry_info.sigma,exception); |
| 3150 | break; |
| 3151 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3152 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3153 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3154 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3155 | if ((flags & SigmaValue) == 0) |
| 3156 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3157 | if ((flags & PercentValue) != 0) |
| 3158 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3159 | 100.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3160 | (void) SigmoidalContrastImage(image,normal_op,geometry_info.rho, |
| 3161 | geometry_info.sigma, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3162 | exception); |
| 3163 | break; |
| 3164 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3165 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3166 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3167 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3168 | if ((flags & SigmaValue) == 0) |
| 3169 | geometry_info.sigma=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3170 | new_image=SketchImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3171 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
| 3172 | break; |
| 3173 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3174 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3175 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3176 | (void) SolarizeImage(image,StringToDoubleInterval(arg1,(double) |
| 3177 | QuantumRange+1.0),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("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3181 | { |
| 3182 | SparseColorMethod |
| 3183 | method; |
| 3184 | |
| 3185 | char |
| 3186 | *arguments; |
| 3187 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3188 | method=(SparseColorMethod) ParseCommandOption( |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3189 | MagickSparseColorOptions,MagickFalse,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3190 | arguments=InterpretImageProperties(image_info,image,arg2,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3191 | if (arguments == (char *) NULL) |
| 3192 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3193 | new_image=SparseColorOption(image,method,arguments,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3194 | arguments=DestroyString(arguments); |
| 3195 | break; |
| 3196 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3197 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3198 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3199 | (void) ParseGravityGeometry(image,arg1,&geometry,exception); |
| 3200 | new_image=SpliceImage(image,&geometry,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3201 | break; |
| 3202 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3203 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3204 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3205 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3206 | new_image=SpreadImage(image,geometry_info.rho,image->interpolate, |
| 3207 | exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3208 | break; |
| 3209 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3210 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3211 | { |
| 3212 | StatisticType |
| 3213 | type; |
| 3214 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3215 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3216 | MagickFalse,arg1); |
| 3217 | (void) ParseGeometry(arg2,&geometry_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3218 | new_image=StatisticImage(image,type,(size_t) geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3219 | (size_t) geometry_info.sigma,exception); |
| 3220 | break; |
| 3221 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3222 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3223 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3224 | (void) StripImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3225 | break; |
| 3226 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3227 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3228 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3229 | (void) ParseGeometry(arg1,&geometry_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3230 | new_image=SwirlImage(image,geometry_info.rho, |
| 3231 | image->interpolate,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3232 | break; |
| 3233 | } |
| 3234 | break; |
| 3235 | } |
| 3236 | case 't': |
| 3237 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3238 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3239 | { |
| 3240 | double |
| 3241 | threshold; |
| 3242 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3243 | if (!normal_op) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3244 | threshold=(double) QuantumRange/2; |
| 3245 | else |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3246 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3247 | (void) BilevelImage(image,threshold,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3248 | break; |
| 3249 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3250 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3251 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3252 | (void) ParseRegionGeometry(image,arg1,&geometry,exception); |
| 3253 | new_image=ThumbnailImage(image,geometry.width,geometry.height, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3254 | exception); |
| 3255 | break; |
| 3256 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3257 | if (LocaleCompare("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3258 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3259 | new_image=TintImage(image,arg1,&draw_info->fill,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3260 | break; |
| 3261 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3262 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3263 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3264 | /* DEPRECIATED */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3265 | new_image=AffineTransformImage(image,&draw_info->affine, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3266 | exception); |
| 3267 | break; |
| 3268 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3269 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3270 | { |
| 3271 | PixelInfo |
| 3272 | target; |
| 3273 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3274 | (void) QueryColorCompliance(arg1,AllCompliance,&target,exception); |
| 3275 | (void) TransparentPaintImage(image,&target,(Quantum) |
| 3276 | TransparentAlpha,plus_alt_op,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("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3280 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3281 | new_image=TransposeImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3282 | break; |
| 3283 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3284 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3285 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3286 | new_image=TransverseImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3287 | break; |
| 3288 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3289 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3290 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3291 | new_image=TrimImage(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3292 | break; |
| 3293 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3294 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3295 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3296 | /* Note that "type" setting should have already been defined */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3297 | (void) SetImageType(image,image_info->type,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3298 | break; |
| 3299 | } |
| 3300 | break; |
| 3301 | } |
| 3302 | case 'u': |
| 3303 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3304 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3305 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3306 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3307 | if (!normal_op) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3308 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3309 | (void) DeleteImageArtifact(image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3310 | break; |
| 3311 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3312 | (void) SetImageArtifact(image,"identify:unique-colors","true"); |
| 3313 | (void) SetImageArtifact(image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3314 | break; |
| 3315 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3316 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3317 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3318 | new_image=UniqueImageColors(image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3319 | break; |
| 3320 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3321 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3322 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3323 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3324 | if ((flags & SigmaValue) == 0) |
| 3325 | geometry_info.sigma=1.0; |
| 3326 | if ((flags & XiValue) == 0) |
| 3327 | geometry_info.xi=1.0; |
| 3328 | if ((flags & PsiValue) == 0) |
| 3329 | geometry_info.psi=0.05; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3330 | new_image=UnsharpMaskImage(image,geometry_info.rho, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3331 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
| 3332 | break; |
| 3333 | } |
| 3334 | break; |
| 3335 | } |
| 3336 | case 'v': |
| 3337 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3338 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3339 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3340 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3341 | three places! ImageArtifact ImageOption image_info->verbose |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3342 | Some how new images also get this artifact presumably here |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3343 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3344 | (void) SetImageArtifact(image,option+1, |
| 3345 | IfNormalOp ? "true" : "false" ); |
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("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3349 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3350 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3351 | if ((flags & SigmaValue) == 0) |
| 3352 | geometry_info.sigma=1.0; |
| 3353 | if ((flags & XiValue) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3354 | geometry_info.xi=0.1*image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3355 | if ((flags & PsiValue) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3356 | geometry_info.psi=0.1*image->rows; |
| 3357 | new_image=VignetteImage(image,geometry_info.rho,geometry_info.sigma, |
| 3358 | image->bias,(ssize_t) ceil(geometry_info.xi-0.5), |
| 3359 | (ssize_t) ceil(geometry_info.psi-0.5),exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3360 | break; |
| 3361 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3362 | break; |
| 3363 | } |
| 3364 | case 'w': |
| 3365 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3366 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3367 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3368 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3369 | if ((flags & SigmaValue) == 0) |
| 3370 | geometry_info.sigma=1.0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3371 | new_image=WaveImage(image,geometry_info.rho,geometry_info.sigma, |
| 3372 | image->interpolate,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3373 | break; |
| 3374 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3375 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3376 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3377 | (void) WhiteThresholdImage(image,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3378 | break; |
| 3379 | } |
| 3380 | break; |
| 3381 | } |
| 3382 | default: |
| 3383 | break; |
| 3384 | } |
| 3385 | /* |
| 3386 | Replace current image with any image that was generated |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3387 | and set image point to last image (so image->next is correct) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3388 | */ |
| 3389 | if (new_image != (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3390 | ReplaceImageInListReturnLast(&image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3391 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3392 | return; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3393 | #undef image_info |
| 3394 | #undef draw_info |
| 3395 | #undef quantize_info |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3396 | #undef image |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3397 | #undef exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3398 | #undef IfNormalOp |
| 3399 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3400 | #undef normal_op |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3401 | #undef plus_alt_op |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3402 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3403 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3404 | WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3405 | const char *option, const char *arg1, const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3406 | { |
| 3407 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3408 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3409 | i; |
| 3410 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3411 | assert(cli_wand != (MagickCLI *) NULL); |
| 3412 | assert(cli_wand->signature == WandSignature); |
| 3413 | assert(cli_wand->wand.signature == WandSignature); |
| 3414 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
| 3415 | if (cli_wand->wand.debug != MagickFalse) |
| 3416 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3417 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3418 | #if !USE_WAND_METHODS |
| 3419 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3420 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3421 | n=GetImageListLength(cli_wand->wand.images); |
| 3422 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3423 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3424 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3425 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3426 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3427 | break; |
| 3428 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3429 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3430 | assert( i == n ); |
| 3431 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3432 | #else |
| 3433 | MagickResetIterator(&cli_wand->wand); |
| 3434 | while ( MagickNextImage(&cli_wand->wand) != MagickFalse ) |
| 3435 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3436 | MagickResetIterator(&cli_wand->wand); |
| 3437 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3438 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3439 | } |
| 3440 | |
| 3441 | /* |
| 3442 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3443 | % % |
| 3444 | % % |
| 3445 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3446 | + 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] | 3447 | % % |
| 3448 | % % |
| 3449 | % % |
| 3450 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3451 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3452 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3453 | % entire image list as a whole. The result is often a complete replacment |
| 3454 | % 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] | 3455 | % |
| 3456 | % The format of the MogrifyImage method is: |
| 3457 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3458 | % void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3459 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3460 | % |
| 3461 | % A description of each parameter follows: |
| 3462 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3463 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3464 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3465 | % o option: The option string for the operation |
| 3466 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3467 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3468 | % |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3469 | % NOTE: only "limit" currently uses two arguments. |
| 3470 | % |
| 3471 | % Example usage... |
| 3472 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3473 | % CLIListOperatorImages(cli_wand,MagickFalse,"-duplicate", "3", NULL); |
| 3474 | % CLIListOperatorImages(cli_wand,MagickTrue, "+append", NULL, NULL); |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3475 | % |
| 3476 | % Or for handling command line arguments EG: +/-option ["arg"] |
| 3477 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3478 | % cli_wand |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3479 | % argc,argv |
| 3480 | % i=index in argv |
| 3481 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 3482 | % option_info = GetCommandOptionInfo(argv[i]); |
| 3483 | % count=option_info->type; |
| 3484 | % option_type=option_info->flags; |
| 3485 | % |
| 3486 | % if ( (option_type & ListOperatorOptionFlag) != 0 ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3487 | % CLIListOperatorImages(cli_wand,argv[i], |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3488 | % count>=1 ? argv[i+1] : (char *)NULL, |
| 3489 | % count>=2 ? argv[i+2] : (char *)NULL ); |
| 3490 | % i += count+1; |
| 3491 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3492 | */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3493 | WandExport void CLIListOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3494 | const char *option,const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3495 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3496 | Image |
| 3497 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3498 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3499 | #define image_info (cli_wand->wand.image_info) |
| 3500 | #define images (cli_wand->wand.images) |
| 3501 | #define exception (cli_wand->wand.exception) |
| 3502 | #define draw_info (cli_wand->draw_info) |
| 3503 | #define quantize_info (cli_wand->quantize_info) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3504 | #define IfNormalOp (*option=='-') |
| 3505 | #define IfPlusOp (*option!='-') |
| 3506 | #define normal_op (IfNormalOp?MagickTrue:MagickFalse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3507 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3508 | assert(cli_wand != (MagickCLI *) NULL); |
| 3509 | assert(cli_wand->signature == WandSignature); |
| 3510 | assert(cli_wand->wand.signature == WandSignature); |
| 3511 | assert(images != (Image *) NULL); /* images must be present */ |
| 3512 | if (cli_wand->wand.debug != MagickFalse) |
| 3513 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3514 | |
| 3515 | (void) SyncImagesSettings(image_info,images,exception); |
| 3516 | |
| 3517 | new_images=NewImageList(); |
| 3518 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3519 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3520 | { |
| 3521 | case 'a': |
| 3522 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3523 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3524 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3525 | new_images=AppendImages(images,normal_op,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3526 | break; |
| 3527 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3528 | if (LocaleCompare("average",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3529 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3530 | /* DEPRECIATED - use -evaluate-sequence Mean */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3531 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3532 | break; |
| 3533 | } |
| 3534 | break; |
| 3535 | } |
| 3536 | case 'c': |
| 3537 | { |
cristy | d04e7bf | 2012-03-03 19:19:12 +0000 | [diff] [blame] | 3538 | if (LocaleCompare("channel-ops",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3539 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame^] | 3540 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
| 3541 | new_images=ChannelOperationImage(*images,argv[i+1],exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3542 | break; |
| 3543 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3544 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3545 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3546 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3547 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3548 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3549 | /* FUTURE - make this a compose option, and thus can be used |
| 3550 | with layers compose or even compose last image over all other |
| 3551 | images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3552 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3553 | new_images=RemoveFirstImageFromList(&images); |
| 3554 | clut_image=RemoveLastImageFromList(&images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3555 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3556 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3557 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3558 | (void) ClutImage(new_images,clut_image,images->interpolate,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3559 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3560 | break; |
| 3561 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3562 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3563 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3564 | new_images=CoalesceImages(images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3565 | break; |
| 3566 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3567 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3568 | { |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3569 | /* FUTURE - this may be replaced by a 'channel' method */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3570 | new_images=CombineImages(images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3571 | break; |
| 3572 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3573 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3574 | { |
| 3575 | Image |
| 3576 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3577 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3578 | |
| 3579 | RectangleInfo |
| 3580 | geometry; |
| 3581 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3582 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3583 | compose; |
| 3584 | |
| 3585 | const char* |
| 3586 | value; |
| 3587 | |
| 3588 | value=GetImageOption(image_info,"compose"); |
| 3589 | if (value != (const char *) NULL) |
| 3590 | compose=(CompositeOperator) ParseCommandOption( |
| 3591 | MagickComposeOptions,MagickFalse,value); |
| 3592 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3593 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3594 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3595 | new_images=RemoveFirstImageFromList(&images); |
| 3596 | source_image=RemoveFirstImageFromList(&images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3597 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3598 | if (source_image == (Image *) NULL) |
| 3599 | break; |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3600 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3601 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3602 | (void) TransformImage(&source_image,(char *) NULL, |
| 3603 | source_image->geometry,exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3604 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3605 | SetGeometry(source_image,&geometry); |
| 3606 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3607 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
| 3608 | new_images->gravity, &geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3609 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3610 | mask_image=RemoveFirstImageFromList(&images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3611 | if (mask_image != (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3612 | { /* handle a third write mask image */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3613 | if ((compose == DisplaceCompositeOp) || |
| 3614 | (compose == DistortCompositeOp)) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3615 | { /* Merge Y displacement into X displace/distort map. */ |
| 3616 | (void) CompositeImage(source_image,CopyGreenCompositeOp, |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 3617 | mask_image,0,0,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3618 | mask_image=DestroyImage(mask_image); |
| 3619 | } |
| 3620 | else |
| 3621 | { |
| 3622 | /* |
| 3623 | Set a blending mask for the composition. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3624 | */ |
cristy | 1539afd | 2012-01-30 01:32:59 +0000 | [diff] [blame] | 3625 | (void) NegateImage(mask_image,MagickFalse,exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3626 | (void) SetImageMask(new_images,mask_image,exception); |
cristy | 1539afd | 2012-01-30 01:32:59 +0000 | [diff] [blame] | 3627 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3628 | } |
| 3629 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3630 | (void) CompositeImage(new_images,compose,source_image,geometry.x, |
| 3631 | geometry.y,exception); |
| 3632 | (void) SetImageMask(new_images,(Image *) NULL,exception); |
| 3633 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3634 | break; |
| 3635 | } |
| 3636 | break; |
| 3637 | } |
| 3638 | case 'd': |
| 3639 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3640 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3641 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3642 | /* DEPRECIATED - use -layers CompareAny */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3643 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3644 | break; |
| 3645 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3646 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3647 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3648 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3649 | DeleteImages(&images,arg1,exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3650 | else |
| 3651 | DeleteImages(&images,"-1",exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3652 | break; |
| 3653 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3654 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3655 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3656 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3657 | { |
| 3658 | const char |
| 3659 | *p; |
| 3660 | |
| 3661 | size_t |
| 3662 | number_duplicates; |
| 3663 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3664 | number_duplicates=(size_t) StringToLong(arg1); |
| 3665 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3666 | if (p == (const char *) NULL) |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3667 | new_images=DuplicateImages(images,number_duplicates, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3668 | "-1",exception); |
| 3669 | else |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3670 | new_images=DuplicateImages(images,number_duplicates,p, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3671 | exception); |
| 3672 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3673 | else |
| 3674 | new_images=DuplicateImages(images,1,"-1",exception); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3675 | AppendImageToList(&images, new_images); |
| 3676 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3677 | break; |
| 3678 | } |
| 3679 | break; |
| 3680 | } |
| 3681 | case 'e': |
| 3682 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3683 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3684 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3685 | MagickEvaluateOperator |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3686 | method; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3687 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3688 | method=(MagickEvaluateOperator) ParseCommandOption( |
| 3689 | MagickEvaluateOptions,MagickFalse,arg1); |
| 3690 | new_images=EvaluateImages(images,method,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3691 | break; |
| 3692 | } |
| 3693 | break; |
| 3694 | } |
| 3695 | case 'f': |
| 3696 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3697 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3698 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3699 | new_images=ForwardFourierTransformImage(images,normal_op,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3700 | break; |
| 3701 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3702 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3703 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame^] | 3704 | /* REDIRECTED to use -layers flatten instead */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3705 | CLIListOperatorImages(cli_wand,"-layer",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3706 | break; |
| 3707 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3708 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3709 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3710 | new_images=FxImage(images,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3711 | break; |
| 3712 | } |
| 3713 | break; |
| 3714 | } |
| 3715 | case 'h': |
| 3716 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3717 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3718 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3719 | /* FUTURE - make this a compose option (and thus layers compose ) |
| 3720 | or perhaps compose last image over all other images. |
| 3721 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3722 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3723 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3724 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3725 | new_images=RemoveFirstImageFromList(&images); |
| 3726 | hald_image=RemoveLastImageFromList(&images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3727 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3728 | break; |
| 3729 | (void) HaldClutImage(new_images,hald_image,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3730 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3731 | break; |
| 3732 | } |
| 3733 | break; |
| 3734 | } |
| 3735 | case 'i': |
| 3736 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3737 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3738 | { |
| 3739 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3740 | *magnitude_image, |
| 3741 | *phase_image; |
| 3742 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3743 | magnitude_image=RemoveFirstImageFromList(&images); |
| 3744 | phase_image=RemoveFirstImageFromList(&images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3745 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3746 | if (phase_image == (Image *) NULL) |
| 3747 | break; |
| 3748 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
| 3749 | normal_op,exception); |
| 3750 | magnitude_image=DestroyImage(magnitude_image); |
| 3751 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3752 | break; |
| 3753 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3754 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3755 | { |
| 3756 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3757 | *insert_image, |
| 3758 | *index_image; |
| 3759 | |
| 3760 | ssize_t |
| 3761 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3762 | |
| 3763 | index=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3764 | insert_image=RemoveLastImageFromList(&images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3765 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3766 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3767 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3768 | if (index == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3769 | PrependImageToList(&images,insert_image); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3770 | else if (index == (ssize_t) GetImageListLength(images)) |
| 3771 | AppendImageToList(&images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3772 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3773 | { |
| 3774 | index_image=GetImageFromList(images,index-1); |
| 3775 | if (index_image == (Image *) NULL) |
| 3776 | { |
| 3777 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 3778 | OptionError,"NoSuchImage","'%s'",arg1); |
| 3779 | break; |
| 3780 | } |
| 3781 | InsertImageInList(&index_image,insert_image); |
| 3782 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3783 | images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3784 | break; |
| 3785 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3786 | break; |
| 3787 | } |
| 3788 | case 'l': |
| 3789 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3790 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3791 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3792 | ImageLayerMethod |
| 3793 | method; |
| 3794 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3795 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3796 | MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3797 | switch (method) |
| 3798 | { |
| 3799 | case CoalesceLayer: |
| 3800 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3801 | new_images=CoalesceImages(images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3802 | break; |
| 3803 | } |
| 3804 | case CompareAnyLayer: |
| 3805 | case CompareClearLayer: |
| 3806 | case CompareOverlayLayer: |
| 3807 | default: |
| 3808 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3809 | new_images=CompareImagesLayers(images,method,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3810 | break; |
| 3811 | } |
| 3812 | case MergeLayer: |
| 3813 | case FlattenLayer: |
| 3814 | case MosaicLayer: |
| 3815 | case TrimBoundsLayer: |
| 3816 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3817 | new_images=MergeImageLayers(images,method,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3818 | break; |
| 3819 | } |
| 3820 | case DisposeLayer: |
| 3821 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3822 | new_images=DisposeImages(images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3823 | break; |
| 3824 | } |
| 3825 | case OptimizeImageLayer: |
| 3826 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3827 | new_images=OptimizeImageLayers(images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3828 | break; |
| 3829 | } |
| 3830 | case OptimizePlusLayer: |
| 3831 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3832 | new_images=OptimizePlusImageLayers(images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3833 | break; |
| 3834 | } |
| 3835 | case OptimizeTransLayer: |
| 3836 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3837 | OptimizeImageTransparency(images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3838 | break; |
| 3839 | } |
| 3840 | case RemoveDupsLayer: |
| 3841 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3842 | RemoveDuplicateLayers(&images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3843 | break; |
| 3844 | } |
| 3845 | case RemoveZeroLayer: |
| 3846 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3847 | RemoveZeroDelayLayers(&images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3848 | break; |
| 3849 | } |
| 3850 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3851 | { /* General Purpose, GIF Animation Optimizer. */ |
| 3852 | new_images=CoalesceImages(images,exception); |
| 3853 | if (new_images == (Image *) NULL) |
| 3854 | break; |
| 3855 | images=DestroyImageList(images); |
| 3856 | images=OptimizeImageLayers(new_images,exception); |
| 3857 | if (images == (Image *) NULL) |
| 3858 | break; |
| 3859 | new_images=DestroyImageList(new_images); |
| 3860 | OptimizeImageTransparency(images,exception); |
| 3861 | (void) RemapImages(quantize_info,images,(Image *) NULL, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3862 | exception); |
| 3863 | break; |
| 3864 | } |
| 3865 | case CompositeLayer: |
| 3866 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3867 | Image |
| 3868 | *source; |
| 3869 | |
| 3870 | RectangleInfo |
| 3871 | geometry; |
| 3872 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3873 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3874 | compose; |
| 3875 | |
| 3876 | const char* |
| 3877 | value; |
| 3878 | |
| 3879 | value=GetImageOption(image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3880 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3881 | if (value != (const char *) NULL) |
| 3882 | compose=(CompositeOperator) ParseCommandOption( |
| 3883 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3884 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3885 | /* Split image sequence at the first 'NULL:' image. */ |
| 3886 | source=images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3887 | while (source != (Image *) NULL) |
| 3888 | { |
| 3889 | source=GetNextImageInList(source); |
| 3890 | if ((source != (Image *) NULL) && |
| 3891 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 3892 | break; |
| 3893 | } |
| 3894 | if (source != (Image *) NULL) |
| 3895 | { |
| 3896 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 3897 | (GetNextImageInList(source) == (Image *) NULL)) |
| 3898 | source=(Image *) NULL; |
| 3899 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3900 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3901 | source=SplitImageList(source->previous); |
| 3902 | DeleteImageFromList(&source); |
| 3903 | } |
| 3904 | } |
| 3905 | if (source == (Image *) NULL) |
| 3906 | { |
| 3907 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 3908 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3909 | break; |
| 3910 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3911 | /* Adjust offset with gravity and virtual canvas. */ |
| 3912 | SetGeometry(images,&geometry); |
| 3913 | (void) ParseAbsoluteGeometry(images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3914 | geometry.width=source->page.width != 0 ? |
| 3915 | source->page.width : source->columns; |
| 3916 | geometry.height=source->page.height != 0 ? |
| 3917 | source->page.height : source->rows; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3918 | GravityAdjustGeometry(images->page.width != 0 ? |
| 3919 | images->page.width : images->columns, |
| 3920 | images->page.height != 0 ? images->page.height : |
| 3921 | images->rows,images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3922 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3923 | /* Compose the two image sequences together */ |
| 3924 | CompositeLayers(images,compose,source,geometry.x,geometry.y, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3925 | exception); |
| 3926 | source=DestroyImageList(source); |
| 3927 | break; |
| 3928 | } |
| 3929 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3930 | break; |
| 3931 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3932 | if (LocaleCompare("limit",option+1) == 0) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 3933 | { |
| 3934 | MagickSizeType |
| 3935 | limit; |
| 3936 | |
| 3937 | ResourceType |
| 3938 | type; |
| 3939 | |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 3940 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3941 | MagickFalse,arg1); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 3942 | limit=MagickResourceInfinity; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3943 | if (LocaleCompare("unlimited",arg2) != 0) |
| 3944 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 3945 | (void) SetMagickResourceLimit(type,limit); |
| 3946 | break; |
| 3947 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3948 | break; |
| 3949 | } |
| 3950 | case 'm': |
| 3951 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3952 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3953 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3954 | /* DEPRECIATED use +remap */ |
| 3955 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3956 | break; |
| 3957 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3958 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3959 | { |
| 3960 | Image |
| 3961 | *morph_image; |
| 3962 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3963 | morph_image=MorphImages(images,StringToUnsignedLong(arg1), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3964 | exception); |
| 3965 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3966 | break; |
| 3967 | images=DestroyImageList(images); |
| 3968 | images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3969 | break; |
| 3970 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3971 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3972 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame^] | 3973 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3974 | CLIListOperatorImages(cli_wand,"-layer",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3975 | break; |
| 3976 | } |
| 3977 | break; |
| 3978 | } |
| 3979 | case 'p': |
| 3980 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3981 | if (LocaleCompare("print",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3982 | { |
| 3983 | char |
| 3984 | *string; |
| 3985 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3986 | string=InterpretImageProperties(image_info,images,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3987 | exception); |
| 3988 | if (string == (char *) NULL) |
| 3989 | break; |
| 3990 | (void) FormatLocaleFile(stdout,"%s",string); |
| 3991 | string=DestroyString(string); |
| 3992 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3993 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3994 | { |
| 3995 | char |
| 3996 | **arguments; |
| 3997 | |
| 3998 | int |
| 3999 | j, |
| 4000 | number_arguments; |
| 4001 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4002 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4003 | if (arguments == (char **) NULL) |
| 4004 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4005 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4006 | { |
| 4007 | char |
| 4008 | breaker, |
| 4009 | quote, |
| 4010 | *token; |
| 4011 | |
| 4012 | const char |
| 4013 | *arguments; |
| 4014 | |
| 4015 | int |
| 4016 | next, |
| 4017 | status; |
| 4018 | |
| 4019 | size_t |
| 4020 | length; |
| 4021 | |
| 4022 | TokenInfo |
| 4023 | *token_info; |
| 4024 | |
| 4025 | /* |
| 4026 | Support old style syntax, filter="-option arg". |
| 4027 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4028 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4029 | token=(char *) NULL; |
| 4030 | if (~length >= (MaxTextExtent-1)) |
| 4031 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4032 | sizeof(*token)); |
| 4033 | if (token == (char *) NULL) |
| 4034 | break; |
| 4035 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4036 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4037 | token_info=AcquireTokenInfo(); |
| 4038 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4039 | "\"",'\0',&breaker,&next,"e); |
| 4040 | token_info=DestroyTokenInfo(token_info); |
| 4041 | if (status == 0) |
| 4042 | { |
| 4043 | const char |
| 4044 | *argv; |
| 4045 | |
| 4046 | argv=(&(arguments[next])); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4047 | (void) InvokeDynamicImageFilter(token,&images,1,&argv, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4048 | exception); |
| 4049 | } |
| 4050 | token=DestroyString(token); |
| 4051 | break; |
| 4052 | } |
| 4053 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4054 | (void) InvokeDynamicImageFilter(arguments[1],&images, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4055 | number_arguments-2,(const char **) arguments+2,exception); |
| 4056 | for (j=0; j < number_arguments; j++) |
| 4057 | arguments[j]=DestroyString(arguments[j]); |
| 4058 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4059 | break; |
| 4060 | } |
| 4061 | break; |
| 4062 | } |
| 4063 | case 'r': |
| 4064 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4065 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4066 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4067 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
| 4068 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
| 4069 | break; |
| 4070 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4071 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4072 | { |
| 4073 | ReverseImageList(&images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4074 | break; |
| 4075 | } |
| 4076 | break; |
| 4077 | } |
| 4078 | case 's': |
| 4079 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4080 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4081 | { |
| 4082 | Image |
| 4083 | *smush_image; |
| 4084 | |
| 4085 | ssize_t |
| 4086 | offset; |
| 4087 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4088 | offset=(ssize_t) StringToLong(arg1); |
| 4089 | smush_image=SmushImages(images,normal_op,offset,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4090 | if (smush_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4091 | break; |
| 4092 | images=DestroyImageList(images); |
| 4093 | images=smush_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4094 | break; |
| 4095 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4096 | if (LocaleCompare("swap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4097 | { |
| 4098 | Image |
| 4099 | *p, |
| 4100 | *q, |
| 4101 | *swap; |
| 4102 | |
| 4103 | ssize_t |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4104 | index, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4105 | swap_index; |
| 4106 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4107 | index=-1; |
| 4108 | swap_index=-2; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4109 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4110 | { |
| 4111 | GeometryInfo |
| 4112 | geometry_info; |
| 4113 | |
| 4114 | MagickStatusType |
| 4115 | flags; |
| 4116 | |
| 4117 | swap_index=(-1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4118 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4119 | index=(ssize_t) geometry_info.rho; |
| 4120 | if ((flags & SigmaValue) != 0) |
| 4121 | swap_index=(ssize_t) geometry_info.sigma; |
| 4122 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4123 | p=GetImageFromList(images,index); |
| 4124 | q=GetImageFromList(images,swap_index); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4125 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 4126 | { |
| 4127 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4128 | OptionError,"NoSuchImage","'%s'",images->filename); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4129 | break; |
| 4130 | } |
| 4131 | if (p == q) |
| 4132 | break; |
| 4133 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 4134 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 4135 | ReplaceImageInList(&q,swap); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4136 | images=GetFirstImageInList(q); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4137 | break; |
| 4138 | } |
| 4139 | break; |
| 4140 | } |
| 4141 | case 'w': |
| 4142 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4143 | if (LocaleCompare("write",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4144 | { |
| 4145 | char |
| 4146 | key[MaxTextExtent]; |
| 4147 | |
| 4148 | Image |
| 4149 | *write_images; |
| 4150 | |
| 4151 | ImageInfo |
| 4152 | *write_info; |
| 4153 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4154 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4155 | (void) DeleteImageRegistry(key); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4156 | write_images=images; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4157 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4158 | write_images=CloneImageList(images,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4159 | write_info=CloneImageInfo(image_info); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4160 | (void) WriteImages(write_info,write_images,arg1,exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4161 | write_info=DestroyImageInfo(write_info); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4162 | if (IfPlusOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4163 | write_images=DestroyImageList(write_images); |
| 4164 | break; |
| 4165 | } |
| 4166 | break; |
| 4167 | } |
| 4168 | default: |
| 4169 | break; |
| 4170 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4171 | if (new_images == (Image *) NULL) |
| 4172 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4173 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4174 | if (images != (Image *) NULL) |
| 4175 | images=DestroyImageList(images); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4176 | images=GetFirstImageInList(new_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4177 | return; |
| 4178 | |
| 4179 | #undef image_info |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4180 | #undef images |
| 4181 | #undef exception |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4182 | #undef draw_info |
| 4183 | #undef quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4184 | #undef IfNormalOp |
| 4185 | #undef IfPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4186 | #undef normal_op |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4187 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4188 | |
| 4189 | /* |
| 4190 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4191 | % % |
| 4192 | % % |
| 4193 | % % |
| 4194 | + C L I S p e c i a l O p e r a t i o n s % |
| 4195 | % % |
| 4196 | % % |
| 4197 | % % |
| 4198 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4199 | % |
| 4200 | % CLISpecialOption() Applies operations that may involve empty image lists |
| 4201 | % and or stacks of image lists or image_info settings. |
| 4202 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4203 | % The classic operators of this type is -read, and image stack operators, |
| 4204 | % which can be applied to empty image lists. |
| 4205 | % |
| 4206 | % Note: unlike other Operators, these may involve other special 'option' |
| 4207 | % character prefixes, other than simply '-' or '+'. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4208 | % |
| 4209 | % The format of the CLISpecialOption method is: |
| 4210 | % |
| 4211 | % void CLISpecialOption(MagickCLI *cli_wand,const char *option, |
| 4212 | % const char *arg) |
| 4213 | % |
| 4214 | % A description of each parameter follows: |
| 4215 | % |
| 4216 | % o cli_wand: the main CLI Wand to use. |
| 4217 | % |
| 4218 | % o option: The special option (with any switch char) to process |
| 4219 | % |
| 4220 | % o arg: Argument for option, if required |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4221 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4222 | % Example Usage... |
| 4223 | % |
| 4224 | % CLISpecialOperator(cli_wand,"-read", "rose:"); |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4225 | % |
| 4226 | % Or for handling command line arguments EG: +/-option ["arg"] |
| 4227 | % |
| 4228 | % cli_wand |
| 4229 | % argc,argv |
| 4230 | % i=index in argv |
| 4231 | % |
| 4232 | % option_info = GetCommandOptionInfo(argv[i]); |
| 4233 | % count=option_info->type; |
| 4234 | % option_type=option_info->flags; |
| 4235 | % |
| 4236 | % if ( (option_type & SpecialOptionFlag) != 0 ) |
| 4237 | % CLISpecialOperator(cli_wand,argv[i], |
| 4238 | % count>=1 ? argv[i+1] : (char *)NULL); |
| 4239 | % i += count+1; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4240 | % |
| 4241 | */ |
| 4242 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4243 | WandExport void CLISpecialOperator(MagickCLI *cli_wand, |
| 4244 | const char *option, const char *arg) |
| 4245 | { |
| 4246 | #define exception (cli_wand->wand.exception) |
| 4247 | |
| 4248 | assert(cli_wand != (MagickCLI *) NULL); |
| 4249 | assert(cli_wand->signature == WandSignature); |
| 4250 | assert(cli_wand->wand.signature == WandSignature); |
| 4251 | if (cli_wand->wand.debug != MagickFalse) |
| 4252 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
| 4253 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4254 | if (LocaleCompare("(",option) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4255 | { |
| 4256 | /* stack 'push' images */ |
| 4257 | Stack |
| 4258 | *node; |
| 4259 | |
| 4260 | size_t |
| 4261 | size; |
| 4262 | |
| 4263 | const char* |
| 4264 | value; |
| 4265 | |
| 4266 | size=0; |
| 4267 | node=cli_wand->image_list_stack; |
| 4268 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4269 | size++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4270 | if ( size >= MAX_STACK_DEPTH ) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4271 | { |
| 4272 | ThrowMagickException(exception,GetMagickModule(), |
| 4273 | OptionError,"ParenthesisNestedTooDeeply", option); |
| 4274 | return; |
| 4275 | } |
| 4276 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4277 | if (node == (Stack *) NULL) |
| 4278 | { |
| 4279 | ThrowMagickException(exception,GetMagickModule(), |
| 4280 | ResourceLimitFatalError,"MemoryAllocationFailed", "PushImages"); |
| 4281 | return; |
| 4282 | } |
| 4283 | node->data = (void *)cli_wand->wand.images; |
| 4284 | cli_wand->wand.images = NewImageList(); |
| 4285 | node->next = cli_wand->image_list_stack; |
| 4286 | cli_wand->image_list_stack = node; |
| 4287 | |
| 4288 | /* handle respect-parenthesis */ |
| 4289 | value=GetImageOption(cli_wand->wand.image_info,"respect-parenthesis"); |
| 4290 | if (value != (const char *) NULL) |
| 4291 | option="{"; |
| 4292 | else |
| 4293 | return; |
| 4294 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4295 | if (LocaleCompare("{",option) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4296 | { |
| 4297 | /* stack 'push' of image_info settings */ |
| 4298 | Stack |
| 4299 | *node; |
| 4300 | |
| 4301 | size_t |
| 4302 | size; |
| 4303 | |
| 4304 | size=0; |
| 4305 | node=cli_wand->image_info_stack; |
| 4306 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4307 | size++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4308 | if ( size >= MAX_STACK_DEPTH ) { |
| 4309 | ThrowMagickException(exception,GetMagickModule(), |
| 4310 | OptionError,"ParenthesisNestedTooDeeply", option); |
| 4311 | return; |
| 4312 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4313 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4314 | if (node == (Stack *) NULL) { |
| 4315 | ThrowMagickException(exception,GetMagickModule(), |
| 4316 | ResourceLimitFatalError,"MemoryAllocationFailed", "PushSettings"); |
| 4317 | return; |
| 4318 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4319 | |
| 4320 | node->data = (void *)cli_wand->wand.image_info; |
| 4321 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4322 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
| 4323 | ThrowMagickException(exception,GetMagickModule(), |
| 4324 | ResourceLimitFatalError,"MemoryAllocationFailed", "PushSettings"); |
| 4325 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4326 | node = (Stack *)RelinquishMagickMemory(node); |
| 4327 | return; |
| 4328 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4329 | |
| 4330 | node->next = cli_wand->image_info_stack; |
| 4331 | cli_wand->image_info_stack = node; |
| 4332 | |
| 4333 | return; |
| 4334 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4335 | if (LocaleCompare(")",option) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4336 | { |
| 4337 | /* pop images from stack */ |
| 4338 | Stack |
| 4339 | *node; |
| 4340 | |
| 4341 | const char* |
| 4342 | value; |
| 4343 | |
| 4344 | node = (void *)cli_wand->image_list_stack; |
| 4345 | if ( node == (Stack *)NULL) |
| 4346 | { |
| 4347 | ThrowMagickException(exception,GetMagickModule(), |
| 4348 | OptionError,"UnbalancedParenthesis", option); |
| 4349 | return; |
| 4350 | } |
| 4351 | cli_wand->image_list_stack = node->next; |
| 4352 | |
| 4353 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4354 | cli_wand->wand.images= (Image *)node->data; |
| 4355 | node = (Stack *)RelinquishMagickMemory(node); |
| 4356 | |
| 4357 | /* handle respect-parenthesis - of the previous 'push' settings */ |
| 4358 | node = cli_wand->image_info_stack; |
| 4359 | if ( node != (Stack *)NULL) |
| 4360 | { |
| 4361 | value=GetImageOption((ImageInfo *)node->data,"respect-parenthesis"); |
| 4362 | if (value != (const char *) NULL) |
| 4363 | option="}"; |
| 4364 | else |
| 4365 | return; |
| 4366 | } |
| 4367 | else |
| 4368 | return; |
| 4369 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4370 | if (LocaleCompare("}",option) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4371 | { |
| 4372 | /* pop image_info settings from stack */ |
| 4373 | Stack |
| 4374 | *node; |
| 4375 | |
| 4376 | node = (void *)cli_wand->image_info_stack; |
| 4377 | if ( node == (Stack *)NULL) |
| 4378 | { |
| 4379 | ThrowMagickException(exception,GetMagickModule(), |
| 4380 | OptionError,"UnbalancedParenthesis", option); |
| 4381 | return; |
| 4382 | } |
| 4383 | cli_wand->image_info_stack = node->next; |
| 4384 | |
| 4385 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
| 4386 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4387 | node = (Stack *)RelinquishMagickMemory(node); |
| 4388 | |
| 4389 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4390 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4391 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4392 | |
| 4393 | return; |
| 4394 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4395 | if (LocaleCompare("clone",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4396 | { |
| 4397 | Image |
| 4398 | *new_images; |
| 4399 | |
| 4400 | if (*option == '+') |
| 4401 | arg="-1"; |
| 4402 | if (IsSceneGeometry(arg,MagickFalse) == MagickFalse) |
| 4403 | { |
| 4404 | ThrowMagickException(exception,GetMagickModule(), |
| 4405 | OptionError,"InvalidArgument", "'%s': %s", option, arg); |
| 4406 | return; |
| 4407 | } |
| 4408 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
| 4409 | { |
| 4410 | ThrowMagickException(exception,GetMagickModule(), |
| 4411 | OptionError,"UnableToCloneImage", option); |
| 4412 | return; |
| 4413 | } |
| 4414 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4415 | if (new_images == (Image *) NULL) |
| 4416 | { |
| 4417 | ThrowMagickException(exception,GetMagickModule(), |
| 4418 | OptionError,"UnableToCloneImage", option); |
| 4419 | return; |
| 4420 | } |
| 4421 | new_images=CloneImages(new_images,arg,exception); |
| 4422 | if (new_images == (Image *) NULL) |
| 4423 | { |
| 4424 | ThrowMagickException(exception,GetMagickModule(), |
| 4425 | OptionError,"NoSuchImage",option); |
| 4426 | return; |
| 4427 | } |
| 4428 | AppendImageToList(&cli_wand->wand.images,new_images); |
| 4429 | return; |
| 4430 | } |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame^] | 4431 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
| 4432 | ( LocaleCompare("--",option) == 0 ) ) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4433 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4434 | #if !USE_WAND_METHODS |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4435 | Image * |
| 4436 | new_images; |
| 4437 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4438 | if (cli_wand->wand.image_info->ping != MagickFalse) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4439 | new_images=PingImages(cli_wand->wand.image_info,arg,exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4440 | else |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4441 | new_images=ReadImages(cli_wand->wand.image_info,arg,exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4442 | AppendImageToList(&cli_wand->wand.images, new_images); |
| 4443 | #else |
| 4444 | /* read images using MagickWand method - no ping */ |
| 4445 | /* This is not working! - it locks up in a CPU loop! */ |
| 4446 | MagickSetLastIterator(&cli_wand->wand); |
| 4447 | MagickReadImage(&cli_wand->wand,arg); |
| 4448 | MagickSetFirstIterator(&cli_wand->wand); |
| 4449 | #endif |
| 4450 | return; |
| 4451 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4452 | /* No-op options */ |
| 4453 | if (LocaleCompare("noop",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4454 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4455 | if (LocaleCompare("sans",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4456 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4457 | if (LocaleCompare("sans0",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4458 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4459 | if (LocaleCompare("sans2",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4460 | return; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4461 | if (LocaleCompare("list",option+1) == 0) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4462 | { |
| 4463 | /* FUTURE: This should really be built into the MagickCore |
| 4464 | It does not actually require any wand or images at all! |
| 4465 | */ |
| 4466 | ssize_t |
| 4467 | list; |
| 4468 | |
| 4469 | list=ParseCommandOption(MagickListOptions,MagickFalse, arg); |
| 4470 | switch (list) |
| 4471 | { |
| 4472 | case MagickCoderOptions: |
| 4473 | { |
| 4474 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 4475 | break; |
| 4476 | } |
| 4477 | case MagickColorOptions: |
| 4478 | { |
| 4479 | (void) ListColorInfo((FILE *) NULL,exception); |
| 4480 | break; |
| 4481 | } |
| 4482 | case MagickConfigureOptions: |
| 4483 | { |
| 4484 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 4485 | break; |
| 4486 | } |
| 4487 | case MagickDelegateOptions: |
| 4488 | { |
| 4489 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 4490 | break; |
| 4491 | } |
| 4492 | case MagickFontOptions: |
| 4493 | { |
| 4494 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 4495 | break; |
| 4496 | } |
| 4497 | case MagickFormatOptions: |
| 4498 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 4499 | break; |
| 4500 | case MagickLocaleOptions: |
| 4501 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 4502 | break; |
| 4503 | case MagickLogOptions: |
| 4504 | (void) ListLogInfo((FILE *) NULL,exception); |
| 4505 | break; |
| 4506 | case MagickMagicOptions: |
| 4507 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 4508 | break; |
| 4509 | case MagickMimeOptions: |
| 4510 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 4511 | break; |
| 4512 | case MagickModuleOptions: |
| 4513 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 4514 | break; |
| 4515 | case MagickPolicyOptions: |
| 4516 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 4517 | break; |
| 4518 | case MagickResourceOptions: |
| 4519 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 4520 | break; |
| 4521 | case MagickThresholdOptions: |
| 4522 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 4523 | break; |
| 4524 | default: |
| 4525 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
| 4526 | exception); |
| 4527 | break; |
| 4528 | } |
| 4529 | return; |
| 4530 | } |
| 4531 | |
| 4532 | #if 0 |
| 4533 | // adjust stack handling |
| 4534 | // Other 'special' options this should handle |
| 4535 | // "region" "list" "version" |
| 4536 | // It does not do "exit" however as due to its side-effect requirements |
| 4537 | #endif |
| 4538 | #if 0 |
| 4539 | if ( ( process_flags & ProcessUnknownOptionError ) != 0 ) |
| 4540 | MagickExceptionReturn(OptionError,"InvalidUseOfOption",option); |
| 4541 | #endif |
| 4542 | |
| 4543 | #undef image_info |
| 4544 | #undef images |
| 4545 | #undef exception |
| 4546 | } |