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