| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1 | /* | 
|  | 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 3 | %                                                                             % | 
|  | 4 | %                                                                             % | 
|  | 5 | %                                                                             % | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 6 | %          OOO   PPPP   EEEE  RRRR    AA   TTTTT  III   OOO   N   N           % | 
|  | 7 | %         O   O  P   P  E     R   R  A  A    T     I   O   O  NN  N           % | 
|  | 8 | %         O   O  PPPP   EEE   RRRR   AAAA    T     I   O   O  N N N           % | 
|  | 9 | %         O   O  P      E     R R    A  A    T     I   O   O  N  NN           % | 
|  | 10 | %          OOO   P      EEEE  R  RR  A  A    T    III   OOO   N   N           % | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 11 | %                                                                             % | 
|  | 12 | %                                                                             % | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 13 | %                         CLI Magick Option Methods                           % | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 14 | %                                                                             % | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 15 | %                              Dragon Computing                               % | 
| cristy | 9e58efd | 2012-01-30 14:27:34 +0000 | [diff] [blame] | 16 | %                              Anthony Thyssen                                % | 
| cristy | 0a0ca4f | 2011-09-28 01:15:28 +0000 | [diff] [blame] | 17 | %                               September 2011                                % | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 18 | %                                                                             % | 
|  | 19 | %                                                                             % | 
| cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame] | 20 | %  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      % | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 21 | %  dedicated to making software imaging solutions freely available.           % | 
|  | 22 | %                                                                             % | 
|  | 23 | %  You may not use this file except in compliance with the License.  You may  % | 
|  | 24 | %  obtain a copy of the License at                                            % | 
|  | 25 | %                                                                             % | 
|  | 26 | %    http://www.imagemagick.org/script/license.php                            % | 
|  | 27 | %                                                                             % | 
|  | 28 | %  Unless required by applicable law or agreed to in writing, software        % | 
|  | 29 | %  distributed under the License is distributed on an "AS IS" BASIS,          % | 
|  | 30 | %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   % | 
|  | 31 | %  See the License for the specific language governing permissions and        % | 
|  | 32 | %  limitations under the License.                                             % | 
|  | 33 | %                                                                             % | 
|  | 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 35 | % | 
|  | 36 | % Apply the given options (settings, and simple, or sequence operations) to | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 37 | % the given image(s) according to the current "image_info", "draw_info", and | 
|  | 38 | % "quantize_info" settings, stored in a special CLI Image Wand. | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 39 | % | 
|  | 40 | % The final goal is to allow the execution in a strict one option at a time | 
|  | 41 | % manner that is needed for 'pipelining and file scripting' of options in | 
|  | 42 | % IMv7. | 
|  | 43 | % | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 44 | % Anthony Thyssen, September 2011 | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 45 | */ | 
|  | 46 |  | 
|  | 47 | /* | 
|  | 48 | Include declarations. | 
|  | 49 | */ | 
|  | 50 | #include "MagickWand/studio.h" | 
|  | 51 | #include "MagickWand/MagickWand.h" | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 52 | #include "MagickWand/magick-wand-private.h" | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 53 | #include "MagickWand/operation.h" | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 54 | #include "MagickWand/operation-private.h" | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 55 | #include "MagickWand/wand.h" | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 56 | #include "MagickCore/monitor-private.h" | 
|  | 57 | #include "MagickCore/thread-private.h" | 
|  | 58 | #include "MagickCore/string-private.h" | 
|  | 59 |  | 
|  | 60 | /* | 
|  | 61 | Define declarations. | 
|  | 62 | */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 63 | #define USE_WAND_METHODS  0 | 
|  | 64 | #define MAX_STACK_DEPTH  32 | 
|  | 65 | #define UNDEFINED_COMPRESSION_QUALITY  0UL | 
|  | 66 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 67 | /* | 
|  | 68 | Constant declaration. (temporary exports) | 
|  | 69 | */ | 
|  | 70 | static const char | 
|  | 71 | BackgroundColor[] = "#fff",  /* white */ | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 72 | BorderColor[] = "#dfdfdf",  /* sRGB gray */ | 
|  | 73 | MatteColor[] = "#bdbdbd";  /* slightly darker gray */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 74 |  | 
|  | 75 | /* | 
|  | 76 | ** Function to report on the progress of image operations | 
|  | 77 | */ | 
|  | 78 | static MagickBooleanType MonitorProgress(const char *text, | 
|  | 79 | const MagickOffsetType offset,const MagickSizeType extent, | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 80 | void *wand_unused(cli_wandent_data)) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 81 | { | 
|  | 82 | char | 
|  | 83 | message[MaxTextExtent], | 
|  | 84 | tag[MaxTextExtent]; | 
|  | 85 |  | 
|  | 86 | const char | 
|  | 87 | *locale_message; | 
|  | 88 |  | 
|  | 89 | register char | 
|  | 90 | *p; | 
|  | 91 |  | 
|  | 92 | if (extent < 2) | 
|  | 93 | return(MagickTrue); | 
|  | 94 | (void) CopyMagickMemory(tag,text,MaxTextExtent); | 
|  | 95 | p=strrchr(tag,'/'); | 
|  | 96 | if (p != (char *) NULL) | 
|  | 97 | *p='\0'; | 
|  | 98 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); | 
|  | 99 | locale_message=GetLocaleMessage(message); | 
|  | 100 | if (locale_message == message) | 
|  | 101 | locale_message=tag; | 
|  | 102 | if (p == (char *) NULL) | 
|  | 103 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", | 
|  | 104 | locale_message,(long) offset,(unsigned long) extent,(long) | 
|  | 105 | (100L*offset/(extent-1))); | 
|  | 106 | else | 
|  | 107 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", | 
|  | 108 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) | 
|  | 109 | (100L*offset/(extent-1))); | 
|  | 110 | if (offset == (MagickOffsetType) (extent-1)) | 
|  | 111 | (void) FormatLocaleFile(stderr,"\n"); | 
|  | 112 | (void) fflush(stderr); | 
|  | 113 | return(MagickTrue); | 
|  | 114 | } | 
|  | 115 |  | 
|  | 116 | /* | 
|  | 117 | ** GetImageCache() will read an image into a image cache if not already | 
|  | 118 | ** present then return the image that is in the cache under that filename. | 
|  | 119 | */ | 
|  | 120 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, | 
|  | 121 | ExceptionInfo *exception) | 
|  | 122 | { | 
|  | 123 | char | 
|  | 124 | key[MaxTextExtent]; | 
|  | 125 |  | 
|  | 126 | ExceptionInfo | 
|  | 127 | *sans_exception; | 
|  | 128 |  | 
|  | 129 | Image | 
|  | 130 | *image; | 
|  | 131 |  | 
|  | 132 | ImageInfo | 
|  | 133 | *read_info; | 
|  | 134 |  | 
|  | 135 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); | 
|  | 136 | sans_exception=AcquireExceptionInfo(); | 
|  | 137 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); | 
|  | 138 | sans_exception=DestroyExceptionInfo(sans_exception); | 
|  | 139 | if (image != (Image *) NULL) | 
|  | 140 | return(image); | 
|  | 141 | read_info=CloneImageInfo(image_info); | 
|  | 142 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); | 
|  | 143 | image=ReadImage(read_info,exception); | 
|  | 144 | read_info=DestroyImageInfo(read_info); | 
|  | 145 | if (image != (Image *) NULL) | 
|  | 146 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); | 
|  | 147 | return(image); | 
|  | 148 | } | 
|  | 149 |  | 
|  | 150 | /* | 
| anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 151 | SparseColorOption() parse the complex -sparse-color argument into an | 
|  | 152 | an array of floating point values than call SparseColorImage(). | 
|  | 153 | Argument is a complex mix of floating-point pixel coodinates, and color | 
|  | 154 | specifications (or direct floating point numbers).  The number of floats | 
|  | 155 | needed to represent a color varies depending on teh current channel | 
|  | 156 | setting. | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 157 |  | 
|  | 158 | This really should be in MagickCore, so that other API's can make use of it. | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 159 | */ | 
|  | 160 | static Image *SparseColorOption(const Image *image, | 
|  | 161 | const SparseColorMethod method,const char *arguments, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 162 | ExceptionInfo *exception) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 163 | { | 
|  | 164 | char | 
|  | 165 | token[MaxTextExtent]; | 
|  | 166 |  | 
|  | 167 | const char | 
|  | 168 | *p; | 
|  | 169 |  | 
|  | 170 | double | 
|  | 171 | *sparse_arguments; | 
|  | 172 |  | 
|  | 173 | Image | 
|  | 174 | *sparse_image; | 
|  | 175 |  | 
|  | 176 | PixelInfo | 
|  | 177 | color; | 
|  | 178 |  | 
|  | 179 | MagickBooleanType | 
|  | 180 | error; | 
|  | 181 |  | 
|  | 182 | register size_t | 
|  | 183 | x; | 
|  | 184 |  | 
|  | 185 | size_t | 
|  | 186 | number_arguments, | 
|  | 187 | number_colors; | 
|  | 188 |  | 
|  | 189 | assert(image != (Image *) NULL); | 
|  | 190 | assert(image->signature == MagickSignature); | 
|  | 191 | if (image->debug != MagickFalse) | 
|  | 192 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); | 
|  | 193 | assert(exception != (ExceptionInfo *) NULL); | 
|  | 194 | assert(exception->signature == MagickSignature); | 
|  | 195 | /* | 
|  | 196 | Limit channels according to image - and add up number of color channel. | 
|  | 197 | */ | 
|  | 198 | number_colors=0; | 
|  | 199 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) | 
|  | 200 | number_colors++; | 
|  | 201 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) | 
|  | 202 | number_colors++; | 
|  | 203 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) | 
|  | 204 | number_colors++; | 
|  | 205 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && | 
|  | 206 | (image->colorspace == CMYKColorspace)) | 
|  | 207 | number_colors++; | 
|  | 208 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && | 
|  | 209 | (image->matte != MagickFalse)) | 
|  | 210 | number_colors++; | 
|  | 211 |  | 
|  | 212 | /* | 
|  | 213 | Read string, to determine number of arguments needed, | 
|  | 214 | */ | 
|  | 215 | p=arguments; | 
|  | 216 | x=0; | 
|  | 217 | while( *p != '\0' ) | 
|  | 218 | { | 
|  | 219 | GetMagickToken(p,&p,token); | 
|  | 220 | if ( token[0] == ',' ) continue; | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 221 | if ( isalpha((int) token[0]) || token[0] == '#' ) | 
|  | 222 | x += number_colors;  /* color argument found */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 223 | else { | 
|  | 224 | x++;   /* floating point argument */ | 
|  | 225 | } | 
|  | 226 | } | 
|  | 227 | error=MagickTrue; | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 228 | /* control points and color values */ | 
|  | 229 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; | 
|  | 230 | number_arguments=x; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 231 | if ( error ) { | 
|  | 232 | (void) ThrowMagickException(exception,GetMagickModule(), | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 233 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 234 | "Invalid number of Arguments"); | 
|  | 235 | return( (Image *)NULL); | 
|  | 236 | } | 
|  | 237 |  | 
|  | 238 | /* Allocate and fill in the floating point arguments */ | 
|  | 239 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, | 
|  | 240 | sizeof(*sparse_arguments)); | 
|  | 241 | if (sparse_arguments == (double *) NULL) { | 
|  | 242 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, | 
|  | 243 | "MemoryAllocationFailed","%s","SparseColorOption"); | 
|  | 244 | return( (Image *)NULL); | 
|  | 245 | } | 
|  | 246 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* | 
|  | 247 | sizeof(*sparse_arguments)); | 
|  | 248 | p=arguments; | 
|  | 249 | x=0; | 
|  | 250 | while( *p != '\0' && x < number_arguments ) { | 
|  | 251 | /* X coordinate */ | 
|  | 252 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
|  | 253 | if ( token[0] == '\0' ) break; | 
|  | 254 | if ( isalpha((int) token[0]) || token[0] == '#' ) { | 
|  | 255 | (void) ThrowMagickException(exception,GetMagickModule(), | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 256 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 257 | "Color found, instead of X-coord"); | 
|  | 258 | error = MagickTrue; | 
|  | 259 | break; | 
|  | 260 | } | 
| cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 261 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 262 | /* Y coordinate */ | 
|  | 263 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
|  | 264 | if ( token[0] == '\0' ) break; | 
|  | 265 | if ( isalpha((int) token[0]) || token[0] == '#' ) { | 
|  | 266 | (void) ThrowMagickException(exception,GetMagickModule(), | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 267 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 268 | "Color found, instead of Y-coord"); | 
|  | 269 | error = MagickTrue; | 
|  | 270 | break; | 
|  | 271 | } | 
| cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 272 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 273 | /* color name or function given in string argument */ | 
|  | 274 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
|  | 275 | if ( token[0] == '\0' ) break; | 
|  | 276 | if ( isalpha((int) token[0]) || token[0] == '#' ) { | 
|  | 277 | /* Color string given */ | 
|  | 278 | (void) QueryColorCompliance(token,AllCompliance,&color, | 
|  | 279 | exception); | 
|  | 280 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) | 
|  | 281 | sparse_arguments[x++] = QuantumScale*color.red; | 
|  | 282 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) | 
|  | 283 | sparse_arguments[x++] = QuantumScale*color.green; | 
|  | 284 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) | 
|  | 285 | sparse_arguments[x++] = QuantumScale*color.blue; | 
|  | 286 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && | 
|  | 287 | (image->colorspace == CMYKColorspace)) | 
|  | 288 | sparse_arguments[x++] = QuantumScale*color.black; | 
|  | 289 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && | 
|  | 290 | (image->matte != MagickFalse)) | 
|  | 291 | sparse_arguments[x++] = QuantumScale*color.alpha; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 292 | } | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 293 | else { | 
|  | 294 | /* Colors given as a set of floating point values - experimental */ | 
|  | 295 | /* NB: token contains the first floating point value to use! */ | 
|  | 296 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) | 
|  | 297 | { | 
|  | 298 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
|  | 299 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
|  | 300 | break; | 
|  | 301 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); | 
|  | 302 | token[0] = ','; /* used this token - get another */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 303 | } | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 304 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) | 
|  | 305 | { | 
|  | 306 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
|  | 307 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
|  | 308 | break; | 
|  | 309 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); | 
|  | 310 | token[0] = ','; /* used this token - get another */ | 
|  | 311 | } | 
|  | 312 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) | 
|  | 313 | { | 
|  | 314 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
|  | 315 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
|  | 316 | break; | 
|  | 317 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); | 
|  | 318 | token[0] = ','; /* used this token - get another */ | 
|  | 319 | } | 
|  | 320 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && | 
|  | 321 | (image->colorspace == CMYKColorspace)) | 
|  | 322 | { | 
|  | 323 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
|  | 324 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
|  | 325 | break; | 
|  | 326 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); | 
|  | 327 | token[0] = ','; /* used this token - get another */ | 
|  | 328 | } | 
|  | 329 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && | 
|  | 330 | (image->matte != MagickFalse)) | 
|  | 331 | { | 
|  | 332 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
|  | 333 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
|  | 334 | break; | 
|  | 335 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); | 
|  | 336 | token[0] = ','; /* used this token - get another */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 337 | } | 
|  | 338 | } | 
|  | 339 | } | 
|  | 340 | if ( number_arguments != x && !error ) { | 
|  | 341 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 342 | "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 343 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); | 
|  | 344 | return( (Image *)NULL); | 
|  | 345 | } | 
|  | 346 | if ( error ) | 
|  | 347 | return( (Image *)NULL); | 
|  | 348 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 349 | /* Call the Sparse Color Interpolation function with the parsed arguments */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 350 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, | 
|  | 351 | exception); | 
|  | 352 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); | 
|  | 353 | return( sparse_image ); | 
|  | 354 | } | 
|  | 355 |  | 
|  | 356 | /* | 
|  | 357 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 358 | %                                                                             % | 
|  | 359 | %                                                                             % | 
|  | 360 | %                                                                             % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 361 | +   A c q u i r e W a n d C L I                                               % | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 362 | %                                                                             % | 
|  | 363 | %                                                                             % | 
|  | 364 | %                                                                             % | 
|  | 365 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 366 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 367 | %  AcquireMagickCLI() creates a new CLI wand (an expanded form of Magick | 
|  | 368 | %  Wand). The given image_info and exception is included as is if provided. | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 369 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 370 | %  Use DestroyMagickCLI() to dispose of the CLI wand when it is no longer | 
|  | 371 | %  needed. | 
|  | 372 | % | 
|  | 373 | %  The format of the NewMagickWand method is: | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 374 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 375 | %      MagickCLI *AcquireMagickCLI(ImageInfo *image_info, | 
|  | 376 | %           ExceptionInfo *exception) | 
|  | 377 | % | 
|  | 378 | */ | 
|  | 379 | WandExport MagickCLI *AcquireMagickCLI(ImageInfo *image_info, | 
|  | 380 | ExceptionInfo *exception) | 
|  | 381 | { | 
|  | 382 | MagickCLI | 
|  | 383 | *cli_wand; | 
|  | 384 |  | 
|  | 385 | /* precaution - as per NewMagickWand() */ | 
|  | 386 | { | 
|  | 387 | size_t depth = MAGICKCORE_QUANTUM_DEPTH; | 
|  | 388 | const char *quantum = GetMagickQuantumDepth(&depth); | 
|  | 389 | if (depth != MAGICKCORE_QUANTUM_DEPTH) | 
|  | 390 | ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); | 
|  | 391 | } | 
|  | 392 |  | 
|  | 393 | /* allocate memory for MgaickCLI */ | 
|  | 394 | cli_wand=(MagickCLI *) AcquireMagickMemory(sizeof(*cli_wand)); | 
|  | 395 | if (cli_wand == (MagickCLI *) NULL) | 
|  | 396 | { | 
|  | 397 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", | 
|  | 398 | GetExceptionMessage(errno)); | 
|  | 399 | return((MagickCLI *)NULL); | 
|  | 400 | } | 
|  | 401 |  | 
|  | 402 | /* Initialize Wand Part of MagickCLI | 
|  | 403 | FUTURE: this is a repeat of code from NewMagickWand() | 
|  | 404 | However some parts may be given fro man external source! | 
|  | 405 | */ | 
|  | 406 | cli_wand->wand.id=AcquireWandId(); | 
|  | 407 | (void) FormatLocaleString(cli_wand->wand.name,MaxTextExtent, | 
|  | 408 | "%s-%.20g","MagickWandCLI", (double) cli_wand->wand.id); | 
|  | 409 | cli_wand->wand.images=NewImageList(); | 
|  | 410 | if ( image_info == (ImageInfo *)NULL) | 
|  | 411 | cli_wand->wand.image_info=AcquireImageInfo(); | 
|  | 412 | else | 
|  | 413 | cli_wand->wand.image_info=image_info; | 
|  | 414 | if ( exception == (ExceptionInfo *)NULL) | 
|  | 415 | cli_wand->wand.exception=AcquireExceptionInfo(); | 
|  | 416 | else | 
|  | 417 | cli_wand->wand.exception=exception; | 
|  | 418 | cli_wand->wand.debug=IsEventLogging(); | 
|  | 419 | cli_wand->wand.signature=WandSignature; | 
|  | 420 |  | 
|  | 421 | /* Initialize CLI Part of MagickCLI */ | 
|  | 422 | cli_wand->draw_info=CloneDrawInfo(cli_wand->wand.image_info,(DrawInfo *) NULL); | 
|  | 423 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); | 
|  | 424 | cli_wand->image_list_stack=(Stack *)NULL; | 
|  | 425 | cli_wand->image_info_stack=(Stack *)NULL; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 426 | cli_wand->location="'%s' at unknown"; | 
|  | 427 | cli_wand->location2="'%s' '%s' at unknown"; | 
| anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 428 | cli_wand->filename=cli_wand->wand.name; | 
| anthony | 1cdc5b7 | 2012-03-03 02:31:18 +0000 | [diff] [blame] | 429 | cli_wand->line=0; | 
|  | 430 | cli_wand->column=0; | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 431 | cli_wand->signature=WandSignature; | 
|  | 432 |  | 
|  | 433 | if (cli_wand->wand.debug != MagickFalse) | 
|  | 434 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); | 
|  | 435 | return(cli_wand); | 
|  | 436 | } | 
|  | 437 |  | 
|  | 438 | /* | 
|  | 439 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 440 | %                                                                             % | 
|  | 441 | %                                                                             % | 
|  | 442 | %                                                                             % | 
|  | 443 | +   D e s t r o y W a n d C L I                                               % | 
|  | 444 | %                                                                             % | 
|  | 445 | %                                                                             % | 
|  | 446 | %                                                                             % | 
|  | 447 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 448 | % | 
|  | 449 | %  DestroyMagickCLI() destorys everything in a CLI wand, including image_info | 
|  | 450 | %  and any exceptions, if still present in the wand. | 
|  | 451 | % | 
|  | 452 | %  The format of the NewMagickWand method is: | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 453 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 454 | %    MagickWand *DestroyMagickCLI() | 
|  | 455 | %            Exception *exception) | 
|  | 456 | % | 
|  | 457 | */ | 
|  | 458 | WandExport MagickCLI *DestroyMagickCLI(MagickCLI *cli_wand) | 
|  | 459 | { | 
|  | 460 | Stack | 
|  | 461 | *node; | 
|  | 462 |  | 
|  | 463 | assert(cli_wand != (MagickCLI *) NULL); | 
|  | 464 | assert(cli_wand->signature == WandSignature); | 
|  | 465 | assert(cli_wand->wand.signature == WandSignature); | 
|  | 466 | if (cli_wand->wand.debug != MagickFalse) | 
|  | 467 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); | 
|  | 468 |  | 
|  | 469 | /* Destroy CLI part of MagickCLI */ | 
|  | 470 | if (cli_wand->draw_info != (DrawInfo *) NULL ) | 
|  | 471 | cli_wand->draw_info=DestroyDrawInfo(cli_wand->draw_info); | 
|  | 472 | if (cli_wand->quantize_info != (QuantizeInfo *) NULL ) | 
|  | 473 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); | 
|  | 474 | while(cli_wand->image_list_stack != (Stack *)NULL) | 
|  | 475 | { | 
|  | 476 | node=cli_wand->image_list_stack; | 
|  | 477 | cli_wand->image_list_stack=node->next; | 
|  | 478 | (void) DestroyImageList((Image *)node->data); | 
|  | 479 | (void) RelinquishMagickMemory(node); | 
|  | 480 | } | 
|  | 481 | while(cli_wand->image_info_stack != (Stack *)NULL) | 
|  | 482 | { | 
|  | 483 | node=cli_wand->image_info_stack; | 
|  | 484 | cli_wand->image_info_stack=node->next; | 
|  | 485 | (void) DestroyImageInfo((ImageInfo *)node->data); | 
|  | 486 | (void) RelinquishMagickMemory(node); | 
|  | 487 | } | 
|  | 488 | cli_wand->signature=(~WandSignature); | 
|  | 489 |  | 
|  | 490 | /* Destroy Wand part MagickCLI */ | 
|  | 491 | cli_wand->wand.images=DestroyImageList(cli_wand->wand.images); | 
|  | 492 | if (cli_wand->wand.image_info != (ImageInfo *) NULL ) | 
|  | 493 | cli_wand->wand.image_info=DestroyImageInfo(cli_wand->wand.image_info); | 
|  | 494 | if (cli_wand->wand.exception != (ExceptionInfo *) NULL ) | 
|  | 495 | cli_wand->wand.exception=DestroyExceptionInfo(cli_wand->wand.exception); | 
|  | 496 | RelinquishWandId(cli_wand->wand.id); | 
|  | 497 | cli_wand->wand.signature=(~WandSignature); | 
|  | 498 |  | 
|  | 499 | return((MagickCLI *)NULL); | 
|  | 500 | } | 
|  | 501 |  | 
|  | 502 | /* | 
|  | 503 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 504 | %                                                                             % | 
|  | 505 | %                                                                             % | 
|  | 506 | %                                                                             % | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 507 | +   C L I C a t c h E x c e p t i o n                                         % | 
|  | 508 | %                                                                             % | 
|  | 509 | %                                                                             % | 
|  | 510 | %                                                                             % | 
|  | 511 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 512 | % | 
|  | 513 | %  CLICatchException() will report exceptions, either just non-fatal warnings | 
|  | 514 | %  only, or all errors, according to 'all_execeptions' boolean argument. | 
|  | 515 | % | 
|  | 516 | %  The function returns true is errors are fatal, in which case the caller | 
|  | 517 | %  should abort and re-call with an 'all_exceptions' argument of true before | 
|  | 518 | %  quitting. | 
|  | 519 | % | 
|  | 520 | %  The cut-off level between fatal and non-fatal may be controlled by options | 
|  | 521 | %  (FUTURE), but defaults to 'Error' exceptions. | 
|  | 522 | % | 
|  | 523 | %  The format of the CLICatchException method is: | 
|  | 524 | % | 
|  | 525 | %    MagickBooleanType CLICatchException(MagickCLI *cli_wand, | 
|  | 526 | %              const MagickBooleanType all_exceptions ); | 
|  | 527 | % | 
|  | 528 | */ | 
|  | 529 | WandExport MagickBooleanType CLICatchException(MagickCLI *cli_wand, | 
|  | 530 | const MagickBooleanType all_exceptions ) | 
|  | 531 | { | 
|  | 532 | MagickBooleanType | 
|  | 533 | status; | 
|  | 534 | assert(cli_wand != (MagickCLI *) NULL); | 
|  | 535 | assert(cli_wand->signature == WandSignature); | 
|  | 536 | assert(cli_wand->wand.signature == WandSignature); | 
|  | 537 | if (cli_wand->wand.debug != MagickFalse) | 
|  | 538 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); | 
|  | 539 |  | 
|  | 540 | // FUTURE: '-regard_warning' should make this more sensitive. | 
|  | 541 | // Note pipelined options may like more control over this level | 
|  | 542 |  | 
|  | 543 | status = MagickFalse; | 
|  | 544 | if (cli_wand->wand.exception->severity > ErrorException) | 
|  | 545 | status = MagickTrue; | 
|  | 546 |  | 
|  | 547 | if ( status == MagickFalse || all_exceptions != MagickFalse ) | 
|  | 548 | CatchException(cli_wand->wand.exception); /* output and clear exceptions */ | 
|  | 549 |  | 
|  | 550 | return(status); | 
|  | 551 | } | 
|  | 552 |  | 
|  | 553 | /* | 
|  | 554 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 555 | %                                                                             % | 
|  | 556 | %                                                                             % | 
|  | 557 | %                                                                             % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 558 | +   C L I S e t t i n g O p t i o n I n f o                                   % | 
|  | 559 | %                                                                             % | 
|  | 560 | %                                                                             % | 
|  | 561 | %                                                                             % | 
|  | 562 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 563 | % | 
|  | 564 | %  CLISettingOptionInfo() applies a single settings option into a CLI wand | 
|  | 565 | %  holding the image_info, draw_info, quantize_info structures that will be | 
|  | 566 | %  used when processing the images. | 
|  | 567 | % | 
|  | 568 | %  These options do no require images to be present in the CLI wand for them | 
|  | 569 | %  to be able to be set, in which case they will generally be applied to image | 
|  | 570 | %  that are read in later | 
| anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 571 | % | 
|  | 572 | %  Options handled by this function are listed in CommandOptions[] of | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 573 | %  "option.c" that is one of "SettingOptionFlags" option flags. | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 574 | % | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 575 | %  The format of the CLISettingOptionInfo method is: | 
| anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 576 | % | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 577 | %    void CLISettingOptionInfo(MagickCLI *cli_wand, | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 578 | %               const char *option, const char *arg1) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 579 | % | 
|  | 580 | %  A description of each parameter follows: | 
|  | 581 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 582 | %    o cli_wand: structure holding settings to be applied | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 583 | % | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 584 | %    o option: The option string to be set | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 585 | % | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 586 | %    o arg1: The single argument used to set this option. | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 587 | % | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 588 | % Example usage... | 
|  | 589 | % | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 590 | %    CLISettingOptionInfo(cli_wand, "-background", "Red");  // set value | 
|  | 591 | %    CLISettingOptionInfo(cli_wand, "-adjoin", NULL);       // set boolean | 
|  | 592 | %    CLISettingOptionInfo(cli_wand, "+adjoin", NULL);       // unset | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 593 | % | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 594 | % Or for handling command line arguments EG: +/-option ["arg1"] | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 595 | % | 
|  | 596 | %    argc,argv | 
|  | 597 | %    i=index in argv | 
|  | 598 | % | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 599 | %    option_info = GetCommandOptionInfo(argv[i]); | 
|  | 600 | %    count=option_info->type; | 
|  | 601 | %    option_type=option_info->flags; | 
|  | 602 | % | 
|  | 603 | %    if ( (option_type & SettingOperatorOptionFlags) != 0 ) | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 604 | %      CLISettingOptionInfo(cli_wand, argv[i], | 
|  | 605 | %                   (count>0) ? argv[i+1] : (char *)NULL); | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 606 | %    i += count+1; | 
|  | 607 | % | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 608 | */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 609 | WandExport void CLISettingOptionInfo(MagickCLI *cli_wand, | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 610 | const char *option,const char *arg1) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 611 | { | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 612 | assert(cli_wand != (MagickCLI *) NULL); | 
|  | 613 | assert(cli_wand->signature == WandSignature); | 
|  | 614 | assert(cli_wand->wand.signature == WandSignature); | 
|  | 615 | if (cli_wand->wand.debug != MagickFalse) | 
|  | 616 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); | 
| anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 617 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 618 | #define _image_info        (cli_wand->wand.image_info) | 
|  | 619 | #define _exception         (cli_wand->wand.exception) | 
|  | 620 | #define _draw_info         (cli_wand->draw_info) | 
|  | 621 | #define _quantize_info     (cli_wand->quantize_info) | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 622 | #define IfSetOption       (*option=='-') | 
|  | 623 | #define ArgBoolean        (IfSetOption?MagickTrue:MagickFalse) | 
|  | 624 | #define ArgBooleanNot     (IfSetOption?MagickFalse:MagickTrue) | 
|  | 625 | #define ArgBooleanString  (IfSetOption?"true":"false") | 
|  | 626 | #define ArgOption(def)    (IfSetOption?arg1:(const char *)(def)) | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 627 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 628 | switch (*(option+1)) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 629 | { | 
|  | 630 | case 'a': | 
|  | 631 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 632 | if (LocaleCompare("adjoin",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 633 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 634 | _image_info->adjoin = ArgBoolean; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 635 | break; | 
|  | 636 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 637 | if (LocaleCompare("affine",option+1) == 0) | 
| anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 638 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 639 | /* DEPRECIATED: _draw_info setting only: for -draw and -transform */ | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 640 | if (IfSetOption) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 641 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 642 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 643 | GetAffineMatrix(&_draw_info->affine); | 
| anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 644 | break; | 
|  | 645 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 646 | if (LocaleCompare("antialias",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 647 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 648 | _image_info->antialias = | 
|  | 649 | _draw_info->stroke_antialias = | 
|  | 650 | _draw_info->text_antialias = ArgBoolean; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 651 | break; | 
|  | 652 | } | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 653 | if (LocaleCompare("attenuate",option+1) == 0) | 
|  | 654 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 655 | if (IfSetOption && IsGeometry(arg1) == MagickFalse) | 
|  | 656 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); | 
|  | 657 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 658 | break; | 
|  | 659 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 660 | if (LocaleCompare("authenticate",option+1) == 0) | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 661 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 662 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 663 | break; | 
|  | 664 | } | 
|  | 665 | break; | 
|  | 666 | } | 
|  | 667 | case 'b': | 
|  | 668 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 669 | if (LocaleCompare("background",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 670 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 671 | /* FUTURE: both _image_info attribute & ImageOption in use! | 
|  | 672 | _image_info only used directly for generating new images. | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 673 | SyncImageSettings() used to set per-image attribute. | 
|  | 674 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 675 | FUTURE: if _image_info->background_color is not set then | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 676 | we should fall back to image | 
|  | 677 | Note that +background, means fall-back to image background | 
|  | 678 | and only if not set fall back to BackgroundColor const. | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 679 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 680 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 681 | (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 682 | &_image_info->background_color,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 683 | break; | 
|  | 684 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 685 | if (LocaleCompare("bias",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 686 | { | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 687 | /* FUTURE: bias OBSOLETED, replaced by "convolve:bias" | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 688 | as it is actually rarely used except in direct convolve operations | 
|  | 689 | Usage outside a direct convolve operation is actally non-sensible! | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 690 |  | 
|  | 691 | SyncImageSettings() used to set per-image attribute. | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 692 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 693 | (void) SetImageOption(_image_info,option+1,ArgOption("0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 694 | break; | 
|  | 695 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 696 | if (LocaleCompare("black-point-compensation",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 697 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 698 | /* Used as a image chromaticity setting | 
|  | 699 | SyncImageSettings() used to set per-image attribute. | 
|  | 700 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 701 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 702 | break; | 
|  | 703 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 704 | if (LocaleCompare("blue-primary",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 705 | { | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 706 | /* Image chromaticity X,Y  NB: Y=X if Y not defined | 
|  | 707 | Used by many coders including PNG | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 708 | SyncImageSettings() used to set per-image attribute. | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 709 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 710 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 711 | break; | 
|  | 712 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 713 | if (LocaleCompare("bordercolor",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 714 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 715 | /* FUTURE: both _image_info attribute & ImageOption in use! | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 716 | SyncImageSettings() used to set per-image attribute. | 
|  | 717 | */ | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 718 | if (IfSetOption) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 719 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 720 | (void) SetImageOption(_image_info,option+1,arg1); | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 721 | (void) QueryColorCompliance(arg1,AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 722 | &_image_info->border_color,_exception); | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 723 | (void) QueryColorCompliance(arg1,AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 724 | &_draw_info->border_color,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 725 | break; | 
|  | 726 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 727 | (void) DeleteImageOption(_image_info,option+1); | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 728 | (void) QueryColorCompliance(BorderColor,AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 729 | &_image_info->border_color,_exception); | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 730 | (void) QueryColorCompliance(BorderColor,AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 731 | &_draw_info->border_color,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 732 | break; | 
|  | 733 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 734 | if (LocaleCompare("box",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 735 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 736 | /* DEPRECIATED - now "undercolor" */ | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 737 | CLISettingOptionInfo(cli_wand,"undercolor",arg1); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 738 | break; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 739 | } | 
|  | 740 | break; | 
|  | 741 | } | 
|  | 742 | case 'c': | 
|  | 743 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 744 | if (LocaleCompare("cache",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 745 | { | 
|  | 746 | MagickSizeType | 
|  | 747 | limit; | 
|  | 748 |  | 
|  | 749 | limit=MagickResourceInfinity; | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 750 | if (LocaleCompare("unlimited",arg1) != 0) | 
|  | 751 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 752 | (void) SetMagickResourceLimit(MemoryResource,limit); | 
|  | 753 | (void) SetMagickResourceLimit(MapResource,2*limit); | 
|  | 754 | break; | 
|  | 755 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 756 | if (LocaleCompare("caption",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 757 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 758 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 759 | break; | 
|  | 760 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 761 | if (LocaleCompare("channel",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 762 | { | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 763 | /* FUTURE:  -channel mask {vaules} | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 764 | This is also applied to images in SimpleImageOperator!!! | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 765 | Move it to SyncImageSettings() - or alternative | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 766 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 767 | _image_info->channel=(ChannelType) ( | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 768 | IfSetOption ? ParseChannelOption(arg1) : DefaultChannels ); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 769 | break; | 
|  | 770 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 771 | if (LocaleCompare("colorspace",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 772 | { | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 773 | /* Setting used for new images via AquireImage() | 
|  | 774 | But also used as a SimpleImageOperator | 
|  | 775 | Undefined colorspace means don't modify images on | 
|  | 776 | read or as a operation */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 777 | _image_info->colorspace=(ColorspaceType) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 778 | MagickColorspaceOptions,MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 779 | break; | 
|  | 780 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 781 | if (LocaleCompare("comment",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 782 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 783 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 784 | break; | 
|  | 785 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 786 | if (LocaleCompare("compose",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 787 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 788 | /* FUTURE: _image_info should be used, | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 789 | SyncImageSettings() used to set per-image attribute. - REMOVE | 
|  | 790 |  | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 791 | This setting should NOT be used to set image 'compose' | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 792 | "-layer" operators shoud use _image_info if defined otherwise | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 793 | they should use a per-image compose setting. | 
| anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 794 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 795 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 796 | _image_info->compose=(CompositeOperator) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 797 | MagickComposeOptions,MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 798 | break; | 
|  | 799 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 800 | if (LocaleCompare("compress",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 801 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 802 | /* FUTURE: What should be used?  _image_info  or ImageOption ??? | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 803 | The former is more efficent, but Crisy prefers the latter! | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 804 | SyncImageSettings() used to set per-image attribute. | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 805 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 806 | The coders appears to use _image_info, not Image_Option | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 807 | however the image attribute (for save) is set from the | 
|  | 808 | ImageOption! | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 809 |  | 
|  | 810 | Note that "undefined" is a different setting to "none". | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 811 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 812 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 813 | _image_info->compression=(CompressionType) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 814 | MagickCompressOptions,MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 815 | break; | 
|  | 816 | } | 
|  | 817 | break; | 
|  | 818 | } | 
|  | 819 | case 'd': | 
|  | 820 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 821 | if (LocaleCompare("debug",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 822 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 823 | /* SyncImageSettings() used to set per-image attribute. */ | 
|  | 824 | (void) SetLogEventMask(ArgOption("none")); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 825 | _image_info->debug=IsEventLogging(); /* extract logging*/ | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 826 | cli_wand->wand.debug=IsEventLogging(); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 827 | break; | 
|  | 828 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 829 | if (LocaleCompare("define",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 830 | { | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 831 | if (LocaleNCompare(arg1,"registry:",9) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 832 | { | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 833 | if (IfSetOption) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 834 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 835 | else | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 836 | (void) DeleteImageRegistry(arg1+9); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 837 | break; | 
|  | 838 | } | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 839 | /* DefineImageOption() equals SetImageOption() but with '=' */ | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 840 | if (IfSetOption) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 841 | (void) DefineImageOption(_image_info,arg1); | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 842 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 843 | (void) DeleteImageOption(_image_info,arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 844 | break; | 
|  | 845 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 846 | if (LocaleCompare("delay",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 847 | { | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 848 | /* Only used for new images via AcquireImage() | 
|  | 849 | FUTURE: Option should also be used for "-morph" (color morphing) | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 850 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 851 | (void) SetImageOption(_image_info,option+1,ArgOption("0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 852 | break; | 
|  | 853 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 854 | if (LocaleCompare("density",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 855 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 856 | /* FUTURE: strings used in _image_info attr and _draw_info! | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 857 | Basically as density can be in a XxY form! | 
|  | 858 |  | 
|  | 859 | SyncImageSettings() used to set per-image attribute. | 
|  | 860 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 861 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 862 | (void) CloneString(&_image_info->density,ArgOption(NULL)); | 
|  | 863 | (void) CloneString(&_draw_info->density,_image_info->density); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 864 | break; | 
|  | 865 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 866 | if (LocaleCompare("depth",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 867 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 868 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! | 
|  | 869 | SyncImageSettings() used to set per-image attribute. | 
|  | 870 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 871 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 872 | :MAGICKCORE_QUANTUM_DEPTH; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 873 | break; | 
|  | 874 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 875 | if (LocaleCompare("direction",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 876 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 877 | /* Image Option is only used to set _draw_info */ | 
|  | 878 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); | 
|  | 879 | _draw_info->direction=(DirectionType) ParseCommandOption( | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 880 | MagickDirectionOptions,MagickFalse, | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 881 | ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 882 | break; | 
|  | 883 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 884 | if (LocaleCompare("display",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 885 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 886 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); | 
|  | 887 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 888 | break; | 
|  | 889 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 890 | if (LocaleCompare("dispose",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 891 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 892 | /* only used in setting new images */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 893 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 894 | break; | 
|  | 895 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 896 | if (LocaleCompare("dither",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 897 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 898 | /* _image_info attr (on/off), _quantize_info attr (on/off) | 
|  | 899 | but also ImageInfo and _quantize_info method! | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 900 | FUTURE: merge the duality of the dithering options | 
|  | 901 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 902 | _image_info->dither = _quantize_info->dither = ArgBoolean; | 
|  | 903 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); | 
|  | 904 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 905 | MagickDitherOptions,MagickFalse,ArgOption("none")); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 906 | if (_quantize_info->dither_method == NoDitherMethod) | 
|  | 907 | _image_info->dither = _quantize_info->dither = MagickFalse; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 908 | break; | 
|  | 909 | } | 
|  | 910 | break; | 
|  | 911 | } | 
|  | 912 | case 'e': | 
|  | 913 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 914 | if (LocaleCompare("encoding",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 915 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 916 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); | 
|  | 917 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 918 | break; | 
|  | 919 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 920 | if (LocaleCompare("endian",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 921 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 922 | /* Both _image_info attr and ImageInfo */ | 
|  | 923 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); | 
|  | 924 | _image_info->endian=(EndianType) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 925 | MagickEndianOptions,MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 926 | break; | 
|  | 927 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 928 | if (LocaleCompare("extract",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 929 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 930 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 931 | break; | 
|  | 932 | } | 
|  | 933 | break; | 
|  | 934 | } | 
|  | 935 | case 'f': | 
|  | 936 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 937 | if (LocaleCompare("family",option+1) == 0) | 
| anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 938 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 939 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); | 
| anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 940 | break; | 
|  | 941 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 942 | if (LocaleCompare("fill",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 943 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 944 | /* Set "fill" OR "fill-pattern" in _draw_info | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 945 | The original fill color is preserved if a fill-pattern is given. | 
|  | 946 | That way it does not effect other operations that directly using | 
|  | 947 | the fill color and, can be retored using "+tile". | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 948 | */ | 
| anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 949 | const char | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 950 | *value; | 
|  | 951 |  | 
|  | 952 | MagickBooleanType | 
|  | 953 | status; | 
| anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 954 |  | 
|  | 955 | ExceptionInfo | 
|  | 956 | *sans; | 
|  | 957 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 958 | PixelInfo | 
|  | 959 | color; | 
|  | 960 |  | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 961 | value = ArgOption("none"); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 962 | (void) SetImageOption(_image_info,option+1,value); | 
|  | 963 | if (_draw_info->fill_pattern != (Image *) NULL) | 
|  | 964 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 965 |  | 
|  | 966 | /* is it a color or a image? -- ignore exceptions */ | 
|  | 967 | sans=AcquireExceptionInfo(); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 968 | status=QueryColorCompliance(value,AllCompliance,&color,sans); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 969 | sans=DestroyExceptionInfo(sans); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 970 |  | 
| anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 971 | if (status == MagickFalse) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 972 | _draw_info->fill_pattern=GetImageCache(_image_info,value,_exception); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 973 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 974 | _draw_info->fill=color; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 975 | break; | 
|  | 976 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 977 | if (LocaleCompare("filter",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 978 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 979 | /* SyncImageSettings() used to set per-image attribute. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 980 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 981 | break; | 
|  | 982 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 983 | if (LocaleCompare("font",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 984 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 985 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); | 
|  | 986 | (void) CloneString(&_image_info->font,_draw_info->font); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 987 | break; | 
|  | 988 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 989 | if (LocaleCompare("format",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 990 | { | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 991 | /* FUTURE: why the ping test, you could set ping after this! */ | 
|  | 992 | /* | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 993 | register const char | 
|  | 994 | *q; | 
|  | 995 |  | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 996 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 997 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 998 | _image_info->ping=MagickFalse; | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 999 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1000 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1001 | break; | 
|  | 1002 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1003 | if (LocaleCompare("fuzz",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1004 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1005 | /* Option used to set image fuzz! unless blank canvas (from color) | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1006 | Image attribute used for color compare operations | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1007 | SyncImageSettings() used to set per-image attribute. | 
|  | 1008 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1009 | Can't find anything else using _image_info->fuzz directly! | 
| anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 1010 | */ | 
|  | 1011 | if (IfSetOption) | 
| cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 1012 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1013 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) | 
| anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 1014 | QuantumRange+1.0); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1015 | (void) SetImageOption(_image_info,option+1,arg1); | 
| cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 1016 | break; | 
|  | 1017 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1018 | _image_info->fuzz=0.0; | 
|  | 1019 | (void) SetImageOption(_image_info,option+1,"0"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1020 | break; | 
|  | 1021 | } | 
|  | 1022 | break; | 
|  | 1023 | } | 
|  | 1024 | case 'g': | 
|  | 1025 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1026 | if (LocaleCompare("gravity",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1027 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1028 | /* SyncImageSettings() used to set per-image attribute. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1029 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); | 
|  | 1030 | _draw_info->gravity=(GravityType) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1031 | MagickGravityOptions,MagickFalse,ArgOption("none")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1032 | break; | 
|  | 1033 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1034 | if (LocaleCompare("green-primary",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1035 | { | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1036 | /* Image chromaticity X,Y  NB: Y=X if Y not defined | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1037 | SyncImageSettings() used to set per-image attribute. | 
|  | 1038 | Used directly by many coders | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1039 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1040 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1041 | break; | 
|  | 1042 | } | 
|  | 1043 | break; | 
|  | 1044 | } | 
|  | 1045 | case 'i': | 
|  | 1046 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1047 | if (LocaleCompare("intent",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1048 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1049 | /* Only used by coders: MIFF, MPC, BMP, PNG | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1050 | and for image profile call to AcquireTransformThreadSet() | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1051 | SyncImageSettings() used to set per-image attribute. | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1052 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1053 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1054 | break; | 
|  | 1055 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1056 | if (LocaleCompare("interlace",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1057 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1058 | /* _image_info is directly used by coders (so why an image setting?) | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1059 | SyncImageSettings() used to set per-image attribute. | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1060 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1061 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); | 
|  | 1062 | _image_info->interlace=(InterlaceType) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1063 | MagickInterlaceOptions,MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1064 | break; | 
|  | 1065 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1066 | if (LocaleCompare("interline-spacing",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1067 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1068 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); | 
|  | 1069 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1070 | (char **) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1071 | break; | 
|  | 1072 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1073 | if (LocaleCompare("interpolate",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1074 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1075 | /* SyncImageSettings() used to set per-image attribute. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1076 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1077 | break; | 
|  | 1078 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1079 | if (LocaleCompare("interword-spacing",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1080 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1081 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); | 
|  | 1082 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1083 | break; | 
|  | 1084 | } | 
|  | 1085 | break; | 
|  | 1086 | } | 
|  | 1087 | case 'k': | 
|  | 1088 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1089 | if (LocaleCompare("kerning",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1090 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1091 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 1092 | _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1093 | break; | 
|  | 1094 | } | 
|  | 1095 | break; | 
|  | 1096 | } | 
|  | 1097 | case 'l': | 
|  | 1098 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1099 | if (LocaleCompare("label",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1100 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1101 | /* only used for new images - not in SyncImageOptions() */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1102 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1103 | break; | 
|  | 1104 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1105 | if (LocaleCompare("log",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1106 | { | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1107 | if (IfSetOption) | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1108 | (void) SetLogFormat(arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1109 | break; | 
|  | 1110 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1111 | if (LocaleCompare("loop",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1112 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1113 | /* SyncImageSettings() used to set per-image attribute. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1114 | (void) SetImageOption(_image_info,option+1,ArgOption("0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1115 | break; | 
|  | 1116 | } | 
|  | 1117 | break; | 
|  | 1118 | } | 
|  | 1119 | case 'm': | 
|  | 1120 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1121 | if (LocaleCompare("mattecolor",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1122 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1123 | /* SyncImageSettings() used to set per-image attribute. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1124 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1125 | (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1126 | &_image_info->matte_color,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1127 | break; | 
|  | 1128 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1129 | if (LocaleCompare("monitor",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1130 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1131 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1132 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1133 | break; | 
|  | 1134 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1135 | if (LocaleCompare("monochrome",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1136 | { | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1137 | /* Setting (used by some input coders!) -- why? | 
|  | 1138 | Warning: This is also Special '-type' SimpleOperator | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1139 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1140 | _image_info->monochrome= ArgBoolean; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1141 | break; | 
|  | 1142 | } | 
|  | 1143 | break; | 
|  | 1144 | } | 
|  | 1145 | case 'o': | 
|  | 1146 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1147 | if (LocaleCompare("orient",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1148 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1149 | /* Is not used when defining for new images. | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1150 | This makes it more of a 'operation' than a setting | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1151 | FUTURE: make set meta-data operator instead. | 
|  | 1152 | SyncImageSettings() used to set per-image attribute. | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1153 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1154 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); | 
|  | 1155 | _image_info->orientation=(InterlaceType) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1156 | MagickOrientationOptions,MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1157 | break; | 
|  | 1158 | } | 
|  | 1159 | } | 
|  | 1160 | case 'p': | 
|  | 1161 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1162 | if (LocaleCompare("page",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1163 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1164 | /* Only used for new images and image generators | 
|  | 1165 | SyncImageSettings() used to set per-image attribute. ????? | 
|  | 1166 | That last is WRONG!!!! | 
|  | 1167 | */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1168 | char | 
|  | 1169 | *canonical_page, | 
|  | 1170 | page[MaxTextExtent]; | 
|  | 1171 |  | 
|  | 1172 | const char | 
|  | 1173 | *image_option; | 
|  | 1174 |  | 
|  | 1175 | MagickStatusType | 
|  | 1176 | flags; | 
|  | 1177 |  | 
|  | 1178 | RectangleInfo | 
|  | 1179 | geometry; | 
|  | 1180 |  | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1181 | if (!IfSetOption) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1182 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1183 | (void) DeleteImageOption(_image_info,option+1); | 
|  | 1184 | (void) CloneString(&_image_info->page,(char *) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1185 | break; | 
|  | 1186 | } | 
|  | 1187 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1188 | image_option=GetImageOption(_image_info,"page"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1189 | if (image_option != (const char *) NULL) | 
|  | 1190 | flags=ParseAbsoluteGeometry(image_option,&geometry); | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1191 | canonical_page=GetPageGeometry(arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1192 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); | 
|  | 1193 | canonical_page=DestroyString(canonical_page); | 
|  | 1194 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", | 
|  | 1195 | (unsigned long) geometry.width,(unsigned long) geometry.height); | 
|  | 1196 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) | 
|  | 1197 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", | 
|  | 1198 | (unsigned long) geometry.width,(unsigned long) geometry.height, | 
|  | 1199 | (long) geometry.x,(long) geometry.y); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1200 | (void) SetImageOption(_image_info,option+1,page); | 
|  | 1201 | (void) CloneString(&_image_info->page,page); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1202 | break; | 
|  | 1203 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1204 | if (LocaleCompare("ping",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1205 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1206 | _image_info->ping = ArgBoolean; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1207 | break; | 
|  | 1208 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1209 | if (LocaleCompare("pointsize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1210 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1211 | _image_info->pointsize=_draw_info->pointsize= | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1212 | StringToDouble(ArgOption("12"),(char **) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1213 | break; | 
|  | 1214 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1215 | if (LocaleCompare("precision",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1216 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1217 | (void) SetMagickPrecision(StringToInteger(ArgOption("-1"))); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1218 | break; | 
|  | 1219 | } | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1220 | /* FUTURE: Only the 'preview' coder appears to use this | 
| anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1221 | * DEPRECIATE the coder?  Leaving only the 'preview' operator. | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1222 | if (LocaleCompare("preview",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1223 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1224 | _image_info->preview_type=UndefinedPreview; | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1225 | if (IfSetOption) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1226 | _image_info->preview_type=(PreviewType) ParseCommandOption( | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1227 | MagickPreviewOptions,MagickFalse,arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1228 | break; | 
|  | 1229 | } | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1230 | */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1231 | break; | 
|  | 1232 | } | 
|  | 1233 | case 'q': | 
|  | 1234 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1235 | if (LocaleCompare("quality",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1236 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1237 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 1238 | _image_info->quality=UNDEFINED_COMPRESSION_QUALITY; | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1239 | if (IfSetOption) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1240 | _image_info->quality=StringToUnsignedLong(arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1241 | break; | 
|  | 1242 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1243 | if (LocaleCompare("quantize",option+1) == 0) | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1244 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1245 | /* Just a set direct in _quantize_info */ | 
|  | 1246 | _quantize_info->colorspace=UndefinedColorspace; | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1247 | if (IfSetOption) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1248 | _quantize_info->colorspace=(ColorspaceType) ParseCommandOption( | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1249 | MagickColorspaceOptions,MagickFalse,arg1); | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1250 | break; | 
|  | 1251 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1252 | if (LocaleCompare("quiet",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1253 | { | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1254 | /* FUTURE: if two -quiet is performed you can not do +quiet! */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1255 | static WarningHandler | 
|  | 1256 | warning_handler = (WarningHandler) NULL; | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1257 |  | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1258 | WarningHandler | 
|  | 1259 | tmp = SetWarningHandler((WarningHandler) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1260 |  | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1261 | if ( tmp != (WarningHandler) NULL) | 
|  | 1262 | warning_handler = tmp; /* remember the old handler */ | 
|  | 1263 | if (!IfSetOption)        /* set the old handler */ | 
|  | 1264 | warning_handler=SetWarningHandler(warning_handler); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1265 | break; | 
|  | 1266 | } | 
|  | 1267 | break; | 
|  | 1268 | } | 
|  | 1269 | case 'r': | 
|  | 1270 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1271 | if (LocaleCompare("red-primary",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1272 | { | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1273 | /* Image chromaticity X,Y  NB: Y=X if Y not defined | 
|  | 1274 | Used by many coders | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1275 | SyncImageSettings() used to set per-image attribute. | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1276 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1277 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1278 | break; | 
|  | 1279 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1280 | if (LocaleCompare("render",option+1) == 0) | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1281 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1282 | /* _draw_info only setting */ | 
|  | 1283 | _draw_info->render= ArgBooleanNot; | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1284 | break; | 
|  | 1285 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1286 | if (LocaleCompare("respect-parenthesis",option+1) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1287 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1288 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1289 | break; | 
|  | 1290 | } | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1291 | break; | 
|  | 1292 | } | 
|  | 1293 | case 's': | 
|  | 1294 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1295 | if (LocaleCompare("sampling-factor",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1296 | { | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1297 | /* FUTURE: should be converted to jpeg:sampling_factor */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1298 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1299 | break; | 
|  | 1300 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1301 | if (LocaleCompare("scene",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1302 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1303 | /* SyncImageSettings() used to set per-image attribute. | 
|  | 1304 | What ??? Why ???? | 
|  | 1305 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1306 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 1307 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1308 | break; | 
|  | 1309 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1310 | if (LocaleCompare("seed",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1311 | { | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1312 | SeedPseudoRandomGenerator( | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1313 | IfSetOption ? (size_t) StringToUnsignedLong(arg1) | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1314 | : (size_t) time((time_t *) NULL) ); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1315 | break; | 
|  | 1316 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1317 | if (LocaleCompare("size",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1318 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1319 | /* FUTURE: string in _image_info -- convert to Option ??? | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1320 | Look at the special handling for "size" in SetImageOption() | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1321 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1322 | (void) CloneString(&_image_info->size,ArgOption(NULL)); | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1323 | break; | 
|  | 1324 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1325 | if (LocaleCompare("stretch",option+1) == 0) | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1326 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1327 | _draw_info->stretch=(StretchType) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1328 | MagickStretchOptions,MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1329 | break; | 
|  | 1330 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1331 | if (LocaleCompare("stroke",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1332 | { | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1333 | /* set stroke color OR stroke-pattern | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1334 | UPDATE: ensure stroke color is not destroyed is a pattern | 
|  | 1335 | is given. Just in case the color is also used for other purposes. | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1336 | */ | 
|  | 1337 | const char | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1338 | *value; | 
|  | 1339 |  | 
|  | 1340 | MagickBooleanType | 
|  | 1341 | status; | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1342 |  | 
|  | 1343 | ExceptionInfo | 
|  | 1344 | *sans; | 
|  | 1345 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1346 | PixelInfo | 
|  | 1347 | color; | 
|  | 1348 |  | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1349 | value = ArgOption("none"); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1350 | (void) SetImageOption(_image_info,option+1,value); | 
|  | 1351 | if (_draw_info->stroke_pattern != (Image *) NULL) | 
|  | 1352 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1353 |  | 
|  | 1354 | /* is it a color or a image? -- ignore exceptions */ | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1355 | sans=AcquireExceptionInfo(); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1356 | status=QueryColorCompliance(value,AllCompliance,&color,sans); | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1357 | sans=DestroyExceptionInfo(sans); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1358 |  | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1359 | if (status == MagickFalse) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1360 | _draw_info->stroke_pattern=GetImageCache(_image_info,value,_exception); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1361 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1362 | _draw_info->stroke=color; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1363 | break; | 
|  | 1364 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1365 | if (LocaleCompare("strokewidth",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1366 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1367 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 1368 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1369 | (char **) NULL); | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1370 | break; | 
|  | 1371 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1372 | if (LocaleCompare("style",option+1) == 0) | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1373 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1374 | _draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1375 | MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1376 | break; | 
|  | 1377 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1378 | if (LocaleCompare("synchronize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1379 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1380 | _image_info->synchronize = ArgBoolean; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1381 | break; | 
|  | 1382 | } | 
|  | 1383 | break; | 
|  | 1384 | } | 
|  | 1385 | case 't': | 
|  | 1386 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1387 | if (LocaleCompare("taint",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1388 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1389 | /* SyncImageSettings() used to set per-image attribute. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1390 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1391 | break; | 
|  | 1392 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1393 | if (LocaleCompare("texture",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1394 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1395 | /* FUTURE: move _image_info string to option splay-tree */ | 
|  | 1396 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1397 | break; | 
|  | 1398 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1399 | if (LocaleCompare("tile",option+1) == 0) | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1400 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1401 | _draw_info->fill_pattern=IfSetOption | 
|  | 1402 | ?GetImageCache(_image_info,arg1,_exception) | 
|  | 1403 | :DestroyImage(_draw_info->fill_pattern); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1404 | break; | 
|  | 1405 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1406 | if (LocaleCompare("tile-offset",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1407 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1408 | /* SyncImageSettings() used to set per-image attribute. ??? */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1409 | (void) SetImageOption(_image_info,option+1,ArgOption("0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1410 | break; | 
|  | 1411 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1412 | if (LocaleCompare("transparent-color",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1413 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1414 | /* FUTURE: both _image_info attribute & ImageOption in use! | 
|  | 1415 | _image_info only used for generating new images. | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1416 | SyncImageSettings() used to set per-image attribute. | 
|  | 1417 |  | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1418 | Note that +transparent-color, means fall-back to image | 
|  | 1419 | attribute so ImageOption is deleted, not set to a default. | 
|  | 1420 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1421 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1422 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1423 | &_image_info->transparent_color,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1424 | break; | 
|  | 1425 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1426 | if (LocaleCompare("treedepth",option+1) == 0) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1427 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1428 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 1429 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1430 | break; | 
|  | 1431 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1432 | if (LocaleCompare("type",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1433 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1434 | /* SyncImageSettings() used to set per-image attribute. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1435 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 1436 | _image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1437 | MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1438 | break; | 
|  | 1439 | } | 
|  | 1440 | break; | 
|  | 1441 | } | 
|  | 1442 | case 'u': | 
|  | 1443 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1444 | if (LocaleCompare("undercolor",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1445 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1446 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1447 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1448 | &_draw_info->undercolor,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1449 | break; | 
|  | 1450 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1451 | if (LocaleCompare("units",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1452 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1453 | /* SyncImageSettings() used to set per-image attribute. | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1454 | Should this effect _draw_info X and Y resolution? | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1455 | FUTURE: this probably should be part of the density setting | 
|  | 1456 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1457 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
|  | 1458 | _image_info->units=(ResolutionType) ParseCommandOption( | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1459 | MagickResolutionOptions,MagickFalse,ArgOption("undefined")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1460 | break; | 
|  | 1461 | } | 
|  | 1462 | break; | 
|  | 1463 | } | 
|  | 1464 | case 'v': | 
|  | 1465 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1466 | if (LocaleCompare("verbose",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1467 | { | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1468 | /* FUTURE: Remember all options become image artifacts | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1469 | _image_info->verbose is only used by coders. | 
| anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1470 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1471 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); | 
|  | 1472 | _image_info->verbose= ArgBoolean; | 
|  | 1473 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1474 | break; | 
|  | 1475 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1476 | if (LocaleCompare("view",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1477 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1478 | /* FUTURE: Convert from _image_info to ImageOption | 
| anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1479 | Only used by coder FPX | 
|  | 1480 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1481 | (void) CloneString(&_image_info->view,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1482 | break; | 
|  | 1483 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1484 | if (LocaleCompare("virtual-pixel",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1485 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1486 | /* SyncImageSettings() used to set per-image attribute. | 
|  | 1487 | This is VERY deep in the image caching structure. | 
|  | 1488 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1489 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1490 | break; | 
|  | 1491 | } | 
|  | 1492 | break; | 
|  | 1493 | } | 
|  | 1494 | case 'w': | 
|  | 1495 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1496 | if (LocaleCompare("weight",option+1) == 0) | 
| anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1497 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1498 | /* Just what does using a font 'weight' do ??? | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1499 | There is no "-list weight" output (reference manual says there is) | 
| anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1500 | */ | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1501 | if (!IfSetOption) | 
|  | 1502 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1503 | _draw_info->weight=StringToUnsignedLong(arg1); | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1504 | if (LocaleCompare(arg1,"all") == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1505 | _draw_info->weight=0; | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1506 | if (LocaleCompare(arg1,"bold") == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1507 | _draw_info->weight=700; | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1508 | if (LocaleCompare(arg1,"bolder") == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1509 | if (_draw_info->weight <= 800) | 
|  | 1510 | _draw_info->weight+=100; | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1511 | if (LocaleCompare(arg1,"lighter") == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1512 | if (_draw_info->weight >= 100) | 
|  | 1513 | _draw_info->weight-=100; | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1514 | if (LocaleCompare(arg1,"normal") == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1515 | _draw_info->weight=400; | 
| anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1516 | break; | 
|  | 1517 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1518 | if (LocaleCompare("white-point",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1519 | { | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1520 | /* Used as a image chromaticity setting | 
|  | 1521 | SyncImageSettings() used to set per-image attribute. | 
|  | 1522 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1523 | (void) SetImageOption(_image_info,option+1,ArgOption("0.0")); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1524 | break; | 
|  | 1525 | } | 
|  | 1526 | break; | 
|  | 1527 | } | 
|  | 1528 | default: | 
|  | 1529 | break; | 
|  | 1530 | } | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1531 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1532 | #undef _image_info | 
|  | 1533 | #undef _exception | 
|  | 1534 | #undef _draw_info | 
|  | 1535 | #undef _quantize_info | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1536 | #undef IfSetOption | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1537 | #undef ArgBoolean | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1538 | #undef ArgBooleanNot | 
|  | 1539 | #undef ArgBooleanString | 
|  | 1540 | #undef ArgOption | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1541 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1542 | return; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1543 | } | 
|  | 1544 |  | 
|  | 1545 | /* | 
|  | 1546 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 1547 | %                                                                             % | 
|  | 1548 | %                                                                             % | 
|  | 1549 | %                                                                             % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1550 | +     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] | 1551 | %                                                                             % | 
|  | 1552 | %                                                                             % | 
|  | 1553 | %                                                                             % | 
|  | 1554 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 1555 | % | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1556 | %  WandSimpleOperatorImages() applys one simple image operation given to all | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1557 | %  the images in the CLI wand,  with the settings that was previously saved in | 
|  | 1558 | %  the CLI wand. | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1559 | % | 
|  | 1560 | %  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] | 1561 | %  extra settings that were already saved in the wand. | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1562 | % | 
| anthony | d144767 | 2012-01-19 05:33:53 +0000 | [diff] [blame] | 1563 | %  The format of the WandSimpleOperatorImage method is: | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1564 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1565 | %    void CLISimpleOperatorImages(MagickCLI *cli_wand, | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1566 | %        const char *option, const char *arg1, const char *arg2) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1567 | % | 
|  | 1568 | %  A description of each parameter follows: | 
|  | 1569 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1570 | %    o cli_wand: structure holding settings and images to be operated on | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1571 | % | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1572 | %    o option:  The option string for the operation | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1573 | % | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1574 | %    o arg1, arg2: optional argument strings to the operation | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1575 | % | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1576 | % Any problems will be added to the 'exception' entry of the given wand. | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1577 | % | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1578 | % Example usage... | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1579 | % | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1580 | %  CLISimpleOperatorImages(cli_wand, "-crop","100x100+20+30",NULL); | 
|  | 1581 | %  CLISimpleOperatorImages(cli_wand, "+repage",NULL,NULL); | 
|  | 1582 | %  CLISimpleOperatorImages(cli_wand, "+distort","SRT","45"); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1583 | % | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1584 | % Or for handling command line arguments EG: +/-option ["arg1"] | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1585 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1586 | %    cli_wand | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1587 | %    argc,argv | 
|  | 1588 | %    i=index in argv | 
|  | 1589 | % | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 1590 | %    option_info = GetCommandOptionInfo(argv[i]); | 
|  | 1591 | %    count=option_info->type; | 
|  | 1592 | %    option_type=option_info->flags; | 
|  | 1593 | % | 
|  | 1594 | %    if ( (option_type & SimpleOperatorOptionFlag) != 0 ) | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1595 | %      CLISimpleOperatorImages(cli_wand, argv[i], | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1596 | %          count>=1 ? argv[i+1] : (char *)NULL, | 
|  | 1597 | %          count>=2 ? argv[i+2] : (char *)NULL ); | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1598 | %    i += count+1; | 
|  | 1599 | % | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1600 | */ | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1601 |  | 
|  | 1602 | /* | 
|  | 1603 | Internal subrountine to apply one simple image operation to the current | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1604 | image pointed to by the CLI wand. | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1605 |  | 
|  | 1606 | The image in the list may be modified in three different ways... | 
|  | 1607 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), | 
|  | 1608 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) | 
|  | 1609 | * one image replace by a list of images (-separate and -crop only!) | 
|  | 1610 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1611 | In each case the result replaces the single original image in the list, as | 
|  | 1612 | well as the pointer to the modified image (last image added if replaced by a | 
|  | 1613 | list of images) is returned. | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1614 |  | 
|  | 1615 | As the image pointed to may be replaced, the first image in the list may | 
|  | 1616 | also change.  GetFirstImageInList() should be used by caller if they wish | 
|  | 1617 | return the Image pointer to the first image in list. | 
|  | 1618 | */ | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1619 | static void CLISimpleOperatorImage(MagickCLI *cli_wand, | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1620 | const char *option, const char *arg1, const char *arg2) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1621 | { | 
|  | 1622 | Image * | 
|  | 1623 | new_image; | 
|  | 1624 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1625 | GeometryInfo | 
|  | 1626 | geometry_info; | 
|  | 1627 |  | 
|  | 1628 | RectangleInfo | 
|  | 1629 | geometry; | 
|  | 1630 |  | 
|  | 1631 | MagickStatusType | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1632 | flags; | 
|  | 1633 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1634 | ssize_t | 
|  | 1635 | type; | 
|  | 1636 |  | 
|  | 1637 | #define _image_info      (cli_wand->wand.image_info) | 
|  | 1638 | #define _image           (cli_wand->wand.images) | 
|  | 1639 | #define _exception       (cli_wand->wand.exception) | 
|  | 1640 | #define _draw_info       (cli_wand->draw_info) | 
|  | 1641 | #define _quantize_info   (cli_wand->quantize_info) | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1642 | #define IfNormalOp      (*option=='-') | 
|  | 1643 | #define IfPlusOp        (*option!='-') | 
|  | 1644 | #define normal_op       (IfNormalOp?MagickTrue:MagickFalse) | 
|  | 1645 | #define plus_alt_op     (IfNormalOp?MagickFalse:MagickTrue) | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1646 |  | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1647 | assert(cli_wand != (MagickCLI *) NULL); | 
|  | 1648 | assert(cli_wand->signature == WandSignature); | 
|  | 1649 | assert(cli_wand->wand.signature == WandSignature); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1650 | assert(_image != (Image *) NULL);             /* an _image must be present */ | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1651 | if (cli_wand->wand.debug != MagickFalse) | 
|  | 1652 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1653 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1654 | (void) SyncImageSettings(_image_info,_image,_exception); | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1655 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1656 | SetGeometryInfo(&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1657 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1658 | new_image = (Image *)NULL; /* the replacement _image, if not null at end */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1659 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1660 | /* FUTURE: We may need somthing a little more optimized than this! | 
|  | 1661 | Perhaps, do the 'sync' if 'settings tainted' before next operator. | 
|  | 1662 | */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1663 | switch (*(option+1)) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1664 | { | 
|  | 1665 | case 'a': | 
|  | 1666 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1667 | if (LocaleCompare("adaptive-blur",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1668 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1669 | if (IsGeometry(arg1) == MagickFalse) | 
|  | 1670 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1671 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1672 | if ((flags & SigmaValue) == 0) | 
|  | 1673 | geometry_info.sigma=1.0; | 
|  | 1674 | if ((flags & XiValue) == 0) | 
|  | 1675 | geometry_info.xi=0.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1676 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, | 
|  | 1677 | geometry_info.sigma,geometry_info.xi,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1678 | break; | 
|  | 1679 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1680 | if (LocaleCompare("adaptive-resize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1681 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1682 | if (IsGeometry(arg1) == MagickFalse) | 
|  | 1683 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); | 
|  | 1684 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); | 
|  | 1685 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, | 
|  | 1686 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1687 | break; | 
|  | 1688 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1689 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1690 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1691 | if (IsGeometry(arg1) == MagickFalse) | 
|  | 1692 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1693 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1694 | if ((flags & SigmaValue) == 0) | 
|  | 1695 | geometry_info.sigma=1.0; | 
|  | 1696 | if ((flags & XiValue) == 0) | 
|  | 1697 | geometry_info.xi=0.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1698 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, | 
|  | 1699 | geometry_info.sigma,geometry_info.xi,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1700 | break; | 
|  | 1701 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1702 | if (LocaleCompare("alpha",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1703 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1704 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,arg1); | 
|  | 1705 | if (type < 0) | 
|  | 1706 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelType", | 
|  | 1707 | option,arg1); | 
|  | 1708 | (void) SetImageAlphaChannel(_image,(AlphaChannelType)type,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1709 | break; | 
|  | 1710 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1711 | if (LocaleCompare("annotate",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1712 | { | 
|  | 1713 | char | 
|  | 1714 | *text, | 
|  | 1715 | geometry[MaxTextExtent]; | 
|  | 1716 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1717 | if (IsGeometry(arg1) == MagickFalse) | 
|  | 1718 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1719 | SetGeometryInfo(&geometry_info); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1720 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1721 | if ((flags & SigmaValue) == 0) | 
|  | 1722 | geometry_info.sigma=geometry_info.rho; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1723 | text=InterpretImageProperties(_image_info,_image,arg2, | 
|  | 1724 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1725 | if (text == (char *) NULL) | 
|  | 1726 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1727 | (void) CloneString(&_draw_info->text,text); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1728 | text=DestroyString(text); | 
|  | 1729 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", | 
|  | 1730 | geometry_info.xi,geometry_info.psi); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1731 | (void) CloneString(&_draw_info->geometry,geometry); | 
|  | 1732 | _draw_info->affine.sx=cos(DegreesToRadians( | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1733 | fmod(geometry_info.rho,360.0))); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1734 | _draw_info->affine.rx=sin(DegreesToRadians( | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1735 | fmod(geometry_info.rho,360.0))); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1736 | _draw_info->affine.ry=(-sin(DegreesToRadians( | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1737 | fmod(geometry_info.sigma,360.0)))); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1738 | _draw_info->affine.sy=cos(DegreesToRadians( | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1739 | fmod(geometry_info.sigma,360.0))); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1740 | (void) AnnotateImage(_image,_draw_info,_exception); | 
|  | 1741 | GetAffineMatrix(&_draw_info->affine); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1742 | break; | 
|  | 1743 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1744 | if (LocaleCompare("auto-gamma",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1745 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1746 | (void) AutoGammaImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1747 | break; | 
|  | 1748 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1749 | if (LocaleCompare("auto-level",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1750 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1751 | (void) AutoLevelImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1752 | break; | 
|  | 1753 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1754 | if (LocaleCompare("auto-orient",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1755 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1756 | /* This should probbaly be a MagickCore function */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1757 | switch (_image->orientation) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1758 | { | 
|  | 1759 | case TopRightOrientation: | 
|  | 1760 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1761 | new_image=FlopImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1762 | break; | 
|  | 1763 | } | 
|  | 1764 | case BottomRightOrientation: | 
|  | 1765 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1766 | new_image=RotateImage(_image,180.0,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1767 | break; | 
|  | 1768 | } | 
|  | 1769 | case BottomLeftOrientation: | 
|  | 1770 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1771 | new_image=FlipImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1772 | break; | 
|  | 1773 | } | 
|  | 1774 | case LeftTopOrientation: | 
|  | 1775 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1776 | new_image=TransposeImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1777 | break; | 
|  | 1778 | } | 
|  | 1779 | case RightTopOrientation: | 
|  | 1780 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1781 | new_image=RotateImage(_image,90.0,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1782 | break; | 
|  | 1783 | } | 
|  | 1784 | case RightBottomOrientation: | 
|  | 1785 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1786 | new_image=TransverseImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1787 | break; | 
|  | 1788 | } | 
|  | 1789 | case LeftBottomOrientation: | 
|  | 1790 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1791 | new_image=RotateImage(_image,270.0,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1792 | break; | 
|  | 1793 | } | 
|  | 1794 | default: | 
|  | 1795 | break; | 
|  | 1796 | } | 
|  | 1797 | if (new_image != (Image *) NULL) | 
|  | 1798 | new_image->orientation=TopLeftOrientation; | 
|  | 1799 | break; | 
|  | 1800 | } | 
|  | 1801 | break; | 
|  | 1802 | } | 
|  | 1803 | case 'b': | 
|  | 1804 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1805 | if (LocaleCompare("black-threshold",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1806 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1807 | (void) BlackThresholdImage(_image,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1808 | break; | 
|  | 1809 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1810 | if (LocaleCompare("blue-shift",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1811 | { | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1812 | geometry_info.rho=1.5; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1813 | if (IfNormalOp) | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1814 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1815 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1816 | break; | 
|  | 1817 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1818 | if (LocaleCompare("blur",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1819 | { | 
| anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1820 | /* FUTURE: use of "bias" in a blur is non-sensible */ | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1821 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1822 | if ((flags & SigmaValue) == 0) | 
|  | 1823 | geometry_info.sigma=1.0; | 
|  | 1824 | if ((flags & XiValue) == 0) | 
|  | 1825 | geometry_info.xi=0.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1826 | new_image=BlurImage(_image,geometry_info.rho, | 
|  | 1827 | geometry_info.sigma,geometry_info.xi,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1828 | break; | 
|  | 1829 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1830 | if (LocaleCompare("border",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1831 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1832 | CompositeOperator | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1833 | compose; | 
|  | 1834 |  | 
|  | 1835 | const char* | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1836 | value; | 
|  | 1837 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1838 | value=GetImageOption(_image_info,"compose"); | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1839 | if (value != (const char *) NULL) | 
|  | 1840 | compose=(CompositeOperator) ParseCommandOption( | 
|  | 1841 | MagickComposeOptions,MagickFalse,value); | 
|  | 1842 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1843 | compose=OverCompositeOp;  /* use Over not _image->compose */ | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1844 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1845 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1846 | if ((flags & SigmaValue) == 0) | 
|  | 1847 | geometry.height=geometry.width; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1848 | new_image=BorderImage(_image,&geometry,compose,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1849 | break; | 
|  | 1850 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1851 | if (LocaleCompare("brightness-contrast",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1852 | { | 
|  | 1853 | double | 
|  | 1854 | brightness, | 
|  | 1855 | contrast; | 
|  | 1856 |  | 
|  | 1857 | GeometryInfo | 
|  | 1858 | geometry_info; | 
|  | 1859 |  | 
|  | 1860 | MagickStatusType | 
|  | 1861 | flags; | 
|  | 1862 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1863 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1864 | brightness=geometry_info.rho; | 
|  | 1865 | contrast=0.0; | 
|  | 1866 | if ((flags & SigmaValue) != 0) | 
|  | 1867 | contrast=geometry_info.sigma; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1868 | (void) BrightnessContrastImage(_image,brightness,contrast, | 
|  | 1869 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1870 | break; | 
|  | 1871 | } | 
|  | 1872 | break; | 
|  | 1873 | } | 
|  | 1874 | case 'c': | 
|  | 1875 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1876 | if (LocaleCompare("cdl",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1877 | { | 
|  | 1878 | char | 
|  | 1879 | *color_correction_collection; | 
|  | 1880 |  | 
|  | 1881 | /* | 
|  | 1882 | Color correct with a color decision list. | 
|  | 1883 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1884 | color_correction_collection=FileToString(arg1,~0,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1885 | if (color_correction_collection == (char *) NULL) | 
|  | 1886 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1887 | (void) ColorDecisionListImage(_image,color_correction_collection, | 
|  | 1888 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1889 | break; | 
|  | 1890 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1891 | if (LocaleCompare("channel",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1892 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1893 | /* The "channel" setting has already been set | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1894 | FUTURE: This probably should be part of SyncImageSettings(). | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1895 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1896 | SetPixelChannelMapMask(_image,_image_info->channel); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1897 | break; | 
|  | 1898 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1899 | if (LocaleCompare("charcoal",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1900 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1901 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1902 | if ((flags & SigmaValue) == 0) | 
|  | 1903 | geometry_info.sigma=1.0; | 
|  | 1904 | if ((flags & XiValue) == 0) | 
|  | 1905 | geometry_info.xi=1.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1906 | new_image=CharcoalImage(_image,geometry_info.rho, | 
|  | 1907 | geometry_info.sigma,geometry_info.xi,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1908 | break; | 
|  | 1909 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1910 | if (LocaleCompare("chop",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1911 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1912 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); | 
|  | 1913 | new_image=ChopImage(_image,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1914 | break; | 
|  | 1915 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1916 | if (LocaleCompare("clamp",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1917 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1918 | (void) ClampImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1919 | break; | 
|  | 1920 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1921 | if (LocaleCompare("clip",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1922 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1923 | if (IfNormalOp) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1924 | (void) ClipImage(_image,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1925 | else /* "+mask" remove the write mask */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1926 | (void) SetImageMask(_image,(Image *) NULL,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1927 | break; | 
|  | 1928 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1929 | if (LocaleCompare("clip-mask",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1930 | { | 
|  | 1931 | CacheView | 
|  | 1932 | *mask_view; | 
|  | 1933 |  | 
|  | 1934 | Image | 
|  | 1935 | *mask_image; | 
|  | 1936 |  | 
|  | 1937 | register Quantum | 
|  | 1938 | *restrict q; | 
|  | 1939 |  | 
|  | 1940 | register ssize_t | 
|  | 1941 | x; | 
|  | 1942 |  | 
|  | 1943 | ssize_t | 
|  | 1944 | y; | 
|  | 1945 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1946 | if (IfPlusOp) { | 
|  | 1947 | /* "+clip-mask" Remove the write mask */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1948 | (void) SetImageMask(_image,(Image *) NULL,_exception); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1949 | break; | 
|  | 1950 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1951 | mask_image=GetImageCache(_image_info,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1952 | if (mask_image == (Image *) NULL) | 
|  | 1953 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1954 | if (SetImageStorageClass(mask_image,DirectClass,_exception) | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1955 | == MagickFalse) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1956 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1957 | /* Create a write mask from cli_wandp-mask _image */ | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1958 | /* FUTURE: use Alpha operations instead and create a Grey Image */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1959 | mask_view=AcquireCacheView(mask_image); | 
|  | 1960 | for (y=0; y < (ssize_t) mask_image->rows; y++) | 
|  | 1961 | { | 
|  | 1962 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1963 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1964 | if (q == (Quantum *) NULL) | 
|  | 1965 | break; | 
|  | 1966 | for (x=0; x < (ssize_t) mask_image->columns; x++) | 
|  | 1967 | { | 
|  | 1968 | if (mask_image->matte == MagickFalse) | 
|  | 1969 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); | 
|  | 1970 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); | 
|  | 1971 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); | 
|  | 1972 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); | 
|  | 1973 | q+=GetPixelChannels(mask_image); | 
|  | 1974 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1975 | if (SyncCacheViewAuthenticPixels(mask_view,_exception) == MagickFalse) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1976 | break; | 
|  | 1977 | } | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1978 | /* clean up and set the write mask */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1979 | mask_view=DestroyCacheView(mask_view); | 
|  | 1980 | mask_image->matte=MagickTrue; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1981 | (void) SetImageMask(_image,mask_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1982 | mask_image=DestroyImage(mask_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1983 | break; | 
|  | 1984 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1985 | if (LocaleCompare("clip-path",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1986 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1987 | (void) ClipImagePath(_image,arg1,normal_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1988 | break; | 
|  | 1989 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1990 | if (LocaleCompare("colorize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1991 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 1992 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1993 | break; | 
|  | 1994 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1995 | if (LocaleCompare("color-matrix",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1996 | { | 
|  | 1997 | KernelInfo | 
|  | 1998 | *kernel; | 
|  | 1999 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2000 | kernel=AcquireKernelInfo(arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2001 | if (kernel == (KernelInfo *) NULL) | 
|  | 2002 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2003 | new_image=ColorMatrixImage(_image,kernel,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2004 | kernel=DestroyKernelInfo(kernel); | 
|  | 2005 | break; | 
|  | 2006 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2007 | if (LocaleCompare("colors",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2008 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2009 | /* Reduce the number of colors in the _image. | 
|  | 2010 | FUTURE: also provide 'plus version with _image 'color counts' | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2011 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2012 | _quantize_info->number_colors=StringToUnsignedLong(arg1); | 
|  | 2013 | if (_quantize_info->number_colors == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2014 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2015 | if ((_image->storage_class == DirectClass) || | 
|  | 2016 | _image->colors > _quantize_info->number_colors) | 
|  | 2017 | (void) QuantizeImage(_quantize_info,_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2018 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2019 | (void) CompressImageColormap(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2020 | break; | 
|  | 2021 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2022 | if (LocaleCompare("colorspace",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2023 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2024 | /* WARNING: this is both a _image_info setting (already done) | 
|  | 2025 | and a operator to change _image colorspace. | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2026 |  | 
|  | 2027 | FUTURE: default colorspace should be sRGB! | 
| anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2028 | Unless some type of 'linear colorspace' mode is set. | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2029 |  | 
| anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2030 | Note that +colorspace sets "undefined" or no effect on | 
|  | 2031 | new images, but forces images already in memory back to RGB! | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2032 | That seems to be a little strange! | 
| anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2033 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2034 | (void) TransformImageColorspace(_image, | 
|  | 2035 | IfNormalOp ? _image_info->colorspace : RGBColorspace, | 
|  | 2036 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2037 | break; | 
|  | 2038 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2039 | if (LocaleCompare("contrast",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2040 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2041 | (void) ContrastImage(_image,normal_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2042 | break; | 
|  | 2043 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2044 | if (LocaleCompare("contrast-stretch",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2045 | { | 
|  | 2046 | double | 
|  | 2047 | black_point, | 
|  | 2048 | white_point; | 
|  | 2049 |  | 
|  | 2050 | MagickStatusType | 
|  | 2051 | flags; | 
|  | 2052 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2053 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2054 | black_point=geometry_info.rho; | 
|  | 2055 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : | 
|  | 2056 | black_point; | 
|  | 2057 | if ((flags & PercentValue) != 0) | 
|  | 2058 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2059 | black_point*=(double) _image->columns*_image->rows/100.0; | 
|  | 2060 | white_point*=(double) _image->columns*_image->rows/100.0; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2061 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2062 | white_point=(MagickRealType) _image->columns*_image->rows- | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2063 | white_point; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2064 | (void) ContrastStretchImage(_image,black_point,white_point, | 
|  | 2065 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2066 | break; | 
|  | 2067 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2068 | if (LocaleCompare("convolve",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2069 | { | 
|  | 2070 | KernelInfo | 
|  | 2071 | *kernel_info; | 
|  | 2072 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2073 | kernel_info=AcquireKernelInfo(arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2074 | if (kernel_info == (KernelInfo *) NULL) | 
|  | 2075 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2076 | kernel_info->bias=_image->bias; | 
|  | 2077 | new_image=ConvolveImage(_image,kernel_info,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2078 | kernel_info=DestroyKernelInfo(kernel_info); | 
|  | 2079 | break; | 
|  | 2080 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2081 | if (LocaleCompare("crop",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2082 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2083 | /* WARNING: This can generate multiple images! */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2084 | new_image=CropImageToTiles(_image,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2085 | break; | 
|  | 2086 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2087 | if (LocaleCompare("cycle",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2088 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2089 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), | 
|  | 2090 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2091 | break; | 
|  | 2092 | } | 
|  | 2093 | break; | 
|  | 2094 | } | 
|  | 2095 | case 'd': | 
|  | 2096 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2097 | if (LocaleCompare("decipher",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2098 | { | 
|  | 2099 | StringInfo | 
|  | 2100 | *passkey; | 
|  | 2101 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2102 | passkey=FileToStringInfo(arg1,~0,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2103 | if (passkey != (StringInfo *) NULL) | 
|  | 2104 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2105 | (void) PasskeyDecipherImage(_image,passkey,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2106 | passkey=DestroyStringInfo(passkey); | 
|  | 2107 | } | 
|  | 2108 | break; | 
|  | 2109 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2110 | if (LocaleCompare("depth",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2111 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2112 | /* The _image_info->depth setting has already been set | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2113 | We just need to apply it to all images in current sequence | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2114 |  | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2115 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! | 
|  | 2116 | That is it really is an operation, not a setting! Arrgghhh | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2117 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2118 | FUTURE: this should not be an operator!!! | 
| anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2119 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2120 | (void) SetImageDepth(_image,_image_info->depth,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2121 | break; | 
|  | 2122 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2123 | if (LocaleCompare("deskew",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2124 | { | 
|  | 2125 | double | 
|  | 2126 | threshold; | 
|  | 2127 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2128 | if (IfNormalOp) | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2129 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2130 | else | 
|  | 2131 | threshold=40.0*QuantumRange/100.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2132 | new_image=DeskewImage(_image,threshold,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2133 | break; | 
|  | 2134 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2135 | if (LocaleCompare("despeckle",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2136 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2137 | new_image=DespeckleImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2138 | break; | 
|  | 2139 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2140 | if (LocaleCompare("distort",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2141 | { | 
|  | 2142 | char | 
|  | 2143 | *args, | 
|  | 2144 | token[MaxTextExtent]; | 
|  | 2145 |  | 
|  | 2146 | const char | 
|  | 2147 | *p; | 
|  | 2148 |  | 
|  | 2149 | DistortImageMethod | 
|  | 2150 | method; | 
|  | 2151 |  | 
|  | 2152 | double | 
|  | 2153 | *arguments; | 
|  | 2154 |  | 
|  | 2155 | register ssize_t | 
|  | 2156 | x; | 
|  | 2157 |  | 
|  | 2158 | size_t | 
|  | 2159 | number_arguments; | 
|  | 2160 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2161 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2162 | MagickFalse,arg1); | 
| anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2163 | if (method == ResizeDistortion) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2164 | { | 
| anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2165 | double | 
|  | 2166 | resize_args[2]; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2167 | /* Special Case - Argument is actually a resize geometry! | 
|  | 2168 | ** Convert that to an appropriate distortion argument array. | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2169 | ** FUTURE: make a separate special resize operator | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2170 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2171 | (void) ParseRegionGeometry(_image,arg2,&geometry, | 
|  | 2172 | _exception); | 
| anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2173 | resize_args[0]=(double) geometry.width; | 
|  | 2174 | resize_args[1]=(double) geometry.height; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2175 | new_image=DistortImage(_image,method,(size_t)2, | 
|  | 2176 | resize_args,MagickTrue,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2177 | break; | 
|  | 2178 | } | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2179 | /* handle percent arguments */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2180 | args=InterpretImageProperties(_image_info,_image,arg2, | 
|  | 2181 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2182 | if (args == (char *) NULL) | 
|  | 2183 | break; | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2184 | /* convert arguments into an array of doubles | 
|  | 2185 | FUTURE: make this a separate function. | 
|  | 2186 | Also make use of new 'sentinal' feature to avoid need for | 
|  | 2187 | tokenization. | 
|  | 2188 | */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2189 | p=(char *) args; | 
|  | 2190 | for (x=0; *p != '\0'; x++) | 
|  | 2191 | { | 
|  | 2192 | GetMagickToken(p,&p,token); | 
|  | 2193 | if (*token == ',') | 
|  | 2194 | GetMagickToken(p,&p,token); | 
|  | 2195 | } | 
|  | 2196 | number_arguments=(size_t) x; | 
|  | 2197 | arguments=(double *) AcquireQuantumMemory(number_arguments, | 
|  | 2198 | sizeof(*arguments)); | 
|  | 2199 | if (arguments == (double *) NULL) | 
|  | 2200 | ThrowWandFatalException(ResourceLimitFatalError, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2201 | "MemoryAllocationFailed",_image->filename); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2202 | (void) ResetMagickMemory(arguments,0,number_arguments* | 
|  | 2203 | sizeof(*arguments)); | 
|  | 2204 | p=(char *) args; | 
|  | 2205 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) | 
|  | 2206 | { | 
|  | 2207 | GetMagickToken(p,&p,token); | 
|  | 2208 | if (*token == ',') | 
|  | 2209 | GetMagickToken(p,&p,token); | 
| cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2210 | arguments[x]=StringToDouble(token,(char **) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2211 | } | 
|  | 2212 | args=DestroyString(args); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2213 | new_image=DistortImage(_image,method,number_arguments,arguments, | 
|  | 2214 | plus_alt_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2215 | arguments=(double *) RelinquishMagickMemory(arguments); | 
|  | 2216 | break; | 
|  | 2217 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2218 | if (LocaleCompare("draw",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2219 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2220 | (void) CloneString(&_draw_info->primitive,arg1); | 
|  | 2221 | (void) DrawImage(_image,_draw_info,_exception); | 
|  | 2222 | (void) CloneString(&_draw_info->primitive,(char *)NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2223 | break; | 
|  | 2224 | } | 
|  | 2225 | break; | 
|  | 2226 | } | 
|  | 2227 | case 'e': | 
|  | 2228 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2229 | if (LocaleCompare("edge",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2230 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2231 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2232 | if ((flags & SigmaValue) == 0) | 
|  | 2233 | geometry_info.sigma=1.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2234 | new_image=EdgeImage(_image,geometry_info.rho, | 
|  | 2235 | geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2236 | break; | 
|  | 2237 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2238 | if (LocaleCompare("emboss",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2239 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2240 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2241 | if ((flags & SigmaValue) == 0) | 
|  | 2242 | geometry_info.sigma=1.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2243 | new_image=EmbossImage(_image,geometry_info.rho, | 
|  | 2244 | geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2245 | break; | 
|  | 2246 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2247 | if (LocaleCompare("encipher",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2248 | { | 
|  | 2249 | StringInfo | 
|  | 2250 | *passkey; | 
|  | 2251 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2252 | passkey=FileToStringInfo(arg1,~0,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2253 | if (passkey != (StringInfo *) NULL) | 
|  | 2254 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2255 | (void) PasskeyEncipherImage(_image,passkey,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2256 | passkey=DestroyStringInfo(passkey); | 
|  | 2257 | } | 
|  | 2258 | break; | 
|  | 2259 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2260 | if (LocaleCompare("enhance",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2261 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2262 | new_image=EnhanceImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2263 | break; | 
|  | 2264 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2265 | if (LocaleCompare("equalize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2266 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2267 | (void) EqualizeImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2268 | break; | 
|  | 2269 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2270 | if (LocaleCompare("evaluate",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2271 | { | 
|  | 2272 | double | 
|  | 2273 | constant; | 
|  | 2274 |  | 
|  | 2275 | MagickEvaluateOperator | 
|  | 2276 | op; | 
|  | 2277 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2278 | op=(MagickEvaluateOperator) ParseCommandOption( | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2279 | MagickEvaluateOptions,MagickFalse,arg1); | 
|  | 2280 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2281 | (void) EvaluateImage(_image,op,constant,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2282 | break; | 
|  | 2283 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2284 | if (LocaleCompare("extent",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2285 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2286 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2287 | if (geometry.width == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2288 | geometry.width=_image->columns; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2289 | if (geometry.height == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2290 | geometry.height=_image->rows; | 
|  | 2291 | new_image=ExtentImage(_image,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2292 | break; | 
|  | 2293 | } | 
|  | 2294 | break; | 
|  | 2295 | } | 
|  | 2296 | case 'f': | 
|  | 2297 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2298 | if (LocaleCompare("features",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2299 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2300 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2301 | if (IfPlusOp) { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2302 | (void) DeleteImageArtifact(_image,"identify:features"); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2303 | break; | 
|  | 2304 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2305 | (void) SetImageArtifact(_image,"identify:features","true"); | 
|  | 2306 | (void) SetImageArtifact(_image,"verbose","true"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2307 | break; | 
|  | 2308 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2309 | if (LocaleCompare("flip",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2310 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2311 | new_image=FlipImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2312 | break; | 
|  | 2313 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2314 | if (LocaleCompare("flop",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2315 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2316 | new_image=FlopImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2317 | break; | 
|  | 2318 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2319 | if (LocaleCompare("floodfill",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2320 | { | 
|  | 2321 | PixelInfo | 
|  | 2322 | target; | 
|  | 2323 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2324 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); | 
|  | 2325 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); | 
|  | 2326 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, | 
|  | 2327 | geometry.y,plus_alt_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2328 | break; | 
|  | 2329 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2330 | if (LocaleCompare("frame",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2331 | { | 
|  | 2332 | FrameInfo | 
|  | 2333 | frame_info; | 
|  | 2334 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2335 | CompositeOperator | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2336 | compose; | 
|  | 2337 |  | 
|  | 2338 | const char* | 
|  | 2339 | value; | 
|  | 2340 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2341 | value=GetImageOption(_image_info,"compose"); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2342 | if (value != (const char *) NULL) | 
|  | 2343 | compose=(CompositeOperator) ParseCommandOption( | 
|  | 2344 | MagickComposeOptions,MagickFalse,value); | 
|  | 2345 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2346 | compose=OverCompositeOp;  /* use Over not _image->compose */ | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2347 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2348 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2349 | frame_info.width=geometry.width; | 
|  | 2350 | frame_info.height=geometry.height; | 
|  | 2351 | if ((flags & HeightValue) == 0) | 
|  | 2352 | frame_info.height=geometry.width; | 
|  | 2353 | frame_info.outer_bevel=geometry.x; | 
|  | 2354 | frame_info.inner_bevel=geometry.y; | 
|  | 2355 | frame_info.x=(ssize_t) frame_info.width; | 
|  | 2356 | frame_info.y=(ssize_t) frame_info.height; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2357 | frame_info.width=_image->columns+2*frame_info.width; | 
|  | 2358 | frame_info.height=_image->rows+2*frame_info.height; | 
|  | 2359 | new_image=FrameImage(_image,&frame_info,compose,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2360 | break; | 
|  | 2361 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2362 | if (LocaleCompare("function",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2363 | { | 
|  | 2364 | char | 
|  | 2365 | *arguments, | 
|  | 2366 | token[MaxTextExtent]; | 
|  | 2367 |  | 
|  | 2368 | const char | 
|  | 2369 | *p; | 
|  | 2370 |  | 
|  | 2371 | double | 
|  | 2372 | *parameters; | 
|  | 2373 |  | 
|  | 2374 | MagickFunction | 
|  | 2375 | function; | 
|  | 2376 |  | 
|  | 2377 | register ssize_t | 
|  | 2378 | x; | 
|  | 2379 |  | 
|  | 2380 | size_t | 
|  | 2381 | number_parameters; | 
|  | 2382 |  | 
| cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2383 | /* | 
|  | 2384 | Function Modify Image Values | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2385 | FUTURE: code should be almost a duplicate of that is "distort" | 
| cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2386 | */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2387 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2388 | MagickFalse,arg1); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2389 | arguments=InterpretImageProperties(_image_info,_image,arg2, | 
|  | 2390 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2391 | if (arguments == (char *) NULL) | 
|  | 2392 | break; | 
|  | 2393 | p=(char *) arguments; | 
|  | 2394 | for (x=0; *p != '\0'; x++) | 
|  | 2395 | { | 
|  | 2396 | GetMagickToken(p,&p,token); | 
|  | 2397 | if (*token == ',') | 
|  | 2398 | GetMagickToken(p,&p,token); | 
|  | 2399 | } | 
|  | 2400 | number_parameters=(size_t) x; | 
|  | 2401 | parameters=(double *) AcquireQuantumMemory(number_parameters, | 
|  | 2402 | sizeof(*parameters)); | 
|  | 2403 | if (parameters == (double *) NULL) | 
|  | 2404 | ThrowWandFatalException(ResourceLimitFatalError, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2405 | "MemoryAllocationFailed",_image->filename); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2406 | (void) ResetMagickMemory(parameters,0,number_parameters* | 
|  | 2407 | sizeof(*parameters)); | 
|  | 2408 | p=(char *) arguments; | 
|  | 2409 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) | 
|  | 2410 | { | 
|  | 2411 | GetMagickToken(p,&p,token); | 
|  | 2412 | if (*token == ',') | 
|  | 2413 | GetMagickToken(p,&p,token); | 
| cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 2414 | parameters[x]=StringToDouble(token,(char **) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2415 | } | 
|  | 2416 | arguments=DestroyString(arguments); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2417 | (void) FunctionImage(_image,function,number_parameters,parameters, | 
|  | 2418 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2419 | parameters=(double *) RelinquishMagickMemory(parameters); | 
|  | 2420 | break; | 
|  | 2421 | } | 
|  | 2422 | break; | 
|  | 2423 | } | 
|  | 2424 | case 'g': | 
|  | 2425 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2426 | if (LocaleCompare("gamma",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2427 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2428 | if (IfNormalOp) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2429 | (void) GammaImage(_image,StringToDouble(arg1,(char **) NULL), | 
|  | 2430 | _exception); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2431 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2432 | _image->gamma=StringToDouble(arg1,(char **) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2433 | break; | 
|  | 2434 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2435 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || | 
|  | 2436 | (LocaleCompare("gaussian",option+1) == 0)) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2437 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2438 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2439 | if ((flags & SigmaValue) == 0) | 
|  | 2440 | geometry_info.sigma=1.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2441 | new_image=GaussianBlurImage(_image,geometry_info.rho, | 
|  | 2442 | geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2443 | break; | 
|  | 2444 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2445 | if (LocaleCompare("geometry",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2446 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2447 | /* | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2448 | Record Image offset for composition. (A Setting) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2449 | Resize last _image. (ListOperator) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2450 | FUTURE: Why if no 'offset' does this resize ALL images? | 
|  | 2451 | Also why is the setting recorded in the IMAGE non-sense! | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2452 | */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2453 | if (IfPlusOp) | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2454 | { /* remove the previous composition geometry offset! */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2455 | if (_image->geometry != (char *) NULL) | 
|  | 2456 | _image->geometry=DestroyString(_image->geometry); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2457 | break; | 
|  | 2458 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2459 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2460 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2461 | (void) CloneString(&_image->geometry,arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2462 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2463 | new_image=ResizeImage(_image,geometry.width,geometry.height, | 
|  | 2464 | _image->filter,_image->blur,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2465 | break; | 
|  | 2466 | } | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2467 | break; | 
|  | 2468 | } | 
|  | 2469 | case 'h': | 
|  | 2470 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2471 | if (LocaleCompare("highlight-color",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2472 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2473 | (void) SetImageArtifact(_image,option+1,arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2474 | break; | 
|  | 2475 | } | 
|  | 2476 | break; | 
|  | 2477 | } | 
|  | 2478 | case 'i': | 
|  | 2479 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2480 | if (LocaleCompare("identify",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2481 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2482 | const char | 
|  | 2483 | *format, | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2484 | *text; | 
|  | 2485 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2486 | format=GetImageOption(_image_info,"format"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2487 | if (format == (char *) NULL) | 
|  | 2488 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2489 | (void) IdentifyImage(_image,stdout,_image_info->verbose, | 
|  | 2490 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2491 | break; | 
|  | 2492 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2493 | text=InterpretImageProperties(_image_info,_image,format,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2494 | if (text == (char *) NULL) | 
|  | 2495 | break; | 
|  | 2496 | (void) fputs(text,stdout); | 
|  | 2497 | (void) fputc('\n',stdout); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2498 | text=DestroyString((char *)text); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2499 | break; | 
|  | 2500 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2501 | if (LocaleCompare("implode",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2502 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2503 | (void) ParseGeometry(arg1,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2504 | new_image=ImplodeImage(_image,geometry_info.rho, | 
|  | 2505 | _image->interpolate,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2506 | break; | 
|  | 2507 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2508 | if (LocaleCompare("interpolative-resize",option+1) == 0) | 
| cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2509 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2510 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); | 
|  | 2511 | new_image=InterpolativeResizeImage(_image,geometry.width, | 
|  | 2512 | geometry.height,_image->interpolate,_exception); | 
| cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2513 | break; | 
|  | 2514 | } | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2515 | break; | 
|  | 2516 | } | 
|  | 2517 | case 'l': | 
|  | 2518 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2519 | if (LocaleCompare("lat",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2520 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2521 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2522 | if ((flags & PercentValue) != 0) | 
|  | 2523 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2524 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2525 | (size_t) geometry_info.sigma,(double) geometry_info.xi, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2526 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2527 | break; | 
|  | 2528 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2529 | if (LocaleCompare("level",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2530 | { | 
|  | 2531 | MagickRealType | 
|  | 2532 | black_point, | 
|  | 2533 | gamma, | 
|  | 2534 | white_point; | 
|  | 2535 |  | 
|  | 2536 | MagickStatusType | 
|  | 2537 | flags; | 
|  | 2538 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2539 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2540 | black_point=geometry_info.rho; | 
|  | 2541 | white_point=(MagickRealType) QuantumRange; | 
|  | 2542 | if ((flags & SigmaValue) != 0) | 
|  | 2543 | white_point=geometry_info.sigma; | 
|  | 2544 | gamma=1.0; | 
|  | 2545 | if ((flags & XiValue) != 0) | 
|  | 2546 | gamma=geometry_info.xi; | 
|  | 2547 | if ((flags & PercentValue) != 0) | 
|  | 2548 | { | 
|  | 2549 | black_point*=(MagickRealType) (QuantumRange/100.0); | 
|  | 2550 | white_point*=(MagickRealType) (QuantumRange/100.0); | 
|  | 2551 | } | 
|  | 2552 | if ((flags & SigmaValue) == 0) | 
|  | 2553 | white_point=(MagickRealType) QuantumRange-black_point; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2554 | if (IfPlusOp || ((flags & AspectValue) != 0)) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2555 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2556 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2557 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2558 | break; | 
|  | 2559 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2560 | if (LocaleCompare("level-colors",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2561 | { | 
|  | 2562 | char | 
|  | 2563 | token[MaxTextExtent]; | 
|  | 2564 |  | 
|  | 2565 | const char | 
|  | 2566 | *p; | 
|  | 2567 |  | 
|  | 2568 | PixelInfo | 
|  | 2569 | black_point, | 
|  | 2570 | white_point; | 
|  | 2571 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2572 | p=(const char *) arg1; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2573 | GetMagickToken(p,&p,token);  /* get black point color */ | 
|  | 2574 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) | 
| cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2575 | (void) QueryColorCompliance(token,AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2576 | &black_point,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2577 | else | 
| cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2578 | (void) QueryColorCompliance("#000000",AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2579 | &black_point,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2580 | if (isalpha((int) token[0]) || (token[0] == '#')) | 
|  | 2581 | GetMagickToken(p,&p,token); | 
|  | 2582 | if (*token == '\0') | 
|  | 2583 | white_point=black_point; /* set everything to that color */ | 
|  | 2584 | else | 
|  | 2585 | { | 
|  | 2586 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) | 
|  | 2587 | GetMagickToken(p,&p,token); /* Get white point color. */ | 
|  | 2588 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) | 
| cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2589 | (void) QueryColorCompliance(token,AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2590 | &white_point,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2591 | else | 
| cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2592 | (void) QueryColorCompliance("#ffffff",AllCompliance, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2593 | &white_point,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2594 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2595 | (void) LevelImageColors(_image,&black_point,&white_point, | 
|  | 2596 | plus_alt_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2597 | break; | 
|  | 2598 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2599 | if (LocaleCompare("linear-stretch",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2600 | { | 
|  | 2601 | double | 
|  | 2602 | black_point, | 
|  | 2603 | white_point; | 
|  | 2604 |  | 
|  | 2605 | MagickStatusType | 
|  | 2606 | flags; | 
|  | 2607 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2608 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2609 | black_point=geometry_info.rho; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2610 | white_point=(MagickRealType) _image->columns*_image->rows; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2611 | if ((flags & SigmaValue) != 0) | 
|  | 2612 | white_point=geometry_info.sigma; | 
|  | 2613 | if ((flags & PercentValue) != 0) | 
|  | 2614 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2615 | black_point*=(double) _image->columns*_image->rows/100.0; | 
|  | 2616 | white_point*=(double) _image->columns*_image->rows/100.0; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2617 | } | 
|  | 2618 | if ((flags & SigmaValue) == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2619 | white_point=(MagickRealType) _image->columns*_image->rows- | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2620 | black_point; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2621 | (void) LinearStretchImage(_image,black_point,white_point,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2622 | break; | 
|  | 2623 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2624 | if (LocaleCompare("liquid-rescale",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2625 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2626 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2627 | if ((flags & XValue) == 0) | 
|  | 2628 | geometry.x=1; | 
|  | 2629 | if ((flags & YValue) == 0) | 
|  | 2630 | geometry.y=0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2631 | new_image=LiquidRescaleImage(_image,geometry.width, | 
|  | 2632 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2633 | break; | 
|  | 2634 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2635 | if (LocaleCompare("lowlight-color",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2636 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2637 | (void) SetImageArtifact(_image,option+1,arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2638 | break; | 
|  | 2639 | } | 
|  | 2640 | break; | 
|  | 2641 | } | 
|  | 2642 | case 'm': | 
|  | 2643 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2644 | if (LocaleCompare("map",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2645 | { | 
|  | 2646 | Image | 
|  | 2647 | *remap_image; | 
|  | 2648 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2649 | /* DEPRECIATED use -remap */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2650 | remap_image=GetImageCache(_image_info,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2651 | if (remap_image == (Image *) NULL) | 
|  | 2652 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2653 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2654 | remap_image=DestroyImage(remap_image); | 
|  | 2655 | break; | 
|  | 2656 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2657 | if (LocaleCompare("mask",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2658 | { | 
|  | 2659 | Image | 
|  | 2660 | *mask; | 
|  | 2661 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2662 | if (IfPlusOp) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2663 | { /* Remove a mask. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2664 | (void) SetImageMask(_image,(Image *) NULL,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2665 | break; | 
|  | 2666 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2667 | /* Set the _image mask. */ | 
|  | 2668 | mask=GetImageCache(_image_info,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2669 | if (mask == (Image *) NULL) | 
|  | 2670 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2671 | (void) SetImageMask(_image,mask,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2672 | mask=DestroyImage(mask); | 
|  | 2673 | break; | 
|  | 2674 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2675 | if (LocaleCompare("matte",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2676 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2677 | /* DEPRECIATED */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2678 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : | 
|  | 2679 | DeactivateAlphaChannel, _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2680 | break; | 
|  | 2681 | } | 
| anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 2682 | if (LocaleCompare("median",option+1) == 0) | 
|  | 2683 | { | 
|  | 2684 | /* DEPRECIATED - use -statistic Median */ | 
|  | 2685 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); | 
|  | 2686 | break; | 
|  | 2687 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2688 | if (LocaleCompare("mode",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2689 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2690 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2691 | if ((flags & SigmaValue) == 0) | 
|  | 2692 | geometry_info.sigma=geometry_info.rho; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2693 | new_image=StatisticImage(_image,ModeStatistic,(size_t) | 
|  | 2694 | geometry_info.rho,(size_t) geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2695 | break; | 
|  | 2696 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2697 | if (LocaleCompare("modulate",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2698 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2699 | (void) ModulateImage(_image,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2700 | break; | 
|  | 2701 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2702 | if (LocaleCompare("monitor",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2703 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2704 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2705 | (MagickProgressMonitor) NULL,(void *) NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2706 | break; | 
|  | 2707 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2708 | if (LocaleCompare("monochrome",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2709 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2710 | (void) SetImageType(_image,BilevelType,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2711 | break; | 
|  | 2712 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2713 | if (LocaleCompare("morphology",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2714 | { | 
|  | 2715 | char | 
|  | 2716 | token[MaxTextExtent]; | 
|  | 2717 |  | 
|  | 2718 | const char | 
|  | 2719 | *p; | 
|  | 2720 |  | 
|  | 2721 | KernelInfo | 
|  | 2722 | *kernel; | 
|  | 2723 |  | 
|  | 2724 | MorphologyMethod | 
|  | 2725 | method; | 
|  | 2726 |  | 
|  | 2727 | ssize_t | 
|  | 2728 | iterations; | 
|  | 2729 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2730 | p=arg1; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2731 | GetMagickToken(p,&p,token); | 
|  | 2732 | method=(MorphologyMethod) ParseCommandOption( | 
|  | 2733 | MagickMorphologyOptions,MagickFalse,token); | 
|  | 2734 | iterations=1L; | 
|  | 2735 | GetMagickToken(p,&p,token); | 
|  | 2736 | if ((*p == ':') || (*p == ',')) | 
|  | 2737 | GetMagickToken(p,&p,token); | 
|  | 2738 | if ((*p != '\0')) | 
|  | 2739 | iterations=(ssize_t) StringToLong(p); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2740 | kernel=AcquireKernelInfo(arg2); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2741 | if (kernel == (KernelInfo *) NULL) | 
|  | 2742 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2743 | (void) ThrowMagickException(_exception,GetMagickModule(), | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2744 | OptionError,"UnabletoParseKernel","morphology"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2745 | break; | 
|  | 2746 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2747 | new_image=MorphologyImage(_image,method,iterations,kernel,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2748 | kernel=DestroyKernelInfo(kernel); | 
|  | 2749 | break; | 
|  | 2750 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2751 | if (LocaleCompare("motion-blur",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2752 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2753 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2754 | if ((flags & SigmaValue) == 0) | 
|  | 2755 | geometry_info.sigma=1.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2756 | new_image=MotionBlurImage(_image,geometry_info.rho, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2757 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2758 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2759 | break; | 
|  | 2760 | } | 
|  | 2761 | break; | 
|  | 2762 | } | 
|  | 2763 | case 'n': | 
|  | 2764 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2765 | if (LocaleCompare("negate",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2766 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2767 | (void) NegateImage(_image, plus_alt_op, _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2768 | break; | 
|  | 2769 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2770 | if (LocaleCompare("noise",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2771 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2772 | if (IfNormalOp) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2773 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2774 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2775 | if ((flags & SigmaValue) == 0) | 
|  | 2776 | geometry_info.sigma=geometry_info.rho; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2777 | new_image=StatisticImage(_image,NonpeakStatistic,(size_t) | 
|  | 2778 | geometry_info.rho,(size_t) geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2779 | } | 
|  | 2780 | else | 
|  | 2781 | { | 
|  | 2782 | NoiseType | 
|  | 2783 | noise; | 
|  | 2784 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2785 | double | 
|  | 2786 | attenuate; | 
|  | 2787 |  | 
|  | 2788 | const char* | 
|  | 2789 | value; | 
|  | 2790 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2791 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2792 | MagickFalse,arg1), | 
|  | 2793 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2794 | value=GetImageOption(_image_info,"attenuate"); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2795 | if  (value != (const char *) NULL) | 
|  | 2796 | attenuate=StringToDouble(value,(char **) NULL); | 
|  | 2797 | else | 
|  | 2798 | attenuate=1.0; | 
|  | 2799 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2800 | new_image=AddNoiseImage(_image,noise,attenuate,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2801 | } | 
|  | 2802 | break; | 
|  | 2803 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2804 | if (LocaleCompare("normalize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2805 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2806 | (void) NormalizeImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2807 | break; | 
|  | 2808 | } | 
|  | 2809 | break; | 
|  | 2810 | } | 
|  | 2811 | case 'o': | 
|  | 2812 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2813 | if (LocaleCompare("opaque",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2814 | { | 
|  | 2815 | PixelInfo | 
|  | 2816 | target; | 
|  | 2817 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2818 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); | 
|  | 2819 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,plus_alt_op, | 
|  | 2820 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2821 | break; | 
|  | 2822 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2823 | if (LocaleCompare("ordered-dither",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2824 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2825 | (void) OrderedPosterizeImage(_image,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2826 | break; | 
|  | 2827 | } | 
|  | 2828 | break; | 
|  | 2829 | } | 
|  | 2830 | case 'p': | 
|  | 2831 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2832 | if (LocaleCompare("paint",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2833 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2834 | (void) ParseGeometry(arg1,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2835 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, | 
|  | 2836 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2837 | break; | 
|  | 2838 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2839 | if (LocaleCompare("polaroid",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2840 | { | 
| cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2841 | const char | 
|  | 2842 | *caption; | 
|  | 2843 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2844 | double | 
|  | 2845 | angle; | 
|  | 2846 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2847 | if (IfPlusOp) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2848 | { | 
|  | 2849 | RandomInfo | 
|  | 2850 | *random_info; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2851 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2852 | random_info=AcquireRandomInfo(); | 
|  | 2853 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); | 
|  | 2854 | random_info=DestroyRandomInfo(random_info); | 
|  | 2855 | } | 
|  | 2856 | else | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2857 | { | 
|  | 2858 | SetGeometryInfo(&geometry_info); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2859 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2860 | angle=geometry_info.rho; | 
|  | 2861 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2862 | caption=GetImageProperty(_image,"caption",_exception); | 
|  | 2863 | new_image=PolaroidImage(_image,_draw_info,caption,angle, | 
|  | 2864 | _image->interpolate,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2865 | break; | 
|  | 2866 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2867 | if (LocaleCompare("posterize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2868 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2869 | (void) ParseGeometry(arg1,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2870 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, | 
|  | 2871 | _quantize_info->dither,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2872 | break; | 
|  | 2873 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2874 | if (LocaleCompare("preview",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2875 | { | 
|  | 2876 | PreviewType | 
| cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2877 | preview_type; | 
| anthony | 170fce9 | 2011-10-20 11:50:23 +0000 | [diff] [blame] | 2878 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2879 | /* FUTURE: should be a 'Genesis' option? | 
|  | 2880 | Option however is also in WandSettingOptionInfo() | 
| cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2881 | */ | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2882 | preview_type=UndefinedPreview; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2883 | if (IfNormalOp) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2884 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, | 
|  | 2885 | MagickFalse,arg1); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2886 | new_image=PreviewImage(_image,preview_type,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2887 | break; | 
|  | 2888 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2889 | if (LocaleCompare("profile",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2890 | { | 
|  | 2891 | const char | 
|  | 2892 | *name; | 
|  | 2893 |  | 
|  | 2894 | const StringInfo | 
|  | 2895 | *profile; | 
|  | 2896 |  | 
|  | 2897 | Image | 
|  | 2898 | *profile_image; | 
|  | 2899 |  | 
|  | 2900 | ImageInfo | 
|  | 2901 | *profile_info; | 
|  | 2902 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2903 | if (IfPlusOp) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2904 | { /* Remove a profile from the _image.  */ | 
|  | 2905 | (void) ProfileImage(_image,arg1,(const unsigned char *) | 
|  | 2906 | NULL,0,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2907 | break; | 
|  | 2908 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2909 | /* Associate a profile with the _image.  */ | 
|  | 2910 | profile_info=CloneImageInfo(_image_info); | 
|  | 2911 | profile=GetImageProfile(_image,"iptc"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2912 | if (profile != (StringInfo *) NULL) | 
|  | 2913 | profile_info->profile=(void *) CloneStringInfo(profile); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2914 | profile_image=GetImageCache(profile_info,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2915 | profile_info=DestroyImageInfo(profile_info); | 
|  | 2916 | if (profile_image == (Image *) NULL) | 
|  | 2917 | { | 
|  | 2918 | StringInfo | 
|  | 2919 | *profile; | 
|  | 2920 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2921 | profile_info=CloneImageInfo(_image_info); | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2922 | (void) CopyMagickString(profile_info->filename,arg1, | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2923 | MaxTextExtent); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2924 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2925 | if (profile != (StringInfo *) NULL) | 
|  | 2926 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2927 | (void) ProfileImage(_image,profile_info->magick, | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2928 | GetStringInfoDatum(profile),(size_t) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2929 | GetStringInfoLength(profile),_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2930 | profile=DestroyStringInfo(profile); | 
|  | 2931 | } | 
|  | 2932 | profile_info=DestroyImageInfo(profile_info); | 
|  | 2933 | break; | 
|  | 2934 | } | 
|  | 2935 | ResetImageProfileIterator(profile_image); | 
|  | 2936 | name=GetNextImageProfile(profile_image); | 
|  | 2937 | while (name != (const char *) NULL) | 
|  | 2938 | { | 
|  | 2939 | profile=GetImageProfile(profile_image,name); | 
|  | 2940 | if (profile != (StringInfo *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2941 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), | 
|  | 2942 | (size_t) GetStringInfoLength(profile),_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2943 | name=GetNextImageProfile(profile_image); | 
|  | 2944 | } | 
|  | 2945 | profile_image=DestroyImage(profile_image); | 
|  | 2946 | break; | 
|  | 2947 | } | 
|  | 2948 | break; | 
|  | 2949 | } | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2950 | case 'r': | 
|  | 2951 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2952 | if (LocaleCompare("radial-blur",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2953 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2954 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2955 | new_image=RadialBlurImage(_image,geometry_info.rho, | 
|  | 2956 | geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2957 | break; | 
|  | 2958 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2959 | if (LocaleCompare("raise",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2960 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2961 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2962 | if ((flags & SigmaValue) == 0) | 
|  | 2963 | geometry.height=geometry.width; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2964 | (void) RaiseImage(_image,&geometry,normal_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2965 | break; | 
|  | 2966 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2967 | if (LocaleCompare("random-threshold",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2968 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2969 | (void) RandomThresholdImage(_image,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2970 | break; | 
|  | 2971 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2972 | if (LocaleCompare("remap",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2973 | { | 
|  | 2974 | Image | 
|  | 2975 | *remap_image; | 
|  | 2976 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2977 | remap_image=GetImageCache(_image_info,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2978 | if (remap_image == (Image *) NULL) | 
|  | 2979 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2980 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2981 | remap_image=DestroyImage(remap_image); | 
|  | 2982 | break; | 
|  | 2983 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2984 | if (LocaleCompare("repage",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2985 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2986 | if (IfNormalOp) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2987 | (void) ResetImagePage(_image,arg1); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2988 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2989 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2990 | break; | 
|  | 2991 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2992 | if (LocaleCompare("resample",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2993 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2994 | /* FUTURE: remove blur arguemnt - no longer used */ | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2995 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2996 | if ((flags & SigmaValue) == 0) | 
|  | 2997 | geometry_info.sigma=geometry_info.rho; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 2998 | new_image=ResampleImage(_image,geometry_info.rho, | 
|  | 2999 | geometry_info.sigma,_image->filter,_image->blur,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3000 | break; | 
|  | 3001 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3002 | if (LocaleCompare("resize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3003 | { | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 3004 | /* FUTURE: remove blur argument - no longer used */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3005 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); | 
|  | 3006 | new_image=ResizeImage(_image,geometry.width,geometry.height, | 
|  | 3007 | _image->filter,_image->blur,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3008 | break; | 
|  | 3009 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3010 | if (LocaleCompare("roll",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3011 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3012 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); | 
|  | 3013 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3014 | break; | 
|  | 3015 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3016 | if (LocaleCompare("rotate",option+1) == 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 | if (strchr(arg1,'>') != (char *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3019 | if (_image->columns <= _image->rows) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3020 | break; | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3021 | if (strchr(arg1,'<') != (char *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3022 | if (_image->columns >= _image->rows) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3023 | break; | 
| anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 3024 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3025 | (void) ParseGeometry(arg1,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3026 | new_image=RotateImage(_image,geometry_info.rho,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3027 | break; | 
|  | 3028 | } | 
|  | 3029 | break; | 
|  | 3030 | } | 
|  | 3031 | case 's': | 
|  | 3032 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3033 | if (LocaleCompare("sample",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3034 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3035 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); | 
|  | 3036 | new_image=SampleImage(_image,geometry.width,geometry.height, | 
|  | 3037 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3038 | break; | 
|  | 3039 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3040 | if (LocaleCompare("scale",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3041 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3042 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); | 
|  | 3043 | new_image=ScaleImage(_image,geometry.width,geometry.height, | 
|  | 3044 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3045 | break; | 
|  | 3046 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3047 | if (LocaleCompare("selective-blur",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3048 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3049 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3050 | if ((flags & PercentValue) != 0) | 
|  | 3051 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3052 | new_image=SelectiveBlurImage(_image,geometry_info.rho, | 
|  | 3053 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3054 | break; | 
|  | 3055 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3056 | if (LocaleCompare("separate",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3057 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3058 | /* WARNING: This can generate multiple images! */ | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3059 | /* FUTURE - this may be replaced by a "-channel" method */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3060 | new_image=SeparateImages(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3061 | break; | 
|  | 3062 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3063 | if (LocaleCompare("sepia-tone",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3064 | { | 
|  | 3065 | double | 
|  | 3066 | threshold; | 
|  | 3067 |  | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3068 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3069 | new_image=SepiaToneImage(_image,threshold,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3070 | break; | 
|  | 3071 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3072 | if (LocaleCompare("segment",option+1) == 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; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3077 | (void) SegmentImage(_image,_image->colorspace, | 
|  | 3078 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, | 
|  | 3079 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3080 | break; | 
|  | 3081 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3082 | if (LocaleCompare("set",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3083 | { | 
|  | 3084 | char | 
|  | 3085 | *value; | 
|  | 3086 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3087 | if (IfPlusOp) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3088 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3089 | if (LocaleNCompare(arg1,"registry:",9) == 0) | 
|  | 3090 | (void) DeleteImageRegistry(arg1+9); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3091 | else | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3092 | if (LocaleNCompare(arg1,"option:",7) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3093 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3094 | (void) DeleteImageOption(_image_info,arg1+7); | 
|  | 3095 | (void) DeleteImageArtifact(_image,arg1+7); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3096 | } | 
|  | 3097 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3098 | (void) DeleteImageProperty(_image,arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3099 | break; | 
|  | 3100 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3101 | value=InterpretImageProperties(_image_info,_image,arg2, | 
|  | 3102 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3103 | if (value == (char *) NULL) | 
|  | 3104 | break; | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3105 | if (LocaleNCompare(arg1,"registry:",9) == 0) | 
|  | 3106 | (void) SetImageRegistry(StringRegistryType,arg1+9,value, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3107 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3108 | else | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3109 | if (LocaleNCompare(arg1,"option:",7) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3110 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3111 | (void) SetImageOption(_image_info,arg1+7,value); | 
|  | 3112 | (void) SetImageArtifact(_image,arg1+7,value); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3113 | } | 
|  | 3114 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3115 | (void) SetImageProperty(_image,arg1,value,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3116 | value=DestroyString(value); | 
|  | 3117 | break; | 
|  | 3118 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3119 | if (LocaleCompare("shade",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3120 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3121 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3122 | if ((flags & SigmaValue) == 0) | 
|  | 3123 | geometry_info.sigma=1.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3124 | new_image=ShadeImage(_image,normal_op,geometry_info.rho, | 
|  | 3125 | geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3126 | break; | 
|  | 3127 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3128 | if (LocaleCompare("shadow",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3129 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3130 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3131 | if ((flags & SigmaValue) == 0) | 
|  | 3132 | geometry_info.sigma=1.0; | 
|  | 3133 | if ((flags & XiValue) == 0) | 
|  | 3134 | geometry_info.xi=4.0; | 
|  | 3135 | if ((flags & PsiValue) == 0) | 
|  | 3136 | geometry_info.psi=4.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3137 | new_image=ShadowImage(_image,geometry_info.rho, | 
|  | 3138 | geometry_info.sigma,_image->bias,(ssize_t) | 
| cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 3139 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3140 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3141 | break; | 
|  | 3142 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3143 | if (LocaleCompare("sharpen",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3144 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3145 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3146 | if ((flags & SigmaValue) == 0) | 
|  | 3147 | geometry_info.sigma=1.0; | 
|  | 3148 | if ((flags & XiValue) == 0) | 
|  | 3149 | geometry_info.xi=0.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3150 | new_image=SharpenImage(_image,geometry_info.rho, | 
|  | 3151 | geometry_info.sigma,geometry_info.xi,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3152 | break; | 
|  | 3153 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3154 | if (LocaleCompare("shave",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3155 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3156 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); | 
|  | 3157 | new_image=ShaveImage(_image,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3158 | break; | 
|  | 3159 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3160 | if (LocaleCompare("shear",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3161 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3162 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3163 | if ((flags & SigmaValue) == 0) | 
|  | 3164 | geometry_info.sigma=geometry_info.rho; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3165 | new_image=ShearImage(_image,geometry_info.rho, | 
|  | 3166 | geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3167 | break; | 
|  | 3168 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3169 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3170 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3171 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3172 | if ((flags & SigmaValue) == 0) | 
|  | 3173 | geometry_info.sigma=(double) QuantumRange/2.0; | 
|  | 3174 | if ((flags & PercentValue) != 0) | 
|  | 3175 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ | 
|  | 3176 | 100.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3177 | (void) SigmoidalContrastImage(_image,normal_op,geometry_info.rho, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3178 | geometry_info.sigma, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3179 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3180 | break; | 
|  | 3181 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3182 | if (LocaleCompare("sketch",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3183 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3184 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3185 | if ((flags & SigmaValue) == 0) | 
|  | 3186 | geometry_info.sigma=1.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3187 | new_image=SketchImage(_image,geometry_info.rho, | 
|  | 3188 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3189 | break; | 
|  | 3190 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3191 | if (LocaleCompare("solarize",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3192 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3193 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) | 
|  | 3194 | QuantumRange+1.0),_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3195 | break; | 
|  | 3196 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3197 | if (LocaleCompare("sparse-color",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3198 | { | 
|  | 3199 | SparseColorMethod | 
|  | 3200 | method; | 
|  | 3201 |  | 
|  | 3202 | char | 
|  | 3203 | *arguments; | 
|  | 3204 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3205 | method=(SparseColorMethod) ParseCommandOption( | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3206 | MagickSparseColorOptions,MagickFalse,arg1); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3207 | arguments=InterpretImageProperties(_image_info,_image,arg2,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3208 | if (arguments == (char *) NULL) | 
|  | 3209 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3210 | new_image=SparseColorOption(_image,method,arguments,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3211 | arguments=DestroyString(arguments); | 
|  | 3212 | break; | 
|  | 3213 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3214 | if (LocaleCompare("splice",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3215 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3216 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); | 
|  | 3217 | new_image=SpliceImage(_image,&geometry,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3218 | break; | 
|  | 3219 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3220 | if (LocaleCompare("spread",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3221 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3222 | (void) ParseGeometry(arg1,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3223 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, | 
|  | 3224 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3225 | break; | 
|  | 3226 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3227 | if (LocaleCompare("statistic",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3228 | { | 
|  | 3229 | StatisticType | 
|  | 3230 | type; | 
|  | 3231 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3232 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3233 | MagickFalse,arg1); | 
|  | 3234 | (void) ParseGeometry(arg2,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3235 | new_image=StatisticImage(_image,type,(size_t) geometry_info.rho, | 
|  | 3236 | (size_t) geometry_info.sigma,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3237 | break; | 
|  | 3238 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3239 | if (LocaleCompare("strip",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3240 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3241 | (void) StripImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3242 | break; | 
|  | 3243 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3244 | if (LocaleCompare("swirl",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3245 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3246 | (void) ParseGeometry(arg1,&geometry_info); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3247 | new_image=SwirlImage(_image,geometry_info.rho, | 
|  | 3248 | _image->interpolate,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3249 | break; | 
|  | 3250 | } | 
|  | 3251 | break; | 
|  | 3252 | } | 
|  | 3253 | case 't': | 
|  | 3254 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3255 | if (LocaleCompare("threshold",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3256 | { | 
|  | 3257 | double | 
|  | 3258 | threshold; | 
|  | 3259 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3260 | if (!normal_op) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3261 | threshold=(double) QuantumRange/2; | 
|  | 3262 | else | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3263 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3264 | (void) BilevelImage(_image,threshold,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3265 | break; | 
|  | 3266 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3267 | if (LocaleCompare("thumbnail",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3268 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3269 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); | 
|  | 3270 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, | 
|  | 3271 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3272 | break; | 
|  | 3273 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3274 | if (LocaleCompare("tint",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3275 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3276 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3277 | break; | 
|  | 3278 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3279 | if (LocaleCompare("transform",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3280 | { | 
| anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 3281 | /* DEPRECIATED -- should really use Distort AffineProjection */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3282 | new_image=AffineTransformImage(_image,&_draw_info->affine, | 
|  | 3283 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3284 | break; | 
|  | 3285 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3286 | if (LocaleCompare("transparent",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3287 | { | 
|  | 3288 | PixelInfo | 
|  | 3289 | target; | 
|  | 3290 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3291 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); | 
|  | 3292 | (void) TransparentPaintImage(_image,&target,(Quantum) | 
|  | 3293 | TransparentAlpha,plus_alt_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3294 | break; | 
|  | 3295 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3296 | if (LocaleCompare("transpose",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3297 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3298 | new_image=TransposeImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3299 | break; | 
|  | 3300 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3301 | if (LocaleCompare("transverse",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3302 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3303 | new_image=TransverseImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3304 | break; | 
|  | 3305 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3306 | if (LocaleCompare("trim",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3307 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3308 | new_image=TrimImage(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3309 | break; | 
|  | 3310 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3311 | if (LocaleCompare("type",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3312 | { | 
| anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3313 | /* Note that "type" setting should have already been defined */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3314 | (void) SetImageType(_image,_image_info->type,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3315 | break; | 
|  | 3316 | } | 
|  | 3317 | break; | 
|  | 3318 | } | 
|  | 3319 | case 'u': | 
|  | 3320 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3321 | if (LocaleCompare("unique",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3322 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3323 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 3324 | /* FUTURE: This option is not documented!!!!! */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3325 | if (!normal_op) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3326 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3327 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3328 | break; | 
|  | 3329 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3330 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); | 
|  | 3331 | (void) SetImageArtifact(_image,"verbose","true"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3332 | break; | 
|  | 3333 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3334 | if (LocaleCompare("unique-colors",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3335 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3336 | new_image=UniqueImageColors(_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3337 | break; | 
|  | 3338 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3339 | if (LocaleCompare("unsharp",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3340 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3341 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3342 | if ((flags & SigmaValue) == 0) | 
|  | 3343 | geometry_info.sigma=1.0; | 
|  | 3344 | if ((flags & XiValue) == 0) | 
|  | 3345 | geometry_info.xi=1.0; | 
|  | 3346 | if ((flags & PsiValue) == 0) | 
|  | 3347 | geometry_info.psi=0.05; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3348 | new_image=UnsharpMaskImage(_image,geometry_info.rho, | 
|  | 3349 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3350 | break; | 
|  | 3351 | } | 
|  | 3352 | break; | 
|  | 3353 | } | 
|  | 3354 | case 'v': | 
|  | 3355 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3356 | if (LocaleCompare("verbose",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3357 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3358 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3359 | three places!   ImageArtifact   ImageOption  _image_info->verbose | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3360 | Some how new images also get this artifact presumably here | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3361 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3362 | (void) SetImageArtifact(_image,option+1, | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3363 | IfNormalOp ? "true" : "false" ); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3364 | break; | 
|  | 3365 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3366 | if (LocaleCompare("vignette",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3367 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3368 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3369 | if ((flags & SigmaValue) == 0) | 
|  | 3370 | geometry_info.sigma=1.0; | 
|  | 3371 | if ((flags & XiValue) == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3372 | geometry_info.xi=0.1*_image->columns; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3373 | if ((flags & PsiValue) == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3374 | geometry_info.psi=0.1*_image->rows; | 
|  | 3375 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, | 
|  | 3376 | _image->bias,(ssize_t) ceil(geometry_info.xi-0.5), | 
|  | 3377 | (ssize_t) ceil(geometry_info.psi-0.5),_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3378 | break; | 
|  | 3379 | } | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3380 | break; | 
|  | 3381 | } | 
|  | 3382 | case 'w': | 
|  | 3383 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3384 | if (LocaleCompare("wave",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3385 | { | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3386 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3387 | if ((flags & SigmaValue) == 0) | 
|  | 3388 | geometry_info.sigma=1.0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3389 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, | 
|  | 3390 | _image->interpolate,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3391 | break; | 
|  | 3392 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3393 | if (LocaleCompare("white-threshold",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3394 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3395 | (void) WhiteThresholdImage(_image,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3396 | break; | 
|  | 3397 | } | 
|  | 3398 | break; | 
|  | 3399 | } | 
|  | 3400 | default: | 
|  | 3401 | break; | 
|  | 3402 | } | 
|  | 3403 | /* | 
|  | 3404 | Replace current image with any image that was generated | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3405 | and set image point to last image (so image->next is correct) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3406 | */ | 
|  | 3407 | if (new_image != (Image *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3408 | ReplaceImageInListReturnLast(&_image,new_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3409 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3410 | return; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3411 | #undef _image_info | 
|  | 3412 | #undef _draw_info | 
|  | 3413 | #undef _quantize_info | 
|  | 3414 | #undef _image | 
|  | 3415 | #undef _exception | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3416 | #undef IfNormalOp | 
|  | 3417 | #undef IfPlusOp | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3418 | #undef normal_op | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3419 | #undef plus_alt_op | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3420 | } | 
| anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3421 |  | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3422 | WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand, | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3423 | const char *option, const char *arg1, const char *arg2) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3424 | { | 
|  | 3425 | size_t | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3426 | n, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3427 | i; | 
|  | 3428 |  | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3429 | assert(cli_wand != (MagickCLI *) NULL); | 
|  | 3430 | assert(cli_wand->signature == WandSignature); | 
|  | 3431 | assert(cli_wand->wand.signature == WandSignature); | 
|  | 3432 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ | 
|  | 3433 | if (cli_wand->wand.debug != MagickFalse) | 
|  | 3434 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3435 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3436 | #if !USE_WAND_METHODS | 
|  | 3437 | /* FUTURE add appropriate tracing */ | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3438 | i=0; | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3439 | n=GetImageListLength(cli_wand->wand.images); | 
|  | 3440 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3441 | while (1) { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3442 | i++; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3443 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3444 | if ( cli_wand->wand.images->next == (Image *) NULL ) | 
|  | 3445 | break; | 
|  | 3446 | cli_wand->wand.images=cli_wand->wand.images->next; | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3447 | } | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3448 | assert( i == n ); | 
|  | 3449 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3450 | #else | 
|  | 3451 | MagickResetIterator(&cli_wand->wand); | 
|  | 3452 | while ( MagickNextImage(&cli_wand->wand) != MagickFalse ) | 
|  | 3453 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); | 
|  | 3454 | MagickResetIterator(&cli_wand->wand); | 
|  | 3455 | #endif | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3456 | return; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3457 | } | 
|  | 3458 |  | 
|  | 3459 | /* | 
|  | 3460 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 3461 | %                                                                             % | 
|  | 3462 | %                                                                             % | 
|  | 3463 | %                                                                             % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3464 | +     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] | 3465 | %                                                                             % | 
|  | 3466 | %                                                                             % | 
|  | 3467 | %                                                                             % | 
|  | 3468 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 3469 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3470 | %  CLIListOperatorImages() applies a single operation that is apply to the | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3471 | %  entire image list as a whole. The result is often a complete replacment | 
|  | 3472 | %  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] | 3473 | % | 
|  | 3474 | %  The format of the MogrifyImage method is: | 
|  | 3475 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3476 | %    void CLIListOperatorImages(MagickCLI *cli_wand, | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3477 | %        const char *option, const char *arg1, const char *arg2) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3478 | % | 
|  | 3479 | %  A description of each parameter follows: | 
|  | 3480 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3481 | %    o cli_wand: structure holding settings to be applied | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3482 | % | 
| anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3483 | %    o option:  The option string for the operation | 
|  | 3484 | % | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3485 | %    o arg1, arg2: optional argument strings to the operation | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3486 | % | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3487 | % NOTE: only "limit" currently uses two arguments. | 
|  | 3488 | % | 
|  | 3489 | % Example usage... | 
|  | 3490 | % | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3491 | %  CLIListOperatorImages(cli_wand,MagickFalse,"-duplicate", "3",  NULL); | 
|  | 3492 | %  CLIListOperatorImages(cli_wand,MagickTrue, "+append",    NULL, NULL); | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3493 | % | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 3494 | % Or for handling command line arguments EG: +/-option ["arg1"] | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3495 | % | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3496 | %    cli_wand | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3497 | %    argc,argv | 
|  | 3498 | %    i=index in argv | 
|  | 3499 | % | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 3500 | %    option_info = GetCommandOptionInfo(argv[i]); | 
|  | 3501 | %    count=option_info->type; | 
|  | 3502 | %    option_type=option_info->flags; | 
|  | 3503 | % | 
|  | 3504 | %    if ( (option_type & ListOperatorOptionFlag) != 0 ) | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3505 | %      CLIListOperatorImages(cli_wand,argv[i], | 
| anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3506 | %          count>=1 ? argv[i+1] : (char *)NULL, | 
|  | 3507 | %          count>=2 ? argv[i+2] : (char *)NULL ); | 
|  | 3508 | %    i += count+1; | 
|  | 3509 | % | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3510 | */ | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3511 | WandExport void CLIListOperatorImages(MagickCLI *cli_wand, | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3512 | const char *option,const char *arg1, const char *arg2) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3513 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3514 | Image | 
|  | 3515 | *new_images; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3516 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3517 | #define _image_info      (cli_wand->wand.image_info) | 
|  | 3518 | #define _images          (cli_wand->wand.images) | 
|  | 3519 | #define _exception       (cli_wand->wand.exception) | 
|  | 3520 | #define _draw_info       (cli_wand->draw_info) | 
|  | 3521 | #define _quantize_info   (cli_wand->quantize_info) | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3522 | #define IfNormalOp      (*option=='-') | 
|  | 3523 | #define IfPlusOp        (*option!='-') | 
|  | 3524 | #define normal_op       (IfNormalOp?MagickTrue:MagickFalse) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3525 |  | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3526 | assert(cli_wand != (MagickCLI *) NULL); | 
|  | 3527 | assert(cli_wand->signature == WandSignature); | 
|  | 3528 | assert(cli_wand->wand.signature == WandSignature); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3529 | assert(_images != (Image *) NULL);             /* _images must be present */ | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3530 | if (cli_wand->wand.debug != MagickFalse) | 
|  | 3531 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3532 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3533 | (void) SyncImagesSettings(_image_info,_images,_exception); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3534 |  | 
|  | 3535 | new_images=NewImageList(); | 
|  | 3536 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3537 | switch (*(option+1)) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3538 | { | 
|  | 3539 | case 'a': | 
|  | 3540 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3541 | if (LocaleCompare("append",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3542 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3543 | new_images=AppendImages(_images,normal_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3544 | break; | 
|  | 3545 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3546 | if (LocaleCompare("average",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3547 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3548 | /* DEPRECIATED - use -evaluate-sequence Mean */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3549 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3550 | break; | 
|  | 3551 | } | 
|  | 3552 | break; | 
|  | 3553 | } | 
|  | 3554 | case 'c': | 
|  | 3555 | { | 
| cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3556 | if (LocaleCompare("channel-fx",option+1) == 0) | 
| cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3557 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3558 | new_images=ChannelFxImage(_images,arg1,_exception); | 
| cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3559 | break; | 
|  | 3560 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3561 | if (LocaleCompare("clut",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3562 | { | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3563 | Image | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3564 | *clut_image; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3565 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3566 | /* FUTURE - make this a compose option, and thus can be used | 
|  | 3567 | with layers compose or even compose last image over all other | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3568 | _images. | 
| cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3569 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3570 | new_images=RemoveFirstImageFromList(&_images); | 
|  | 3571 | clut_image=RemoveLastImageFromList(&_images); | 
| anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3572 | /* FUTURE - produce Exception, rather than silent fail */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3573 | if (clut_image == (Image *) NULL) | 
| cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3574 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3575 | (void) ClutImage(new_images,clut_image,_images->interpolate,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3576 | clut_image=DestroyImage(clut_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3577 | break; | 
|  | 3578 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3579 | if (LocaleCompare("coalesce",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3580 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3581 | new_images=CoalesceImages(_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3582 | break; | 
|  | 3583 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3584 | if (LocaleCompare("combine",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3585 | { | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3586 | /* FUTURE - this may be replaced by a 'channel' method */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3587 | new_images=CombineImages(_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3588 | break; | 
|  | 3589 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3590 | if (LocaleCompare("composite",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3591 | { | 
|  | 3592 | Image | 
|  | 3593 | *mask_image, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3594 | *source_image; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3595 |  | 
|  | 3596 | RectangleInfo | 
|  | 3597 | geometry; | 
|  | 3598 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3599 | CompositeOperator | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3600 | compose; | 
|  | 3601 |  | 
|  | 3602 | const char* | 
|  | 3603 | value; | 
|  | 3604 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3605 | value=GetImageOption(_image_info,"compose"); | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3606 | if (value != (const char *) NULL) | 
|  | 3607 | compose=(CompositeOperator) ParseCommandOption( | 
|  | 3608 | MagickComposeOptions,MagickFalse,value); | 
|  | 3609 | else | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3610 | compose=OverCompositeOp;  /* use Over not source_image->compose */ | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3611 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3612 | new_images=RemoveFirstImageFromList(&_images); | 
|  | 3613 | source_image=RemoveFirstImageFromList(&_images); | 
| anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3614 | /* FUTURE - produce Exception, rather than silent fail */ | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3615 | if (source_image == (Image *) NULL) | 
|  | 3616 | break; | 
| anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3617 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3618 | /* FUTURE - this should not be here! - should be part of -geometry */ | 
|  | 3619 | (void) TransformImage(&source_image,(char *) NULL, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3620 | source_image->geometry,_exception); | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3621 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3622 | SetGeometry(source_image,&geometry); | 
|  | 3623 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); | 
|  | 3624 | GravityAdjustGeometry(new_images->columns,new_images->rows, | 
|  | 3625 | new_images->gravity, &geometry); | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3626 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3627 | mask_image=RemoveFirstImageFromList(&_images); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3628 | if (mask_image != (Image *) NULL) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3629 | { /* handle a third write mask image */ | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3630 | if ((compose == DisplaceCompositeOp) || | 
|  | 3631 | (compose == DistortCompositeOp)) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3632 | { /* Merge Y displacement into X displace/distort map. */ | 
|  | 3633 | (void) CompositeImage(source_image,CopyGreenCompositeOp, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3634 | mask_image,0,0,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3635 | mask_image=DestroyImage(mask_image); | 
|  | 3636 | } | 
|  | 3637 | else | 
|  | 3638 | { | 
|  | 3639 | /* | 
|  | 3640 | Set a blending mask for the composition. | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3641 | */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3642 | (void) NegateImage(mask_image,MagickFalse,_exception); | 
|  | 3643 | (void) SetImageMask(new_images,mask_image,_exception); | 
| cristy | 1539afd | 2012-01-30 01:32:59 +0000 | [diff] [blame] | 3644 | mask_image=DestroyImage(mask_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3645 | } | 
|  | 3646 | } | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3647 | (void) CompositeImage(new_images,compose,source_image,geometry.x, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3648 | geometry.y,_exception); | 
|  | 3649 | (void) SetImageMask(new_images,(Image *) NULL,_exception); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3650 | source_image=DestroyImage(source_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3651 | break; | 
|  | 3652 | } | 
|  | 3653 | break; | 
|  | 3654 | } | 
|  | 3655 | case 'd': | 
|  | 3656 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3657 | if (LocaleCompare("deconstruct",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3658 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3659 | /* DEPRECIATED - use -layers CompareAny */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3660 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3661 | break; | 
|  | 3662 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3663 | if (LocaleCompare("delete",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3664 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3665 | if (IfNormalOp) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3666 | DeleteImages(&_images,arg1,_exception); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3667 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3668 | DeleteImages(&_images,"-1",_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3669 | break; | 
|  | 3670 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3671 | if (LocaleCompare("duplicate",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3672 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3673 | if (IfNormalOp) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3674 | { | 
|  | 3675 | const char | 
|  | 3676 | *p; | 
|  | 3677 |  | 
|  | 3678 | size_t | 
|  | 3679 | number_duplicates; | 
|  | 3680 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3681 | number_duplicates=(size_t) StringToLong(arg1); | 
|  | 3682 | p=strchr(arg1,','); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3683 | if (p == (const char *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3684 | new_images=DuplicateImages(_images,number_duplicates, | 
|  | 3685 | "-1",_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3686 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3687 | new_images=DuplicateImages(_images,number_duplicates,p, | 
|  | 3688 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3689 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3690 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3691 | new_images=DuplicateImages(_images,1,"-1",_exception); | 
|  | 3692 | AppendImageToList(&_images, new_images); | 
| anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3693 | new_images=(Image *)NULL; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3694 | break; | 
|  | 3695 | } | 
|  | 3696 | break; | 
|  | 3697 | } | 
|  | 3698 | case 'e': | 
|  | 3699 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3700 | if (LocaleCompare("evaluate-sequence",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3701 | { | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3702 | MagickEvaluateOperator | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3703 | method; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3704 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3705 | method=(MagickEvaluateOperator) ParseCommandOption( | 
|  | 3706 | MagickEvaluateOptions,MagickFalse,arg1); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3707 | new_images=EvaluateImages(_images,method,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3708 | break; | 
|  | 3709 | } | 
|  | 3710 | break; | 
|  | 3711 | } | 
|  | 3712 | case 'f': | 
|  | 3713 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3714 | if (LocaleCompare("fft",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3715 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3716 | new_images=ForwardFourierTransformImage(_images,normal_op,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3717 | break; | 
|  | 3718 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3719 | if (LocaleCompare("flatten",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3720 | { | 
| anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3721 | /* REDIRECTED to use -layers flatten instead */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3722 | CLIListOperatorImages(cli_wand,"-layer",option+1,NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3723 | break; | 
|  | 3724 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3725 | if (LocaleCompare("fx",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3726 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3727 | new_images=FxImage(_images,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3728 | break; | 
|  | 3729 | } | 
|  | 3730 | break; | 
|  | 3731 | } | 
|  | 3732 | case 'h': | 
|  | 3733 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3734 | if (LocaleCompare("hald-clut",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3735 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3736 | /* FUTURE - make this a compose option (and thus layers compose ) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3737 | or perhaps compose last image over all other _images. | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3738 | */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3739 | Image | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3740 | *hald_image; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3741 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3742 | new_images=RemoveFirstImageFromList(&_images); | 
|  | 3743 | hald_image=RemoveLastImageFromList(&_images); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3744 | if (hald_image == (Image *) NULL) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3745 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3746 | (void) HaldClutImage(new_images,hald_image,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3747 | hald_image=DestroyImage(hald_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3748 | break; | 
|  | 3749 | } | 
|  | 3750 | break; | 
|  | 3751 | } | 
|  | 3752 | case 'i': | 
|  | 3753 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3754 | if (LocaleCompare("ift",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3755 | { | 
|  | 3756 | Image | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3757 | *magnitude_image, | 
|  | 3758 | *phase_image; | 
|  | 3759 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3760 | magnitude_image=RemoveFirstImageFromList(&_images); | 
|  | 3761 | phase_image=RemoveFirstImageFromList(&_images); | 
| anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3762 | /* FUTURE - produce Exception, rather than silent fail */ | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3763 | if (phase_image == (Image *) NULL) | 
|  | 3764 | break; | 
|  | 3765 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3766 | normal_op,_exception); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3767 | magnitude_image=DestroyImage(magnitude_image); | 
|  | 3768 | phase_image=DestroyImage(phase_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3769 | break; | 
|  | 3770 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3771 | if (LocaleCompare("insert",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3772 | { | 
|  | 3773 | Image | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3774 | *insert_image, | 
|  | 3775 | *index_image; | 
|  | 3776 |  | 
|  | 3777 | ssize_t | 
|  | 3778 | index; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3779 |  | 
|  | 3780 | index=0; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3781 | insert_image=RemoveLastImageFromList(&_images); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3782 | if (IfNormalOp) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3783 | index=(ssize_t) StringToLong(arg1); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3784 | index_image=insert_image; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3785 | if (index == 0) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3786 | PrependImageToList(&_images,insert_image); | 
|  | 3787 | else if (index == (ssize_t) GetImageListLength(_images)) | 
|  | 3788 | AppendImageToList(&_images,insert_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3789 | else | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3790 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3791 | index_image=GetImageFromList(_images,index-1); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3792 | if (index_image == (Image *) NULL) | 
|  | 3793 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3794 | (void) ThrowMagickException(_exception,GetMagickModule(), | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3795 | OptionError,"NoSuchImage","'%s'",arg1); | 
|  | 3796 | break; | 
|  | 3797 | } | 
|  | 3798 | InsertImageInList(&index_image,insert_image); | 
|  | 3799 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3800 | _images=GetFirstImageInList(index_image); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3801 | break; | 
|  | 3802 | } | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3803 | break; | 
|  | 3804 | } | 
|  | 3805 | case 'l': | 
|  | 3806 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3807 | if (LocaleCompare("layers",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3808 | { | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3809 | ImageLayerMethod | 
|  | 3810 | method; | 
|  | 3811 |  | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3812 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3813 | MagickFalse,arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3814 | switch (method) | 
|  | 3815 | { | 
|  | 3816 | case CoalesceLayer: | 
|  | 3817 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3818 | new_images=CoalesceImages(_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3819 | break; | 
|  | 3820 | } | 
|  | 3821 | case CompareAnyLayer: | 
|  | 3822 | case CompareClearLayer: | 
|  | 3823 | case CompareOverlayLayer: | 
|  | 3824 | default: | 
|  | 3825 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3826 | new_images=CompareImagesLayers(_images,method,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3827 | break; | 
|  | 3828 | } | 
|  | 3829 | case MergeLayer: | 
|  | 3830 | case FlattenLayer: | 
|  | 3831 | case MosaicLayer: | 
|  | 3832 | case TrimBoundsLayer: | 
|  | 3833 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3834 | new_images=MergeImageLayers(_images,method,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3835 | break; | 
|  | 3836 | } | 
|  | 3837 | case DisposeLayer: | 
|  | 3838 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3839 | new_images=DisposeImages(_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3840 | break; | 
|  | 3841 | } | 
|  | 3842 | case OptimizeImageLayer: | 
|  | 3843 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3844 | new_images=OptimizeImageLayers(_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3845 | break; | 
|  | 3846 | } | 
|  | 3847 | case OptimizePlusLayer: | 
|  | 3848 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3849 | new_images=OptimizePlusImageLayers(_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3850 | break; | 
|  | 3851 | } | 
|  | 3852 | case OptimizeTransLayer: | 
|  | 3853 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3854 | OptimizeImageTransparency(_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3855 | break; | 
|  | 3856 | } | 
|  | 3857 | case RemoveDupsLayer: | 
|  | 3858 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3859 | RemoveDuplicateLayers(&_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3860 | break; | 
|  | 3861 | } | 
|  | 3862 | case RemoveZeroLayer: | 
|  | 3863 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3864 | RemoveZeroDelayLayers(&_images,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3865 | break; | 
|  | 3866 | } | 
|  | 3867 | case OptimizeLayer: | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3868 | { /* General Purpose, GIF Animation Optimizer.  */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3869 | new_images=CoalesceImages(_images,_exception); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3870 | if (new_images == (Image *) NULL) | 
|  | 3871 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3872 | _images=DestroyImageList(_images); | 
|  | 3873 | _images=OptimizeImageLayers(new_images,_exception); | 
|  | 3874 | if (_images == (Image *) NULL) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3875 | break; | 
|  | 3876 | new_images=DestroyImageList(new_images); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3877 | OptimizeImageTransparency(_images,_exception); | 
|  | 3878 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, | 
|  | 3879 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3880 | break; | 
|  | 3881 | } | 
|  | 3882 | case CompositeLayer: | 
|  | 3883 | { | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3884 | Image | 
|  | 3885 | *source; | 
|  | 3886 |  | 
|  | 3887 | RectangleInfo | 
|  | 3888 | geometry; | 
|  | 3889 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3890 | CompositeOperator | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3891 | compose; | 
|  | 3892 |  | 
|  | 3893 | const char* | 
|  | 3894 | value; | 
|  | 3895 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3896 | value=GetImageOption(_image_info,"compose"); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3897 | compose=OverCompositeOp;  /* Default to Over */ | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3898 | if (value != (const char *) NULL) | 
|  | 3899 | compose=(CompositeOperator) ParseCommandOption( | 
|  | 3900 | MagickComposeOptions,MagickFalse,value); | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3901 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3902 | /* Split image sequence at the first 'NULL:' image. */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3903 | source=_images; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3904 | while (source != (Image *) NULL) | 
|  | 3905 | { | 
|  | 3906 | source=GetNextImageInList(source); | 
|  | 3907 | if ((source != (Image *) NULL) && | 
|  | 3908 | (LocaleCompare(source->magick,"NULL") == 0)) | 
|  | 3909 | break; | 
|  | 3910 | } | 
|  | 3911 | if (source != (Image *) NULL) | 
|  | 3912 | { | 
|  | 3913 | if ((GetPreviousImageInList(source) == (Image *) NULL) || | 
|  | 3914 | (GetNextImageInList(source) == (Image *) NULL)) | 
|  | 3915 | source=(Image *) NULL; | 
|  | 3916 | else | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3917 | { /* Separate the two lists, junk the null: image.  */ | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3918 | source=SplitImageList(source->previous); | 
|  | 3919 | DeleteImageFromList(&source); | 
|  | 3920 | } | 
|  | 3921 | } | 
|  | 3922 | if (source == (Image *) NULL) | 
|  | 3923 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3924 | (void) ThrowMagickException(_exception,GetMagickModule(), | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3925 | OptionError,"MissingNullSeparator","layers Composite"); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3926 | break; | 
|  | 3927 | } | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3928 | /* Adjust offset with gravity and virtual canvas.  */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3929 | SetGeometry(_images,&geometry); | 
|  | 3930 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3931 | geometry.width=source->page.width != 0 ? | 
|  | 3932 | source->page.width : source->columns; | 
|  | 3933 | geometry.height=source->page.height != 0 ? | 
|  | 3934 | source->page.height : source->rows; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3935 | GravityAdjustGeometry(_images->page.width != 0 ? | 
|  | 3936 | _images->page.width : _images->columns, | 
|  | 3937 | _images->page.height != 0 ? _images->page.height : | 
|  | 3938 | _images->rows,_images->gravity,&geometry); | 
| anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3939 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3940 | /* Compose the two image sequences together */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3941 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, | 
|  | 3942 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3943 | source=DestroyImageList(source); | 
|  | 3944 | break; | 
|  | 3945 | } | 
|  | 3946 | } | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3947 | break; | 
|  | 3948 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3949 | if (LocaleCompare("limit",option+1) == 0) | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 3950 | { | 
|  | 3951 | MagickSizeType | 
|  | 3952 | limit; | 
|  | 3953 |  | 
|  | 3954 | ResourceType | 
|  | 3955 | type; | 
|  | 3956 |  | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 3957 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3958 | MagickFalse,arg1); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 3959 | limit=MagickResourceInfinity; | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3960 | if (LocaleCompare("unlimited",arg2) != 0) | 
|  | 3961 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); | 
| anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 3962 | (void) SetMagickResourceLimit(type,limit); | 
|  | 3963 | break; | 
|  | 3964 | } | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3965 | break; | 
|  | 3966 | } | 
|  | 3967 | case 'm': | 
|  | 3968 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3969 | if (LocaleCompare("map",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3970 | { | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3971 | /* DEPRECIATED use +remap */ | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3972 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3973 | break; | 
|  | 3974 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3975 | if (LocaleCompare("morph",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3976 | { | 
|  | 3977 | Image | 
|  | 3978 | *morph_image; | 
|  | 3979 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3980 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), | 
|  | 3981 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3982 | if (morph_image == (Image *) NULL) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3983 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 3984 | _images=DestroyImageList(_images); | 
|  | 3985 | _images=morph_image; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3986 | break; | 
|  | 3987 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3988 | if (LocaleCompare("mosaic",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3989 | { | 
| anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3990 | /* REDIRECTED to use -layers mosaic instead */ | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3991 | CLIListOperatorImages(cli_wand,"-layer",option+1,NULL); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3992 | break; | 
|  | 3993 | } | 
|  | 3994 | break; | 
|  | 3995 | } | 
|  | 3996 | case 'p': | 
|  | 3997 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3998 | if (LocaleCompare("print",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3999 | { | 
|  | 4000 | char | 
|  | 4001 | *string; | 
|  | 4002 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4003 | string=InterpretImageProperties(_image_info,_images,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4004 | if (string == (char *) NULL) | 
|  | 4005 | break; | 
|  | 4006 | (void) FormatLocaleFile(stdout,"%s",string); | 
|  | 4007 | string=DestroyString(string); | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4008 | break; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4009 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4010 | if (LocaleCompare("process",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4011 | { | 
|  | 4012 | char | 
|  | 4013 | **arguments; | 
|  | 4014 |  | 
|  | 4015 | int | 
|  | 4016 | j, | 
|  | 4017 | number_arguments; | 
|  | 4018 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4019 | arguments=StringToArgv(arg1,&number_arguments); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4020 | if (arguments == (char **) NULL) | 
|  | 4021 | break; | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4022 | if (strchr(arguments[1],'=') != (char *) NULL) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4023 | { | 
|  | 4024 | char | 
|  | 4025 | breaker, | 
|  | 4026 | quote, | 
|  | 4027 | *token; | 
|  | 4028 |  | 
|  | 4029 | const char | 
|  | 4030 | *arguments; | 
|  | 4031 |  | 
|  | 4032 | int | 
|  | 4033 | next, | 
|  | 4034 | status; | 
|  | 4035 |  | 
|  | 4036 | size_t | 
|  | 4037 | length; | 
|  | 4038 |  | 
|  | 4039 | TokenInfo | 
|  | 4040 | *token_info; | 
|  | 4041 |  | 
|  | 4042 | /* | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4043 | Support old style syntax, filter="-option arg1". | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4044 | */ | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4045 | length=strlen(arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4046 | token=(char *) NULL; | 
|  | 4047 | if (~length >= (MaxTextExtent-1)) | 
|  | 4048 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, | 
|  | 4049 | sizeof(*token)); | 
|  | 4050 | if (token == (char *) NULL) | 
|  | 4051 | break; | 
|  | 4052 | next=0; | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4053 | arguments=arg1; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4054 | token_info=AcquireTokenInfo(); | 
|  | 4055 | status=Tokenizer(token_info,0,token,length,arguments,"","=", | 
|  | 4056 | "\"",'\0',&breaker,&next,"e); | 
|  | 4057 | token_info=DestroyTokenInfo(token_info); | 
|  | 4058 | if (status == 0) | 
|  | 4059 | { | 
|  | 4060 | const char | 
|  | 4061 | *argv; | 
|  | 4062 |  | 
|  | 4063 | argv=(&(arguments[next])); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4064 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, | 
|  | 4065 | _exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4066 | } | 
|  | 4067 | token=DestroyString(token); | 
|  | 4068 | break; | 
|  | 4069 | } | 
|  | 4070 | (void) SubstituteString(&arguments[1],"-",""); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4071 | (void) InvokeDynamicImageFilter(arguments[1],&_images, | 
|  | 4072 | number_arguments-2,(const char **) arguments+2,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4073 | for (j=0; j < number_arguments; j++) | 
|  | 4074 | arguments[j]=DestroyString(arguments[j]); | 
|  | 4075 | arguments=(char **) RelinquishMagickMemory(arguments); | 
|  | 4076 | break; | 
|  | 4077 | } | 
|  | 4078 | break; | 
|  | 4079 | } | 
|  | 4080 | case 'r': | 
|  | 4081 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4082 | if (LocaleCompare("remap",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4083 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4084 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); | 
|  | 4085 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4086 | break; | 
|  | 4087 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4088 | if (LocaleCompare("reverse",option+1) == 0) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4089 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4090 | ReverseImageList(&_images); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4091 | break; | 
|  | 4092 | } | 
|  | 4093 | break; | 
|  | 4094 | } | 
|  | 4095 | case 's': | 
|  | 4096 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4097 | if (LocaleCompare("smush",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4098 | { | 
|  | 4099 | Image | 
|  | 4100 | *smush_image; | 
|  | 4101 |  | 
|  | 4102 | ssize_t | 
|  | 4103 | offset; | 
|  | 4104 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4105 | offset=(ssize_t) StringToLong(arg1); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4106 | smush_image=SmushImages(_images,normal_op,offset,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4107 | if (smush_image == (Image *) NULL) | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4108 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4109 | _images=DestroyImageList(_images); | 
|  | 4110 | _images=smush_image; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4111 | break; | 
|  | 4112 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4113 | if (LocaleCompare("swap",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4114 | { | 
|  | 4115 | Image | 
|  | 4116 | *p, | 
|  | 4117 | *q, | 
|  | 4118 | *swap; | 
|  | 4119 |  | 
|  | 4120 | ssize_t | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4121 | index, | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4122 | swap_index; | 
|  | 4123 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4124 | index=-1; | 
|  | 4125 | swap_index=-2; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4126 | if (IfNormalOp) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4127 | { | 
|  | 4128 | GeometryInfo | 
|  | 4129 | geometry_info; | 
|  | 4130 |  | 
|  | 4131 | MagickStatusType | 
|  | 4132 | flags; | 
|  | 4133 |  | 
|  | 4134 | swap_index=(-1); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4135 | flags=ParseGeometry(arg1,&geometry_info); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4136 | index=(ssize_t) geometry_info.rho; | 
|  | 4137 | if ((flags & SigmaValue) != 0) | 
|  | 4138 | swap_index=(ssize_t) geometry_info.sigma; | 
|  | 4139 | } | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4140 | p=GetImageFromList(_images,index); | 
|  | 4141 | q=GetImageFromList(_images,swap_index); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4142 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) | 
|  | 4143 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4144 | (void) ThrowMagickException(_exception,GetMagickModule(), | 
|  | 4145 | OptionError,"NoSuchImage","'%s'",_images->filename); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4146 | break; | 
|  | 4147 | } | 
|  | 4148 | if (p == q) | 
|  | 4149 | break; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4150 | swap=CloneImage(p,0,0,MagickTrue,_exception); | 
|  | 4151 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4152 | ReplaceImageInList(&q,swap); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4153 | _images=GetFirstImageInList(q); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4154 | break; | 
|  | 4155 | } | 
|  | 4156 | break; | 
|  | 4157 | } | 
|  | 4158 | case 'w': | 
|  | 4159 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4160 | if (LocaleCompare("write",option+1) == 0) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4161 | { | 
|  | 4162 | char | 
|  | 4163 | key[MaxTextExtent]; | 
|  | 4164 |  | 
|  | 4165 | Image | 
|  | 4166 | *write_images; | 
|  | 4167 |  | 
|  | 4168 | ImageInfo | 
|  | 4169 | *write_info; | 
|  | 4170 |  | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4171 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4172 | (void) DeleteImageRegistry(key); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4173 | write_images=_images; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4174 | if (IfPlusOp) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4175 | write_images=CloneImageList(_images,_exception); | 
|  | 4176 | write_info=CloneImageInfo(_image_info); | 
|  | 4177 | (void) WriteImages(write_info,write_images,arg1,_exception); | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4178 | write_info=DestroyImageInfo(write_info); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4179 | if (IfPlusOp) | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4180 | write_images=DestroyImageList(write_images); | 
|  | 4181 | break; | 
|  | 4182 | } | 
|  | 4183 | break; | 
|  | 4184 | } | 
|  | 4185 | default: | 
|  | 4186 | break; | 
|  | 4187 | } | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4188 | if (new_images == (Image *) NULL) | 
|  | 4189 | return; | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4190 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4191 | if (_images != (Image *) NULL) | 
|  | 4192 | _images=DestroyImageList(_images); | 
|  | 4193 | _images=GetFirstImageInList(new_images); | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4194 | return; | 
|  | 4195 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4196 | #undef _image_info | 
|  | 4197 | #undef _images | 
|  | 4198 | #undef _exception | 
|  | 4199 | #undef _draw_info | 
|  | 4200 | #undef _quantize_info | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4201 | #undef IfNormalOp | 
|  | 4202 | #undef IfPlusOp | 
| anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4203 | #undef normal_op | 
| anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4204 | } | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4205 |  | 
|  | 4206 | /* | 
|  | 4207 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 4208 | %                                                                             % | 
|  | 4209 | %                                                                             % | 
|  | 4210 | %                                                                             % | 
|  | 4211 | +   C L I S p e c i a l O p e r a t i o n s                                   % | 
|  | 4212 | %                                                                             % | 
|  | 4213 | %                                                                             % | 
|  | 4214 | %                                                                             % | 
|  | 4215 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|  | 4216 | % | 
|  | 4217 | %  CLISpecialOption() Applies operations that may involve empty image lists | 
|  | 4218 | %  and or stacks of image lists or image_info settings. | 
|  | 4219 | % | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4220 | %  The classic operators of this type is -read, and image stack operators, | 
|  | 4221 | %  which can be applied to empty image lists. | 
|  | 4222 | % | 
|  | 4223 | %  Note: unlike other Operators, these may involve other special 'option' | 
|  | 4224 | %  character prefixes, other than simply '-' or '+'. | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4225 | % | 
|  | 4226 | %  The format of the CLISpecialOption method is: | 
|  | 4227 | % | 
|  | 4228 | %      void CLISpecialOption(MagickCLI *cli_wand,const char *option, | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4229 | %           const char *arg1) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4230 | % | 
|  | 4231 | %  A description of each parameter follows: | 
|  | 4232 | % | 
|  | 4233 | %    o cli_wand: the main CLI Wand to use. | 
|  | 4234 | % | 
|  | 4235 | %    o option: The special option (with any switch char) to process | 
|  | 4236 | % | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4237 | %    o arg1: Argument for option, if required | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4238 | % | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4239 | % Example Usage... | 
|  | 4240 | % | 
|  | 4241 | %  CLISpecialOperator(cli_wand,"-read", "rose:"); | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4242 | % | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4243 | % Or for handling command line arguments EG: +/-option ["arg1"] | 
| anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 4244 | % | 
|  | 4245 | %    cli_wand | 
|  | 4246 | %    argc,argv | 
|  | 4247 | %    i=index in argv | 
|  | 4248 | % | 
|  | 4249 | %    option_info = GetCommandOptionInfo(argv[i]); | 
|  | 4250 | %    count=option_info->type; | 
|  | 4251 | %    option_type=option_info->flags; | 
|  | 4252 | % | 
|  | 4253 | %    if ( (option_type & SpecialOptionFlag) != 0 ) | 
|  | 4254 | %      CLISpecialOperator(cli_wand,argv[i], | 
|  | 4255 | %          count>=1 ? argv[i+1] : (char *)NULL); | 
|  | 4256 | %    i += count+1; | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4257 | % | 
|  | 4258 | */ | 
|  | 4259 |  | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4260 | WandExport void CLISpecialOperator(MagickCLI *cli_wand, | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4261 | const char *option, const char *arg1) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4262 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4263 | #define _exception       (cli_wand->wand.exception) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4264 |  | 
|  | 4265 | assert(cli_wand != (MagickCLI *) NULL); | 
|  | 4266 | assert(cli_wand->signature == WandSignature); | 
|  | 4267 | assert(cli_wand->wand.signature == WandSignature); | 
|  | 4268 | if (cli_wand->wand.debug != MagickFalse) | 
|  | 4269 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); | 
|  | 4270 |  | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4271 | if(cli_wand->wand.images != (Image *)NULL) | 
|  | 4272 | (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4273 | _exception); | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4274 |  | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4275 | if (LocaleCompare("(",option) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4276 | { | 
|  | 4277 | /* stack 'push' images */ | 
|  | 4278 | Stack | 
|  | 4279 | *node; | 
|  | 4280 |  | 
|  | 4281 | size_t | 
|  | 4282 | size; | 
|  | 4283 |  | 
|  | 4284 | const char* | 
|  | 4285 | value; | 
|  | 4286 |  | 
|  | 4287 | size=0; | 
|  | 4288 | node=cli_wand->image_list_stack; | 
|  | 4289 | for ( ; node != (Stack *)NULL; node=node->next) | 
|  | 4290 | size++; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4291 | if ( size >= MAX_STACK_DEPTH ) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4292 | CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4293 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); | 
|  | 4294 | if (node == (Stack *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4295 | CLIWandExceptionReturn(ResourceLimitFatalError, | 
|  | 4296 | "MemoryAllocationFailed",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4297 | node->data = (void *)cli_wand->wand.images; | 
|  | 4298 | cli_wand->wand.images = NewImageList(); | 
|  | 4299 | node->next = cli_wand->image_list_stack; | 
|  | 4300 | cli_wand->image_list_stack = node; | 
|  | 4301 |  | 
|  | 4302 | /* handle respect-parenthesis */ | 
|  | 4303 | value=GetImageOption(cli_wand->wand.image_info,"respect-parenthesis"); | 
|  | 4304 | if (value != (const char *) NULL) | 
|  | 4305 | option="{"; | 
|  | 4306 | else | 
|  | 4307 | return; | 
|  | 4308 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4309 | if (LocaleCompare("{",option) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4310 | { | 
|  | 4311 | /* stack 'push' of image_info settings */ | 
|  | 4312 | Stack | 
|  | 4313 | *node; | 
|  | 4314 |  | 
|  | 4315 | size_t | 
|  | 4316 | size; | 
|  | 4317 |  | 
|  | 4318 | size=0; | 
|  | 4319 | node=cli_wand->image_info_stack; | 
|  | 4320 | for ( ; node != (Stack *)NULL; node=node->next) | 
|  | 4321 | size++; | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4322 | if ( size >= MAX_STACK_DEPTH ) | 
|  | 4323 | CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4324 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4325 | if (node == (Stack *) NULL) | 
|  | 4326 | CLIWandExceptionReturn(ResourceLimitFatalError, | 
|  | 4327 | "MemoryAllocationFailed",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4328 |  | 
|  | 4329 | node->data = (void *)cli_wand->wand.image_info; | 
|  | 4330 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4331 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4332 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", | 
|  | 4333 | option); | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4334 | cli_wand->wand.image_info = (ImageInfo *)node->data; | 
|  | 4335 | node = (Stack *)RelinquishMagickMemory(node); | 
|  | 4336 | return; | 
|  | 4337 | } | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4338 |  | 
|  | 4339 | node->next = cli_wand->image_info_stack; | 
|  | 4340 | cli_wand->image_info_stack = node; | 
|  | 4341 |  | 
|  | 4342 | return; | 
|  | 4343 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4344 | if (LocaleCompare(")",option) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4345 | { | 
|  | 4346 | /* pop images from stack */ | 
|  | 4347 | Stack | 
|  | 4348 | *node; | 
|  | 4349 |  | 
|  | 4350 | const char* | 
|  | 4351 | value; | 
|  | 4352 |  | 
|  | 4353 | node = (void *)cli_wand->image_list_stack; | 
|  | 4354 | if ( node == (Stack *)NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4355 | CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4356 | cli_wand->image_list_stack = node->next; | 
|  | 4357 |  | 
|  | 4358 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); | 
|  | 4359 | cli_wand->wand.images= (Image *)node->data; | 
|  | 4360 | node = (Stack *)RelinquishMagickMemory(node); | 
|  | 4361 |  | 
|  | 4362 | /* handle respect-parenthesis - of the previous 'push' settings */ | 
|  | 4363 | node = cli_wand->image_info_stack; | 
|  | 4364 | if ( node != (Stack *)NULL) | 
|  | 4365 | { | 
|  | 4366 | value=GetImageOption((ImageInfo *)node->data,"respect-parenthesis"); | 
|  | 4367 | if (value != (const char *) NULL) | 
|  | 4368 | option="}"; | 
|  | 4369 | else | 
|  | 4370 | return; | 
|  | 4371 | } | 
|  | 4372 | else | 
|  | 4373 | return; | 
|  | 4374 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4375 | if (LocaleCompare("}",option) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4376 | { | 
|  | 4377 | /* pop image_info settings from stack */ | 
|  | 4378 | Stack | 
|  | 4379 | *node; | 
|  | 4380 |  | 
|  | 4381 | node = (void *)cli_wand->image_info_stack; | 
|  | 4382 | if ( node == (Stack *)NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4383 | CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4384 | cli_wand->image_info_stack = node->next; | 
|  | 4385 |  | 
|  | 4386 | (void) DestroyImageInfo(cli_wand->wand.image_info); | 
|  | 4387 | cli_wand->wand.image_info = (ImageInfo *)node->data; | 
|  | 4388 | node = (Stack *)RelinquishMagickMemory(node); | 
|  | 4389 |  | 
|  | 4390 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); | 
|  | 4391 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); | 
|  | 4392 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); | 
|  | 4393 |  | 
|  | 4394 | return; | 
|  | 4395 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4396 | if (LocaleCompare("clone",option+1) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4397 | { | 
|  | 4398 | Image | 
|  | 4399 | *new_images; | 
|  | 4400 |  | 
|  | 4401 | if (*option == '+') | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4402 | arg1="-1"; | 
|  | 4403 | if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4404 | CLIWandExceptionReturn(OptionError,"InvalidArgument",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4405 | if ( cli_wand->image_list_stack == (Stack *)NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4406 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4407 | new_images = (Image *)cli_wand->image_list_stack->data; | 
|  | 4408 | if (new_images == (Image *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4409 | CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option); | 
|  | 4410 | new_images=CloneImages(new_images,arg1,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4411 | if (new_images == (Image *) NULL) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4412 | CLIWandExceptionReturn(OptionError,"NoSuchImage",option); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4413 | AppendImageToList(&cli_wand->wand.images,new_images); | 
|  | 4414 | return; | 
|  | 4415 | } | 
| anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4416 | if ( ( LocaleCompare("read",option+1) == 0 ) || | 
|  | 4417 | ( LocaleCompare("--",option) == 0 ) ) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4418 | { | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4419 | #if !USE_WAND_METHODS | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4420 | Image * | 
|  | 4421 | new_images; | 
|  | 4422 |  | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4423 | if (cli_wand->wand.image_info->ping != MagickFalse) | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4424 | new_images=PingImages(cli_wand->wand.image_info,arg1,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4425 | else | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4426 | new_images=ReadImages(cli_wand->wand.image_info,arg1,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4427 | AppendImageToList(&cli_wand->wand.images, new_images); | 
|  | 4428 | #else | 
|  | 4429 | /* read images using MagickWand method - no ping */ | 
|  | 4430 | /* This is not working! - it locks up in a CPU loop! */ | 
|  | 4431 | MagickSetLastIterator(&cli_wand->wand); | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4432 | MagickReadImage(&cli_wand->wand,arg1); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4433 | MagickSetFirstIterator(&cli_wand->wand); | 
|  | 4434 | #endif | 
|  | 4435 | return; | 
|  | 4436 | } | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4437 | /* No-op options */ | 
|  | 4438 | if (LocaleCompare("noop",option+1) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4439 | return; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4440 | if (LocaleCompare("sans",option+1) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4441 | return; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4442 | if (LocaleCompare("sans0",option+1) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4443 | return; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4444 | if (LocaleCompare("sans2",option+1) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4445 | return; | 
| anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4446 | if (LocaleCompare("list",option+1) == 0) | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4447 | { | 
|  | 4448 | /* FUTURE: This should really be built into the MagickCore | 
|  | 4449 | It does not actually require any wand or images at all! | 
|  | 4450 | */ | 
|  | 4451 | ssize_t | 
|  | 4452 | list; | 
|  | 4453 |  | 
| anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4454 | list=ParseCommandOption(MagickListOptions,MagickFalse, arg1); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4455 | switch (list) | 
|  | 4456 | { | 
|  | 4457 | case MagickCoderOptions: | 
|  | 4458 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4459 | (void) ListCoderInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4460 | break; | 
|  | 4461 | } | 
|  | 4462 | case MagickColorOptions: | 
|  | 4463 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4464 | (void) ListColorInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4465 | break; | 
|  | 4466 | } | 
|  | 4467 | case MagickConfigureOptions: | 
|  | 4468 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4469 | (void) ListConfigureInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4470 | break; | 
|  | 4471 | } | 
|  | 4472 | case MagickDelegateOptions: | 
|  | 4473 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4474 | (void) ListDelegateInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4475 | break; | 
|  | 4476 | } | 
|  | 4477 | case MagickFontOptions: | 
|  | 4478 | { | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4479 | (void) ListTypeInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4480 | break; | 
|  | 4481 | } | 
|  | 4482 | case MagickFormatOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4483 | (void) ListMagickInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4484 | break; | 
|  | 4485 | case MagickLocaleOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4486 | (void) ListLocaleInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4487 | break; | 
|  | 4488 | case MagickLogOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4489 | (void) ListLogInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4490 | break; | 
|  | 4491 | case MagickMagicOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4492 | (void) ListMagicInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4493 | break; | 
|  | 4494 | case MagickMimeOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4495 | (void) ListMimeInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4496 | break; | 
|  | 4497 | case MagickModuleOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4498 | (void) ListModuleInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4499 | break; | 
|  | 4500 | case MagickPolicyOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4501 | (void) ListPolicyInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4502 | break; | 
|  | 4503 | case MagickResourceOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4504 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4505 | break; | 
|  | 4506 | case MagickThresholdOptions: | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4507 | (void) ListThresholdMaps((FILE *) NULL,_exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4508 | break; | 
|  | 4509 | default: | 
|  | 4510 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4511 | _exception); | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4512 | break; | 
|  | 4513 | } | 
|  | 4514 | return; | 
|  | 4515 | } | 
|  | 4516 |  | 
|  | 4517 | #if 0 | 
|  | 4518 | // adjust stack handling | 
|  | 4519 | // Other 'special' options this should handle | 
|  | 4520 | //    "region" "list" "version" | 
|  | 4521 | // It does not do "exit" however as due to its side-effect requirements | 
|  | 4522 | #endif | 
|  | 4523 | #if 0 | 
|  | 4524 | if ( ( process_flags & ProcessUnknownOptionError ) != 0 ) | 
|  | 4525 | MagickExceptionReturn(OptionError,"InvalidUseOfOption",option); | 
|  | 4526 | #endif | 
|  | 4527 |  | 
| anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame^] | 4528 | #undef _exception | 
| anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4529 | } |