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