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