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