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 | fe676ee | 2013-11-18 13:03:38 +0000 | [diff] [blame] | 20 | % Copyright 1999-2014 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" |
cristy | d7df81d | 2014-01-18 18:42:05 +0000 | [diff] [blame^] | 53 | #include "MagickWand/mogrify.h" |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 54 | #include "MagickWand/wand.h" |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 55 | #include "MagickWand/wandcli.h" |
| 56 | #include "MagickWand/wandcli-private.h" |
cristy | e66172d | 2014-01-15 20:23:01 +0000 | [diff] [blame] | 57 | #include "MagickCore/image-private.h" |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 58 | #include "MagickCore/monitor-private.h" |
cristy | e66172d | 2014-01-15 20:23:01 +0000 | [diff] [blame] | 59 | #include "MagickWand/operation.h" |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 60 | #include "MagickCore/thread-private.h" |
| 61 | #include "MagickCore/string-private.h" |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 62 | #include "MagickCore/pixel-private.h" |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 63 | |
| 64 | /* |
cristy | d7df81d | 2014-01-18 18:42:05 +0000 | [diff] [blame^] | 65 | Constant declaration. |
| 66 | */ |
| 67 | static const char |
| 68 | MogrifyBackgroundColor[] = "#fff", /* white */ |
| 69 | MogrifyBorderColor[] = "#dfdfdf", /* sRGB gray */ |
| 70 | MogrifyMatteColor[] = "#bdbdbd"; /* slightly darker gray */ |
| 71 | |
| 72 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 73 | Define declarations. |
| 74 | */ |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 75 | #define USE_WAND_METHODS 1 |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 76 | #define MAX_STACK_DEPTH 32 |
| 77 | #define UNDEFINED_COMPRESSION_QUALITY 0UL |
| 78 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 79 | /* FUTURE: why is this default so specific? */ |
| 80 | #define DEFAULT_DISSIMILARITY_THRESHOLD "0.31830988618379067154" |
| 81 | |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 82 | /* For Debugging Geometry Input */ |
| 83 | #define ReportGeometry(flags,info) \ |
| 84 | (void) FormatLocaleFile(stderr, "Geometry = 0x%04X : %lg x %lg %+lg %+lg\n", \ |
| 85 | flags, info.rho, info.sigma, info.xi, info.psi ) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | ** Function to report on the progress of image operations |
| 89 | */ |
| 90 | static MagickBooleanType MonitorProgress(const char *text, |
| 91 | const MagickOffsetType offset,const MagickSizeType extent, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 92 | void *wand_unused(cli_wandent_data)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 93 | { |
| 94 | char |
| 95 | message[MaxTextExtent], |
| 96 | tag[MaxTextExtent]; |
| 97 | |
| 98 | const char |
| 99 | *locale_message; |
| 100 | |
| 101 | register char |
| 102 | *p; |
| 103 | |
| 104 | if (extent < 2) |
| 105 | return(MagickTrue); |
| 106 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 107 | p=strrchr(tag,'/'); |
| 108 | if (p != (char *) NULL) |
| 109 | *p='\0'; |
| 110 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
| 111 | locale_message=GetLocaleMessage(message); |
| 112 | if (locale_message == message) |
| 113 | locale_message=tag; |
| 114 | if (p == (char *) NULL) |
| 115 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 116 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 117 | (100L*offset/(extent-1))); |
| 118 | else |
| 119 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
| 120 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 121 | (100L*offset/(extent-1))); |
| 122 | if (offset == (MagickOffsetType) (extent-1)) |
| 123 | (void) FormatLocaleFile(stderr,"\n"); |
| 124 | (void) fflush(stderr); |
| 125 | return(MagickTrue); |
| 126 | } |
| 127 | |
| 128 | /* |
| 129 | ** GetImageCache() will read an image into a image cache if not already |
| 130 | ** present then return the image that is in the cache under that filename. |
| 131 | */ |
| 132 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 133 | ExceptionInfo *exception) |
| 134 | { |
| 135 | char |
| 136 | key[MaxTextExtent]; |
| 137 | |
| 138 | ExceptionInfo |
| 139 | *sans_exception; |
| 140 | |
| 141 | Image |
| 142 | *image; |
| 143 | |
| 144 | ImageInfo |
| 145 | *read_info; |
| 146 | |
| 147 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
| 148 | sans_exception=AcquireExceptionInfo(); |
| 149 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 150 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 151 | if (image != (Image *) NULL) |
| 152 | return(image); |
| 153 | read_info=CloneImageInfo(image_info); |
cristy | 4d246fc | 2014-01-15 22:33:44 +0000 | [diff] [blame] | 154 | if (path != (const char *) NULL) |
| 155 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 156 | image=ReadImage(read_info,exception); |
| 157 | read_info=DestroyImageInfo(read_info); |
| 158 | if (image != (Image *) NULL) |
| 159 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 160 | return(image); |
| 161 | } |
| 162 | |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 163 | /* |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 164 | SparseColorOption() parse the complex -sparse-color argument into an |
| 165 | an array of floating point values than call SparseColorImage(). |
| 166 | Argument is a complex mix of floating-point pixel coodinates, and color |
| 167 | specifications (or direct floating point numbers). The number of floats |
anthony | 4023b26 | 2013-06-03 07:43:50 +0000 | [diff] [blame] | 168 | needed to represent a color varies depending on the current channel |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 169 | setting. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 170 | |
| 171 | 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] | 172 | */ |
| 173 | static Image *SparseColorOption(const Image *image, |
cristy | ab94359 | 2013-03-29 16:47:23 +0000 | [diff] [blame] | 174 | const SparseColorMethod method,const char *arguments,ExceptionInfo *exception) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 175 | { |
| 176 | char |
| 177 | token[MaxTextExtent]; |
| 178 | |
| 179 | const char |
| 180 | *p; |
| 181 | |
| 182 | double |
| 183 | *sparse_arguments; |
| 184 | |
| 185 | Image |
| 186 | *sparse_image; |
| 187 | |
| 188 | PixelInfo |
| 189 | color; |
| 190 | |
| 191 | MagickBooleanType |
| 192 | error; |
| 193 | |
| 194 | register size_t |
| 195 | x; |
| 196 | |
| 197 | size_t |
| 198 | number_arguments, |
| 199 | number_colors; |
| 200 | |
| 201 | assert(image != (Image *) NULL); |
| 202 | assert(image->signature == MagickSignature); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 203 | if (IfMagickTrue(image->debug)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 204 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 205 | assert(exception != (ExceptionInfo *) NULL); |
| 206 | assert(exception->signature == MagickSignature); |
| 207 | /* |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 208 | Limit channels according to image |
| 209 | add up number of values needed per color. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 210 | */ |
| 211 | number_colors=0; |
| 212 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 213 | number_colors++; |
| 214 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 215 | number_colors++; |
| 216 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 217 | number_colors++; |
| 218 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 219 | (image->colorspace == CMYKColorspace)) |
| 220 | number_colors++; |
| 221 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 222 | image->alpha_trait == BlendPixelTrait) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 223 | number_colors++; |
| 224 | |
| 225 | /* |
| 226 | Read string, to determine number of arguments needed, |
| 227 | */ |
| 228 | p=arguments; |
| 229 | x=0; |
| 230 | while( *p != '\0' ) |
| 231 | { |
| 232 | GetMagickToken(p,&p,token); |
| 233 | if ( token[0] == ',' ) continue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 234 | if ( isalpha((int) token[0]) || token[0] == '#' ) |
| 235 | x += number_colors; /* color argument found */ |
anthony | ce8dcb3 | 2012-03-21 13:20:31 +0000 | [diff] [blame] | 236 | else |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 237 | x++; /* floating point argument */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 238 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 239 | /* control points and color values */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 240 | error = IsMagickTrue( x % (2+number_colors) ); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 241 | number_arguments=x; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 242 | if ( IfMagickTrue(error) ) { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 243 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 244 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 245 | "Invalid number of Arguments"); |
| 246 | return( (Image *)NULL); |
| 247 | } |
| 248 | |
| 249 | /* Allocate and fill in the floating point arguments */ |
| 250 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 251 | sizeof(*sparse_arguments)); |
| 252 | if (sparse_arguments == (double *) NULL) { |
| 253 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 254 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 255 | return( (Image *)NULL); |
| 256 | } |
| 257 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 258 | sizeof(*sparse_arguments)); |
| 259 | p=arguments; |
| 260 | x=0; |
| 261 | while( *p != '\0' && x < number_arguments ) { |
| 262 | /* X 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 X-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 | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 273 | /* Y coordinate */ |
| 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 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 278 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 279 | "Color found, instead of Y-coord"); |
| 280 | error = MagickTrue; |
| 281 | break; |
| 282 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 283 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 284 | /* color name or function given in string argument */ |
| 285 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 286 | if ( token[0] == '\0' ) break; |
| 287 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 288 | /* Color string given */ |
| 289 | (void) QueryColorCompliance(token,AllCompliance,&color, |
| 290 | exception); |
| 291 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 292 | sparse_arguments[x++] = QuantumScale*color.red; |
| 293 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 294 | sparse_arguments[x++] = QuantumScale*color.green; |
| 295 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 296 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 297 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 298 | (image->colorspace == CMYKColorspace)) |
| 299 | sparse_arguments[x++] = QuantumScale*color.black; |
| 300 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 301 | image->alpha_trait == BlendPixelTrait) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 302 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 303 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 304 | else { |
| 305 | /* Colors given as a set of floating point values - experimental */ |
| 306 | /* NB: token contains the first floating point value to use! */ |
| 307 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 308 | { |
| 309 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 310 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 311 | break; |
| 312 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 313 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 314 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 315 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 316 | { |
| 317 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 318 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 319 | break; |
| 320 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 321 | token[0] = ','; /* used this token - get another */ |
| 322 | } |
| 323 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 324 | { |
| 325 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 326 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 327 | break; |
| 328 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 329 | token[0] = ','; /* used this token - get another */ |
| 330 | } |
| 331 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 332 | (image->colorspace == CMYKColorspace)) |
| 333 | { |
| 334 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 335 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 336 | break; |
| 337 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 338 | token[0] = ','; /* used this token - get another */ |
| 339 | } |
| 340 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 341 | image->alpha_trait == BlendPixelTrait) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 342 | { |
| 343 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 344 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 345 | break; |
| 346 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
| 347 | token[0] = ','; /* used this token - get another */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 348 | } |
| 349 | } |
| 350 | } |
| 351 | if ( number_arguments != x && !error ) { |
| 352 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 353 | "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 354 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 355 | return( (Image *)NULL); |
| 356 | } |
| 357 | if ( error ) |
| 358 | return( (Image *)NULL); |
| 359 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 360 | /* Call the Sparse Color Interpolation function with the parsed arguments */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 361 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 362 | exception); |
| 363 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 364 | return( sparse_image ); |
| 365 | } |
| 366 | |
| 367 | /* |
| 368 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 369 | % % |
| 370 | % % |
| 371 | % % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 372 | % C L I S e t t i n g O p t i o n I n f o % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 373 | % % |
| 374 | % % |
| 375 | % % |
| 376 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 377 | % |
| 378 | % CLISettingOptionInfo() applies a single settings option into a CLI wand |
| 379 | % holding the image_info, draw_info, quantize_info structures that will be |
| 380 | % used when processing the images. |
| 381 | % |
| 382 | % These options do no require images to be present in the CLI wand for them |
| 383 | % to be able to be set, in which case they will generally be applied to image |
| 384 | % that are read in later |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 385 | % |
| 386 | % Options handled by this function are listed in CommandOptions[] of |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 387 | % "option.c" that is one of "SettingOptionFlags" option flags. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 388 | % |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 389 | % The format of the CLISettingOptionInfo method is: |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 390 | % |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 391 | % void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 392 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 393 | % |
| 394 | % A description of each parameter follows: |
| 395 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 396 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 397 | % |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 398 | % o option: The option string to be set |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 399 | % |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 400 | % o arg1, arg2: optional argument strings to the operation |
| 401 | % arg2 is currently only used by "-limit" |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 402 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 403 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 404 | WandPrivate void CLISettingOptionInfo(MagickCLI *cli_wand, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 405 | const char *option,const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 406 | { |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 407 | ssize_t |
| 408 | parse; /* option argument parsing (string to value table lookup) */ |
| 409 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 410 | const char /* percent escaped versions of the args */ |
| 411 | *arg1, |
| 412 | *arg2; |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 413 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 414 | #define _image_info (cli_wand->wand.image_info) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 415 | #define _image (cli_wand->wand.images) |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 416 | #define _exception (cli_wand->wand.exception) |
| 417 | #define _draw_info (cli_wand->draw_info) |
| 418 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 419 | #define IfSetOption (*option=='-') |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 420 | #define ArgBoolean IsMagickTrue(IfSetOption) |
| 421 | #define ArgBooleanNot IsMagickFalse(IfSetOption) |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 422 | #define ArgBooleanString (IfSetOption?"true":"false") |
| 423 | #define ArgOption(def) (IfSetOption?arg1:(const char *)(def)) |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 424 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 425 | assert(cli_wand != (MagickCLI *) NULL); |
| 426 | assert(cli_wand->signature == WandSignature); |
| 427 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 428 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 429 | if (IfMagickTrue(cli_wand->wand.debug)) |
| 430 | (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), |
| 431 | "- Setting Option: %s \"%s\" \"%s\"", option,arg1n,arg2n); |
| 432 | |
| 433 | arg1 = arg1n, |
| 434 | arg2 = arg2n; |
| 435 | |
| 436 | #if 1 |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 437 | #define _process_flags (cli_wand->process_flags) |
| 438 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
| 439 | /* Interpret Percent Escapes in Arguments - using first image */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 440 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 441 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 442 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 443 | /* Interpret Percent escapes in argument 1 */ |
| 444 | if (arg1n != (char *) NULL) { |
| 445 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 446 | if (arg1 == (char *) NULL) { |
| 447 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 448 | arg1=arg1n; /* use the given argument as is */ |
| 449 | } |
| 450 | } |
| 451 | if (arg2n != (char *) NULL) { |
| 452 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 453 | if (arg2 == (char *) NULL) { |
| 454 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 455 | arg2=arg2n; /* use the given argument as is */ |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | #undef _process_flags |
| 460 | #undef _option_type |
| 461 | #endif |
| 462 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 463 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 464 | { |
| 465 | case 'a': |
| 466 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 467 | if (LocaleCompare("adjoin",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 468 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 469 | _image_info->adjoin = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 470 | break; |
| 471 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 472 | if (LocaleCompare("affine",option+1) == 0) |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 473 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 474 | CLIWandWarnReplaced("-draw 'affine ...'"); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 475 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 476 | (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 477 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 478 | GetAffineMatrix(&_draw_info->affine); |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 479 | break; |
| 480 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 481 | if (LocaleCompare("antialias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 482 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 483 | _image_info->antialias = |
| 484 | _draw_info->stroke_antialias = |
| 485 | _draw_info->text_antialias = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 486 | break; |
| 487 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 488 | if (LocaleCompare("attenuate",option+1) == 0) |
| 489 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 490 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 491 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 492 | (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 493 | break; |
| 494 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 495 | if (LocaleCompare("authenticate",option+1) == 0) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 496 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 497 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 498 | break; |
| 499 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 500 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 501 | } |
| 502 | case 'b': |
| 503 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 504 | if (LocaleCompare("background",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 505 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 506 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 507 | _image_info only used directly for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 508 | SyncImageSettings() used to set per-image attribute. |
| 509 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 510 | FUTURE: if _image_info->background_color is not set then |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 511 | we should fall back to per-image background_color |
| 512 | |
| 513 | At this time -background will 'wipe out' the per-image |
| 514 | background color! |
| 515 | |
| 516 | Better error handling of QueryColorCompliance() needed. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 517 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 518 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
cristy | d7df81d | 2014-01-18 18:42:05 +0000 | [diff] [blame^] | 519 | (void) QueryColorCompliance(ArgOption(MogrifyBackgroundColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 520 | &_image_info->background_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 521 | break; |
| 522 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 523 | if (LocaleCompare("bias",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 524 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 525 | /* FUTURE: bias OBSOLETED, replaced by Artifact "convolve:bias" |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 526 | as it is actually rarely used except in direct convolve operations |
| 527 | Usage outside a direct convolve operation is actally non-sensible! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 528 | |
| 529 | SyncImageSettings() used to set per-image attribute. |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 530 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 531 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 532 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 533 | (void) SetImageOption(_image_info,"convolve:bias",ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 534 | break; |
| 535 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 536 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 537 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 538 | /* Used as a image chromaticity setting |
| 539 | SyncImageSettings() used to set per-image attribute. |
| 540 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 541 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 542 | break; |
| 543 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 544 | if (LocaleCompare("blue-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 545 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 546 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 547 | Used by many coders including PNG |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 548 | SyncImageSettings() used to set per-image attribute. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 549 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 550 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 551 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 552 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 553 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 554 | break; |
| 555 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 556 | if (LocaleCompare("bordercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 557 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 558 | /* FUTURE: both _image_info attribute & ImageOption in use! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 559 | SyncImageSettings() used to set per-image attribute. |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 560 | Better error checking of QueryColorCompliance(). |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 561 | */ |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 562 | if (IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 563 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 564 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 565 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 566 | &_image_info->border_color,_exception); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 567 | (void) QueryColorCompliance(arg1,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 568 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 569 | break; |
| 570 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 571 | (void) DeleteImageOption(_image_info,option+1); |
cristy | d7df81d | 2014-01-18 18:42:05 +0000 | [diff] [blame^] | 572 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 573 | &_image_info->border_color,_exception); |
cristy | d7df81d | 2014-01-18 18:42:05 +0000 | [diff] [blame^] | 574 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 575 | &_draw_info->border_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 576 | break; |
| 577 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 578 | if (LocaleCompare("box",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 579 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 580 | CLIWandWarnReplaced("-undercolor"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 581 | CLISettingOptionInfo(cli_wand,"-undercolor",arg1, arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 582 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 583 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 584 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 585 | } |
| 586 | case 'c': |
| 587 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 588 | if (LocaleCompare("cache",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 589 | { |
| 590 | MagickSizeType |
| 591 | limit; |
| 592 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 593 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 594 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 595 | limit=MagickResourceInfinity; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 596 | if (LocaleCompare("unlimited",arg1) != 0) |
| 597 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 598 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 599 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 600 | break; |
| 601 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 602 | if (LocaleCompare("caption",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 603 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 604 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 605 | break; |
| 606 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 607 | if (LocaleCompare("channel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 608 | { |
anthony | 4023b26 | 2013-06-03 07:43:50 +0000 | [diff] [blame] | 609 | parse=ParseChannelOption(ArgOption("Default")); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 610 | if (parse < 0) |
| 611 | CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType", |
| 612 | option,arg1); |
| 613 | _image_info->channel=(ChannelType) parse; |
| 614 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 615 | break; |
| 616 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 617 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 618 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 619 | /* Setting used for new images via AquireImage() |
| 620 | But also used as a SimpleImageOperator |
| 621 | Undefined colorspace means don't modify images on |
| 622 | read or as a operation */ |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 623 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 624 | ArgOption("undefined")); |
| 625 | if (parse < 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 626 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 627 | option,arg1); |
anthony | 30b912a | 2012-03-22 01:20:28 +0000 | [diff] [blame] | 628 | _image_info->colorspace=(ColorspaceType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 629 | break; |
| 630 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 631 | if (LocaleCompare("comment",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 632 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 633 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 634 | break; |
| 635 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 636 | if (LocaleCompare("compose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 637 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 638 | /* FUTURE: _image_info should be used, |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 639 | SyncImageSettings() used to set per-image attribute. - REMOVE |
| 640 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 641 | This setting should NOT be used to set image 'compose' |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 642 | "-layer" operators shoud use _image_info if defined otherwise |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 643 | they should use a per-image compose setting. |
anthony | 965524b | 2011-10-07 12:34:14 +0000 | [diff] [blame] | 644 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 645 | parse = ParseCommandOption(MagickComposeOptions,MagickFalse, |
| 646 | ArgOption("undefined")); |
| 647 | if (parse < 0) |
| 648 | CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", |
| 649 | option,arg1); |
| 650 | _image_info->compose=(CompositeOperator) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 651 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 652 | break; |
| 653 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 654 | if (LocaleCompare("compress",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 655 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 656 | /* FUTURE: What should be used? _image_info or ImageOption ??? |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 657 | The former is more efficent, but Crisy prefers the latter! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 658 | SyncImageSettings() used to set per-image attribute. |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 659 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 660 | The coders appears to use _image_info, not Image_Option |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 661 | however the image attribute (for save) is set from the |
| 662 | ImageOption! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 663 | |
| 664 | Note that "undefined" is a different setting to "none". |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 665 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 666 | parse = ParseCommandOption(MagickCompressOptions,MagickFalse, |
| 667 | ArgOption("undefined")); |
| 668 | if (parse < 0) |
| 669 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", |
| 670 | option,arg1); |
| 671 | _image_info->compression=(CompressionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 672 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 673 | break; |
| 674 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 675 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 676 | } |
| 677 | case 'd': |
| 678 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 679 | if (LocaleCompare("debug",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 680 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 681 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 682 | arg1=ArgOption("none"); |
| 683 | parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); |
| 684 | if (parse < 0) |
| 685 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", |
| 686 | option,arg1); |
| 687 | (void) SetLogEventMask(arg1); |
| 688 | _image_info->debug=IsEventLogging(); /* extract logging*/ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 689 | cli_wand->wand.debug=IsEventLogging(); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 690 | break; |
| 691 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 692 | if (LocaleCompare("define",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 693 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 694 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 695 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 696 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 697 | (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 698 | else |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 699 | (void) DeleteImageRegistry(arg1+9); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 700 | break; |
| 701 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 702 | /* DefineImageOption() equals SetImageOption() but with '=' */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 703 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 704 | (void) DefineImageOption(_image_info,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 705 | else if (IsMagickFalse(DeleteImageOption(_image_info,arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 706 | CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 707 | break; |
| 708 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 709 | if (LocaleCompare("delay",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 710 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 711 | /* Only used for new images via AcquireImage() |
| 712 | FUTURE: Option should also be used for "-morph" (color morphing) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 713 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 714 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 715 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 716 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 717 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 718 | break; |
| 719 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 720 | if (LocaleCompare("density",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 721 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 722 | /* FUTURE: strings used in _image_info attr and _draw_info! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 723 | Basically as density can be in a XxY form! |
| 724 | |
| 725 | SyncImageSettings() used to set per-image attribute. |
| 726 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 727 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 728 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 729 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 730 | (void) CloneString(&_image_info->density,ArgOption(NULL)); |
| 731 | (void) CloneString(&_draw_info->density,_image_info->density); |
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("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 735 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 736 | /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! |
| 737 | SyncImageSettings() used to set per-image attribute. |
| 738 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 739 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 740 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 741 | _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 742 | :MAGICKCORE_QUANTUM_DEPTH; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 743 | break; |
| 744 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 745 | if (LocaleCompare("direction",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 746 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 747 | /* Image Option is only used to set _draw_info */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 748 | arg1=ArgOption("undefined"); |
| 749 | parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); |
| 750 | if (parse < 0) |
| 751 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", |
| 752 | option,arg1); |
| 753 | _draw_info->direction=(DirectionType) parse; |
| 754 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 755 | break; |
| 756 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 757 | if (LocaleCompare("display",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 758 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 759 | (void) CloneString(&_image_info->server_name,ArgOption(NULL)); |
| 760 | (void) CloneString(&_draw_info->server_name,_image_info->server_name); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 761 | break; |
| 762 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 763 | if (LocaleCompare("dispose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 764 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 765 | /* only used in setting new images */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 766 | arg1=ArgOption("undefined"); |
| 767 | parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); |
| 768 | if (parse < 0) |
| 769 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", |
| 770 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 771 | (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 772 | break; |
| 773 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 774 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 775 | { |
| 776 | /* FUTURE: this is only used by CompareImages() which is used |
| 777 | only by the "compare" CLI program at this time. */ |
| 778 | arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD); |
| 779 | if (IfMagickFalse(IsGeometry(arg1))) |
| 780 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 781 | (void) SetImageOption(_image_info,option+1,arg1); |
| 782 | break; |
| 783 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 784 | if (LocaleCompare("dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 785 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 786 | /* _image_info attr (on/off), _quantize_info attr (on/off) |
| 787 | but also ImageInfo and _quantize_info method! |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 788 | FUTURE: merge the duality of the dithering options |
| 789 | */ |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 790 | _image_info->dither = ArgBoolean; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 791 | (void) SetImageOption(_image_info,option+1,ArgOption("none")); |
| 792 | _quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 793 | MagickDitherOptions,MagickFalse,ArgOption("none")); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 794 | if (_quantize_info->dither_method == NoDitherMethod) |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 795 | _image_info->dither = MagickFalse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 796 | break; |
| 797 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 798 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 799 | } |
| 800 | case 'e': |
| 801 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 802 | if (LocaleCompare("encoding",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 803 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 804 | (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); |
| 805 | (void) SetImageOption(_image_info,option+1,_draw_info->encoding); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 806 | break; |
| 807 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 808 | if (LocaleCompare("endian",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 809 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 810 | /* Both _image_info attr and ImageInfo */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 811 | arg1 = ArgOption("undefined"); |
| 812 | parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); |
| 813 | if (parse < 0) |
| 814 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", |
| 815 | option,arg1); |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 816 | /* FUTURE: check alloc/free of endian string! - remove? */ |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 817 | _image_info->endian=(EndianType) (*arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 818 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 819 | break; |
| 820 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 821 | if (LocaleCompare("extract",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 822 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 823 | (void) CloneString(&_image_info->extract,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 824 | break; |
| 825 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 826 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 827 | } |
| 828 | case 'f': |
| 829 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 830 | if (LocaleCompare("family",option+1) == 0) |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 831 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 832 | (void) CloneString(&_draw_info->family,ArgOption(NULL)); |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 833 | break; |
| 834 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 835 | if (LocaleCompare("features",option+1) == 0) |
| 836 | { |
| 837 | (void) SetImageOption(_image_info,"identify:features", |
cristy | f9b9b66 | 2013-05-25 12:50:16 +0000 | [diff] [blame] | 838 | ArgBooleanString); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 839 | if (IfSetOption) |
| 840 | (void) SetImageArtifact(_image,"verbose","true"); |
| 841 | break; |
| 842 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 843 | if (LocaleCompare("fill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 844 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 845 | /* Set "fill" OR "fill-pattern" in _draw_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 846 | The original fill color is preserved if a fill-pattern is given. |
| 847 | That way it does not effect other operations that directly using |
| 848 | the fill color and, can be retored using "+tile". |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 849 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 850 | MagickBooleanType |
| 851 | status; |
anthony | 6dc09cd | 2011-10-12 08:56:49 +0000 | [diff] [blame] | 852 | |
| 853 | ExceptionInfo |
| 854 | *sans; |
| 855 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 856 | PixelInfo |
| 857 | color; |
| 858 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 859 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 860 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 861 | if (_draw_info->fill_pattern != (Image *) NULL) |
| 862 | _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 863 | |
| 864 | /* is it a color or a image? -- ignore exceptions */ |
| 865 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 866 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 867 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 868 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 869 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 870 | _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 871 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 872 | _draw_info->fill=color; |
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("filter",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 876 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 877 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 878 | arg1 = ArgOption("undefined"); |
| 879 | parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); |
| 880 | if (parse < 0) |
| 881 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", |
| 882 | option,arg1); |
| 883 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 884 | break; |
| 885 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 886 | if (LocaleCompare("font",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 887 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 888 | (void) CloneString(&_draw_info->font,ArgOption(NULL)); |
| 889 | (void) CloneString(&_image_info->font,_draw_info->font); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 890 | break; |
| 891 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 892 | if (LocaleCompare("format",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 893 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 894 | /* FUTURE: why the ping test, you could set ping after this! */ |
| 895 | /* |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 896 | register const char |
| 897 | *q; |
| 898 | |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 899 | for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 900 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 901 | _image_info->ping=MagickFalse; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 902 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 903 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 904 | break; |
| 905 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 906 | if (LocaleCompare("fuzz",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 907 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 908 | /* Option used to set image fuzz! unless blank canvas (from color) |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 909 | Image attribute used for color compare operations |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 910 | SyncImageSettings() used to set per-image attribute. |
| 911 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 912 | FUTURE: Can't find anything else using _image_info->fuzz directly! |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 913 | convert structure attribute to 'option' string |
anthony | 6613bf3 | 2011-10-15 07:24:44 +0000 | [diff] [blame] | 914 | */ |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 915 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 916 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 917 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 918 | _image_info->fuzz=StringToDoubleInterval(arg1,(double) |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 919 | QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 920 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 921 | break; |
| 922 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 923 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 924 | } |
| 925 | case 'g': |
| 926 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 927 | if (LocaleCompare("gravity",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 928 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 929 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 930 | arg1 = ArgOption("none"); |
| 931 | parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); |
| 932 | if (parse < 0) |
| 933 | CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", |
| 934 | option,arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 935 | _draw_info->gravity=(GravityType) parse; |
anthony | e849097 | 2012-04-03 13:16:01 +0000 | [diff] [blame] | 936 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 937 | break; |
| 938 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 939 | if (LocaleCompare("green-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 940 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 941 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 942 | SyncImageSettings() used to set per-image attribute. |
| 943 | Used directly by many coders |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 944 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 945 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 946 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 947 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 948 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 949 | break; |
| 950 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 951 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 952 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 953 | case 'h': |
| 954 | { |
| 955 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 956 | { |
| 957 | /* FUTURE: this is only used by CompareImages() which is used |
| 958 | only by the "compare" CLI program at this time. */ |
| 959 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 960 | break; |
| 961 | } |
| 962 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
| 963 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 964 | case 'i': |
| 965 | { |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 966 | if (LocaleCompare("intensity",option+1) == 0) |
| 967 | { |
| 968 | arg1 = ArgOption("undefined"); |
cristy | 8f84fdd | 2013-03-28 17:52:55 +0000 | [diff] [blame] | 969 | parse = ParseCommandOption(MagickPixelIntensityOptions,MagickFalse, |
| 970 | arg1); |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 971 | if (parse < 0) |
cristy | 8f84fdd | 2013-03-28 17:52:55 +0000 | [diff] [blame] | 972 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntensityType", |
| 973 | option,arg1); |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 974 | (void) SetImageOption(_image_info,option+1,arg1); |
| 975 | break; |
| 976 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 977 | if (LocaleCompare("intent",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 | /* Only used by coders: MIFF, MPC, BMP, PNG |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 980 | and for image profile call to AcquireTransformThreadSet() |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 981 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 982 | */ |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 983 | arg1 = ArgOption("undefined"); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 984 | parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); |
| 985 | if (parse < 0) |
| 986 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", |
| 987 | option,arg1); |
| 988 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 989 | break; |
| 990 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 991 | if (LocaleCompare("interlace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 992 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 993 | /* _image_info is directly used by coders (so why an image setting?) |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 994 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 995 | */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 996 | arg1 = ArgOption("undefined"); |
| 997 | parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); |
| 998 | if (parse < 0) |
| 999 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", |
| 1000 | option,arg1); |
| 1001 | _image_info->interlace=(InterlaceType) parse; |
| 1002 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1003 | break; |
| 1004 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1005 | if (LocaleCompare("interline-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1006 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1007 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1008 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1009 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1010 | _draw_info->interline_spacing=StringToDouble(ArgOption("0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1011 | (char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1012 | break; |
| 1013 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1014 | if (LocaleCompare("interpolate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1015 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1016 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1017 | arg1 = ArgOption("undefined"); |
| 1018 | parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); |
| 1019 | if (parse < 0) |
| 1020 | CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", |
| 1021 | option,arg1); |
| 1022 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1023 | break; |
| 1024 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1025 | if (LocaleCompare("interword-spacing",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1026 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1027 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1028 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1029 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
| 1030 | _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1031 | break; |
| 1032 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1033 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1034 | } |
| 1035 | case 'k': |
| 1036 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1037 | if (LocaleCompare("kerning",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1038 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1039 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1040 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1041 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1042 | _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1043 | break; |
| 1044 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1045 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1046 | } |
| 1047 | case 'l': |
| 1048 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1049 | if (LocaleCompare("label",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1050 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1051 | /* only used for new images - not in SyncImageOptions() */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1052 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1053 | break; |
| 1054 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1055 | if (LocaleCompare("limit",option+1) == 0) |
| 1056 | { |
| 1057 | MagickSizeType |
| 1058 | limit; |
| 1059 | |
| 1060 | limit=MagickResourceInfinity; |
| 1061 | parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); |
| 1062 | if ( parse < 0 ) |
| 1063 | CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", |
| 1064 | option,arg1); |
| 1065 | if (LocaleCompare("unlimited",arg2) != 0) |
| 1066 | limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); |
| 1067 | (void) SetMagickResourceLimit((ResourceType)parse,limit); |
| 1068 | break; |
| 1069 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1070 | if (LocaleCompare("log",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1071 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1072 | if (IfSetOption) { |
| 1073 | if ((strchr(arg1,'%') == (char *) NULL)) |
| 1074 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1075 | (void) SetLogFormat(arg1); |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1076 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1077 | break; |
| 1078 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1079 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1080 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1081 | /* FUTURE: this is only used by CompareImages() which is used |
| 1082 | only by the "compare" CLI program at this time. */ |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 1083 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1084 | break; |
| 1085 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1086 | if (LocaleCompare("loop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1087 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1088 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1089 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1090 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1091 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1092 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1093 | break; |
| 1094 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1095 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1096 | } |
| 1097 | case 'm': |
| 1098 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1099 | if (LocaleCompare("mattecolor",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 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1102 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
cristy | d7df81d | 2014-01-18 18:42:05 +0000 | [diff] [blame^] | 1103 | (void) QueryColorCompliance(ArgOption(MogrifyMatteColor),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1104 | &_image_info->matte_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1105 | break; |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1106 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1107 | if (LocaleCompare("metric",option+1) == 0) |
| 1108 | { |
| 1109 | /* FUTURE: this is only used by CompareImages() which is used |
| 1110 | only by the "compare" CLI program at this time. */ |
| 1111 | parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1); |
| 1112 | if ( parse < 0 ) |
| 1113 | CLIWandExceptArgBreak(OptionError,"UnrecognizedMetricType", |
| 1114 | option,arg1); |
| 1115 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1116 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1117 | } |
cristy | bd4a3c2 | 2014-01-07 15:09:37 +0000 | [diff] [blame] | 1118 | if (LocaleCompare("moments",option+1) == 0) |
| 1119 | { |
| 1120 | (void) SetImageOption(_image_info,"identify:moments", |
| 1121 | ArgBooleanString); |
| 1122 | if (IfSetOption) |
| 1123 | (void) SetImageArtifact(_image,"verbose","true"); |
| 1124 | break; |
| 1125 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1126 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1127 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1128 | (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1129 | MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1130 | break; |
| 1131 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1132 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1133 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1134 | /* Setting (used by some input coders!) -- why? |
| 1135 | Warning: This is also Special '-type' SimpleOperator |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1136 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1137 | _image_info->monochrome= ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1138 | break; |
| 1139 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1140 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1141 | } |
| 1142 | case 'o': |
| 1143 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1144 | if (LocaleCompare("orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1145 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1146 | /* Is not used when defining for new images. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1147 | This makes it more of a 'operation' than a setting |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1148 | FUTURE: make set meta-data operator instead. |
| 1149 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1150 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1151 | parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
| 1152 | ArgOption("undefined")); |
| 1153 | if (parse < 0) |
| 1154 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", |
| 1155 | option,arg1); |
| 1156 | _image_info->orientation=(OrientationType)parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1157 | (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1158 | break; |
| 1159 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1160 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1161 | } |
| 1162 | case 'p': |
| 1163 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1164 | if (LocaleCompare("page",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1165 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1166 | /* Only used for new images and image generators. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1167 | SyncImageSettings() used to set per-image attribute. ????? |
| 1168 | That last is WRONG!!!! |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1169 | FUTURE: adjust named 'page' sizes according density |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1170 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1171 | char |
| 1172 | *canonical_page, |
| 1173 | page[MaxTextExtent]; |
| 1174 | |
| 1175 | const char |
| 1176 | *image_option; |
| 1177 | |
| 1178 | MagickStatusType |
| 1179 | flags; |
| 1180 | |
| 1181 | RectangleInfo |
| 1182 | geometry; |
| 1183 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1184 | if (!IfSetOption) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1185 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1186 | (void) DeleteImageOption(_image_info,option+1); |
| 1187 | (void) CloneString(&_image_info->page,(char *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1188 | break; |
| 1189 | } |
| 1190 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1191 | image_option=GetImageOption(_image_info,"page"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1192 | if (image_option != (const char *) NULL) |
| 1193 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1194 | canonical_page=GetPageGeometry(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1195 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 1196 | canonical_page=DestroyString(canonical_page); |
| 1197 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
| 1198 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
| 1199 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1200 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 1201 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 1202 | (long) geometry.x,(long) geometry.y); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1203 | (void) SetImageOption(_image_info,option+1,page); |
| 1204 | (void) CloneString(&_image_info->page,page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1205 | break; |
| 1206 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1207 | if (LocaleCompare("ping",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1208 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1209 | _image_info->ping = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1210 | break; |
| 1211 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1212 | if (LocaleCompare("pointsize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1213 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1214 | if (IfSetOption) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1215 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1216 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1217 | _image_info->pointsize = |
| 1218 | _draw_info->pointsize = |
| 1219 | StringToDouble(arg1,(char **) NULL); |
| 1220 | } |
| 1221 | else { |
| 1222 | _image_info->pointsize=0.0; /* unset pointsize */ |
| 1223 | _draw_info->pointsize=12.0; |
| 1224 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1225 | break; |
| 1226 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1227 | if (LocaleCompare("precision",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1228 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1229 | arg1=ArgOption("-1"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1230 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1231 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1232 | (void) SetMagickPrecision(StringToInteger(arg1)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1233 | break; |
| 1234 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1235 | /* FUTURE: Only the 'preview' coder appears to use this |
anthony | a3ef4ed | 2012-03-17 06:52:53 +0000 | [diff] [blame] | 1236 | * DEPRECIATE the coder? Leaving only the 'preview' operator. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1237 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1238 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1239 | _image_info->preview_type=UndefinedPreview; |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1240 | if (IfSetOption) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1241 | _image_info->preview_type=(PreviewType) ParseCommandOption( |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1242 | MagickPreviewOptions,MagickFalse,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1243 | break; |
| 1244 | } |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1245 | */ |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1246 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1247 | } |
| 1248 | case 'q': |
| 1249 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1250 | if (LocaleCompare("quality",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1251 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1252 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1253 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1254 | _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1) |
| 1255 | : UNDEFINED_COMPRESSION_QUALITY; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1256 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1257 | break; |
| 1258 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1259 | if (LocaleCompare("quantize",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1260 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1261 | /* Just a set direct in _quantize_info */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 1262 | arg1=ArgOption("undefined"); |
| 1263 | parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); |
| 1264 | if (parse < 0) |
| 1265 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", |
| 1266 | option,arg1); |
| 1267 | _quantize_info->colorspace=(ColorspaceType)parse; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1268 | break; |
| 1269 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1270 | if (LocaleCompare("quiet",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1271 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1272 | /* FUTURE: if two -quiet is performed you can not do +quiet! |
| 1273 | This needs to be checked over thoughly. |
| 1274 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1275 | static WarningHandler |
| 1276 | warning_handler = (WarningHandler) NULL; |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1277 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1278 | WarningHandler |
| 1279 | tmp = SetWarningHandler((WarningHandler) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1280 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1281 | if ( tmp != (WarningHandler) NULL) |
| 1282 | warning_handler = tmp; /* remember the old handler */ |
| 1283 | if (!IfSetOption) /* set the old handler */ |
| 1284 | warning_handler=SetWarningHandler(warning_handler); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1285 | break; |
| 1286 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1287 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1288 | } |
| 1289 | case 'r': |
| 1290 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1291 | if (LocaleCompare("red-primary",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1292 | { |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1293 | /* Image chromaticity X,Y NB: Y=X if Y not defined |
| 1294 | Used by many coders |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1295 | SyncImageSettings() used to set per-image attribute. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1296 | */ |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1297 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1298 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1299 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1300 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1301 | break; |
| 1302 | } |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1303 | if (LocaleCompare("regard-warnings",option+1) == 0) |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 1304 | /* FUTURE: to be replaced by a 'fatal-level' type setting */ |
cristy | b0f7a18 | 2012-04-06 23:33:11 +0000 | [diff] [blame] | 1305 | break; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1306 | if (LocaleCompare("render",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1307 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1308 | /* _draw_info only setting */ |
| 1309 | _draw_info->render= ArgBooleanNot; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1310 | break; |
| 1311 | } |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 1312 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
| 1313 | { |
| 1314 | /* link image and setting stacks - option is itself saved on stack! */ |
| 1315 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1316 | break; |
| 1317 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1318 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1319 | } |
| 1320 | case 's': |
| 1321 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1322 | if (LocaleCompare("sampling-factor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1323 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1324 | /* FUTURE: should be converted to jpeg:sampling_factor */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1325 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1326 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1327 | (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1328 | break; |
| 1329 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1330 | if (LocaleCompare("scene",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1331 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1332 | /* SyncImageSettings() used to set this as a per-image attribute. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1333 | What ??? Why ???? |
| 1334 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1335 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1336 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1337 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1338 | _image_info->scene=StringToUnsignedLong(ArgOption("0")); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1339 | break; |
| 1340 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1341 | if (LocaleCompare("seed",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1342 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1343 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1344 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame] | 1345 | SetRandomSecretKey( |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 1346 | IfSetOption ? (unsigned long) StringToUnsignedLong(arg1) |
| 1347 | : (unsigned long) time((time_t *) NULL) ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1348 | break; |
| 1349 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1350 | if (LocaleCompare("size",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1351 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1352 | /* FUTURE: string in _image_info -- convert to Option ??? |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1353 | Look at the special handling for "size" in SetImageOption() |
anthony | 74b1cfc | 2011-10-06 12:44:16 +0000 | [diff] [blame] | 1354 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1355 | (void) CloneString(&_image_info->size,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1356 | break; |
| 1357 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1358 | if (LocaleCompare("stretch",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1359 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1360 | arg1=ArgOption("undefined"); |
| 1361 | parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1); |
| 1362 | if (parse < 0) |
| 1363 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStretchType", |
| 1364 | option,arg1); |
| 1365 | _draw_info->stretch=(StretchType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1366 | break; |
| 1367 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1368 | if (LocaleCompare("stroke",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1369 | { |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1370 | /* set stroke color OR stroke-pattern |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1371 | UPDATE: ensure stroke color is not destroyed is a pattern |
| 1372 | is given. Just in case the color is also used for other purposes. |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1373 | */ |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1374 | MagickBooleanType |
| 1375 | status; |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1376 | |
| 1377 | ExceptionInfo |
| 1378 | *sans; |
| 1379 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1380 | PixelInfo |
| 1381 | color; |
| 1382 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1383 | arg1 = ArgOption("none"); /* +fill turns it off! */ |
| 1384 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1385 | if (_draw_info->stroke_pattern != (Image *) NULL) |
| 1386 | _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1387 | |
| 1388 | /* is it a color or a image? -- ignore exceptions */ |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1389 | sans=AcquireExceptionInfo(); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1390 | status=QueryColorCompliance(arg1,AllCompliance,&color,sans); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1391 | sans=DestroyExceptionInfo(sans); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1392 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1393 | if (IfMagickFalse(status)) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1394 | _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1395 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1396 | _draw_info->stroke=color; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1397 | break; |
| 1398 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1399 | if (LocaleCompare("strokewidth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1400 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1401 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1402 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1403 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1404 | _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1405 | (char **) NULL); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1406 | break; |
| 1407 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1408 | if (LocaleCompare("style",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1409 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1410 | arg1=ArgOption("undefined"); |
| 1411 | parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1); |
| 1412 | if (parse < 0) |
| 1413 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStyleType", |
| 1414 | option,arg1); |
| 1415 | _draw_info->style=(StyleType) parse; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1416 | break; |
| 1417 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1418 | #if 0 |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 1419 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 1420 | { |
| 1421 | /* FUTURE: this is only used by CompareImages() which is used |
| 1422 | only by the "compare" CLI program at this time. */ |
| 1423 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1424 | break; |
| 1425 | } |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 1426 | #endif |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1427 | if (LocaleCompare("synchronize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1428 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 1429 | /* FUTURE: syncronize to storage - but what does that mean? */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1430 | _image_info->synchronize = ArgBoolean; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1431 | break; |
| 1432 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1433 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1434 | } |
| 1435 | case 't': |
| 1436 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1437 | if (LocaleCompare("taint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1438 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1439 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1440 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1441 | break; |
| 1442 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1443 | if (LocaleCompare("texture",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1444 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1445 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1446 | /* FUTURE: move _image_info string to option splay-tree |
| 1447 | Other than "montage" what uses "texture" ???? |
| 1448 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1449 | (void) CloneString(&_image_info->texture,ArgOption(NULL)); |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1450 | break; |
| 1451 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1452 | if (LocaleCompare("tile",option+1) == 0) |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1453 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1454 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1455 | _draw_info->fill_pattern=IfSetOption |
| 1456 | ?GetImageCache(_image_info,arg1,_exception) |
| 1457 | :DestroyImage(_draw_info->fill_pattern); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1458 | break; |
| 1459 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1460 | if (LocaleCompare("tile-offset",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1461 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1462 | /* SyncImageSettings() used to set per-image attribute. ??? */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1463 | arg1=ArgOption("0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1464 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1465 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1466 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1467 | break; |
| 1468 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1469 | if (LocaleCompare("transparent-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1470 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1471 | /* FUTURE: both _image_info attribute & ImageOption in use! |
| 1472 | _image_info only used for generating new images. |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1473 | SyncImageSettings() used to set per-image attribute. |
| 1474 | |
anthony | afbaed7 | 2011-10-26 12:05:04 +0000 | [diff] [blame] | 1475 | Note that +transparent-color, means fall-back to image |
| 1476 | attribute so ImageOption is deleted, not set to a default. |
| 1477 | */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1478 | if (IfSetOption && IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1479 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1480 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1481 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1482 | &_image_info->transparent_color,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1483 | break; |
| 1484 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1485 | if (LocaleCompare("treedepth",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1486 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1487 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
| 1488 | _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1489 | break; |
| 1490 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1491 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1492 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1493 | /* SyncImageSettings() used to set per-image attribute. */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1494 | parse=ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 1495 | ArgOption("undefined")); |
| 1496 | if (parse < 0) |
| 1497 | CLIWandExceptArgBreak(OptionError,"UnrecognizedImageType", |
| 1498 | option,arg1); |
| 1499 | _image_info->type=(ImageType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1500 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1501 | break; |
| 1502 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1503 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1504 | } |
| 1505 | case 'u': |
| 1506 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1507 | if (LocaleCompare("undercolor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1508 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1509 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1510 | (void) QueryColorCompliance(ArgOption("none"),AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1511 | &_draw_info->undercolor,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1512 | break; |
| 1513 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1514 | if (LocaleCompare("units",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1515 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1516 | /* SyncImageSettings() used to set per-image attribute. |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1517 | Should this effect _draw_info X and Y resolution? |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1518 | FUTURE: this probably should be part of the density setting |
| 1519 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1520 | parse=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
| 1521 | ArgOption("undefined")); |
| 1522 | if (parse < 0) |
| 1523 | CLIWandExceptArgBreak(OptionError,"UnrecognizedUnitsType", |
| 1524 | option,arg1); |
| 1525 | _image_info->units=(ResolutionType) parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1526 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1527 | break; |
| 1528 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1529 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1530 | } |
| 1531 | case 'v': |
| 1532 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1533 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1534 | { |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1535 | /* FUTURE: Remember all options become image artifacts |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1536 | _image_info->verbose is only used by coders. |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1537 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1538 | (void) SetImageOption(_image_info,option+1,ArgBooleanString); |
| 1539 | _image_info->verbose= ArgBoolean; |
| 1540 | _image_info->ping=MagickFalse; /* verbose can't be a ping */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1541 | break; |
| 1542 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1543 | if (LocaleCompare("view",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1544 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1545 | /* FUTURE: Convert from _image_info to ImageOption |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1546 | Only used by coder FPX |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1547 | And it only tests existance, not its content! |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1548 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1549 | (void) CloneString(&_image_info->view,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1550 | break; |
| 1551 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1552 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1553 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1554 | /* SyncImageSettings() used to set per-image attribute. |
| 1555 | This is VERY deep in the image caching structure. |
| 1556 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1557 | parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 1558 | ArgOption("undefined")); |
| 1559 | if (parse < 0) |
| 1560 | CLIWandExceptArgBreak(OptionError,"UnrecognizedVirtualPixelMethod", |
| 1561 | option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1562 | (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1563 | break; |
| 1564 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1565 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1566 | } |
| 1567 | case 'w': |
| 1568 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1569 | if (LocaleCompare("weight",option+1) == 0) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1570 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1571 | /* Just what does using a font 'weight' do ??? |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1572 | There is no "-list weight" output (reference manual says there is) |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1573 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1574 | arg1=ArgOption("all"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1575 | _draw_info->weight=StringToUnsignedLong(arg1); |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1576 | if (LocaleCompare(arg1,"all") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1577 | _draw_info->weight=0; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1578 | if (LocaleCompare(arg1,"bold") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1579 | _draw_info->weight=700; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1580 | if (LocaleCompare(arg1,"bolder") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1581 | if (_draw_info->weight <= 800) |
| 1582 | _draw_info->weight+=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1583 | if (LocaleCompare(arg1,"lighter") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1584 | if (_draw_info->weight >= 100) |
| 1585 | _draw_info->weight-=100; |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1586 | if (LocaleCompare(arg1,"normal") == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1587 | _draw_info->weight=400; |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 1588 | break; |
| 1589 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1590 | if (LocaleCompare("white-point",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1591 | { |
anthony | 72feaa6 | 2012-01-17 06:46:23 +0000 | [diff] [blame] | 1592 | /* Used as a image chromaticity setting |
| 1593 | SyncImageSettings() used to set per-image attribute. |
| 1594 | */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1595 | arg1=ArgOption("0.0"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1596 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 1597 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1598 | (void) SetImageOption(_image_info,option+1,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1599 | break; |
| 1600 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1601 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1602 | } |
| 1603 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1604 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1605 | } |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1606 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1607 | /* clean up percent escape interpreted strings */ |
| 1608 | if (arg1 != arg1n ) |
| 1609 | arg1=DestroyString((char *)arg1); |
| 1610 | if (arg2 != arg2n ) |
| 1611 | arg2=DestroyString((char *)arg2); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1612 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1613 | #undef _image_info |
| 1614 | #undef _exception |
| 1615 | #undef _draw_info |
| 1616 | #undef _quantize_info |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1617 | #undef IfSetOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1618 | #undef ArgBoolean |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 1619 | #undef ArgBooleanNot |
| 1620 | #undef ArgBooleanString |
| 1621 | #undef ArgOption |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1622 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1623 | return; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1624 | } |
| 1625 | |
| 1626 | /* |
| 1627 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1628 | % % |
| 1629 | % % |
| 1630 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1631 | + 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] | 1632 | % % |
| 1633 | % % |
| 1634 | % % |
| 1635 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1636 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1637 | % CLISimpleOperatorImages() applys one simple image operation given to all |
| 1638 | % the images in the CLI wand, using any per-image or global settings that was |
| 1639 | % previously saved in the CLI wand. |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1640 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1641 | % It is assumed that any such settings are up-to-date. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1642 | % |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 1643 | % The format of the WandSimpleOperatorImages method is: |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1644 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1645 | % void CLISimpleOperatorImages(MagickCLI *cli_wand, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1646 | % const char *option, const char *arg1, const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1647 | % |
| 1648 | % A description of each parameter follows: |
| 1649 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1650 | % o cli_wand: structure holding settings and images to be operated on |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1651 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1652 | % o option: The option string for the operation |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1653 | % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1654 | % o arg1, arg2: optional argument strings to the operation |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1655 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1656 | */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1657 | |
| 1658 | /* |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 1659 | CLISimpleOperatorImage() is an Internal subrountine to apply one simple |
| 1660 | image operation to the current image pointed to by the CLI wand. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1661 | |
| 1662 | The image in the list may be modified in three different ways... |
| 1663 | * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 1664 | * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 1665 | * one image replace by a list of images (-separate and -crop only!) |
| 1666 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1667 | In each case the result replaces the single original image in the list, as |
| 1668 | well as the pointer to the modified image (last image added if replaced by a |
| 1669 | list of images) is returned. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1670 | |
| 1671 | As the image pointed to may be replaced, the first image in the list may |
| 1672 | also change. GetFirstImageInList() should be used by caller if they wish |
| 1673 | return the Image pointer to the first image in list. |
| 1674 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 1675 | static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand, |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1676 | const char *option, const char *arg1n, const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1677 | { |
| 1678 | Image * |
| 1679 | new_image; |
| 1680 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1681 | GeometryInfo |
| 1682 | geometry_info; |
| 1683 | |
| 1684 | RectangleInfo |
| 1685 | geometry; |
| 1686 | |
| 1687 | MagickStatusType |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1688 | flags; |
| 1689 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1690 | ssize_t |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1691 | parse; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1692 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 1693 | const char /* percent escaped versions of the args */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1694 | *arg1, |
| 1695 | *arg2; |
| 1696 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 1697 | #define _image_info (cli_wand->wand.image_info) |
| 1698 | #define _image (cli_wand->wand.images) |
| 1699 | #define _exception (cli_wand->wand.exception) |
| 1700 | #define _draw_info (cli_wand->draw_info) |
| 1701 | #define _quantize_info (cli_wand->quantize_info) |
| 1702 | #define _process_flags (cli_wand->process_flags) |
| 1703 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
| 1704 | #define IfNormalOp (*option=='-') |
| 1705 | #define IfPlusOp (*option!='-') |
| 1706 | #define IsNormalOp IsMagickTrue(IfNormalOp) |
| 1707 | #define IsPlusOp IsMagickFalse(IfNormalOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1708 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1709 | assert(cli_wand != (MagickCLI *) NULL); |
| 1710 | assert(cli_wand->signature == WandSignature); |
| 1711 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1712 | assert(_image != (Image *) NULL); /* an image must be present */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1713 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1714 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 1715 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1716 | arg1 = arg1n, |
| 1717 | arg2 = arg2n; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 1718 | |
| 1719 | /* Interpret Percent Escapes in Arguments - using first image */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1720 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 1721 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 1722 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 1723 | /* Interpret Percent escapes in argument 1 */ |
| 1724 | if (arg1n != (char *) NULL) { |
| 1725 | arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); |
| 1726 | if (arg1 == (char *) NULL) { |
| 1727 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1728 | arg1=arg1n; /* use the given argument as is */ |
| 1729 | } |
| 1730 | } |
| 1731 | if (arg2n != (char *) NULL) { |
| 1732 | arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); |
| 1733 | if (arg2 == (char *) NULL) { |
| 1734 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 1735 | arg2=arg2n; /* use the given argument as is */ |
| 1736 | } |
| 1737 | } |
| 1738 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1739 | #undef _process_flags |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1740 | #undef _option_type |
| 1741 | |
| 1742 | #if 0 |
| 1743 | (void) FormatLocaleFile(stderr, |
| 1744 | "CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); |
| 1745 | #endif |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1746 | |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1747 | new_image = (Image *)NULL; /* the replacement image, if not null at end */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1748 | SetGeometryInfo(&geometry_info); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1749 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1750 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1751 | { |
| 1752 | case 'a': |
| 1753 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1754 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1755 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1756 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1757 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1758 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1759 | if ((flags & SigmaValue) == 0) |
| 1760 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1761 | new_image=AdaptiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1762 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1763 | break; |
| 1764 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1765 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1766 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 1767 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1768 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1769 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 1770 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 1771 | new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1772 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1773 | break; |
| 1774 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1775 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1776 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1777 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1778 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1779 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1780 | if ((flags & SigmaValue) == 0) |
| 1781 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1782 | new_image=AdaptiveSharpenImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1783 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1784 | break; |
| 1785 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1786 | if (LocaleCompare("alpha",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1787 | { |
cristy | 288a353 | 2012-08-28 00:19:44 +0000 | [diff] [blame] | 1788 | parse=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1789 | if (parse < 0) |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 1790 | CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelOption", |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1791 | option,arg1); |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 1792 | (void) SetImageAlphaChannel(_image,(AlphaChannelOption)parse, |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 1793 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1794 | break; |
| 1795 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1796 | if (LocaleCompare("annotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1797 | { |
| 1798 | char |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1799 | geometry[MaxTextExtent]; |
| 1800 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1801 | SetGeometryInfo(&geometry_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1802 | flags=ParseGeometry(arg1,&geometry_info); |
cristy | 8592b05 | 2013-02-07 01:24:54 +0000 | [diff] [blame] | 1803 | if (flags == 0) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1804 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1805 | if ((flags & SigmaValue) == 0) |
| 1806 | geometry_info.sigma=geometry_info.rho; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 1807 | (void) CloneString(&_draw_info->text,arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1808 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
| 1809 | geometry_info.xi,geometry_info.psi); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1810 | (void) CloneString(&_draw_info->geometry,geometry); |
| 1811 | _draw_info->affine.sx=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1812 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1813 | _draw_info->affine.rx=sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1814 | fmod(geometry_info.rho,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1815 | _draw_info->affine.ry=(-sin(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1816 | fmod(geometry_info.sigma,360.0)))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1817 | _draw_info->affine.sy=cos(DegreesToRadians( |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1818 | fmod(geometry_info.sigma,360.0))); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1819 | (void) AnnotateImage(_image,_draw_info,_exception); |
| 1820 | GetAffineMatrix(&_draw_info->affine); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1821 | break; |
| 1822 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1823 | if (LocaleCompare("auto-gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1824 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1825 | (void) AutoGammaImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1826 | break; |
| 1827 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1828 | if (LocaleCompare("auto-level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1829 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1830 | (void) AutoLevelImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1831 | break; |
| 1832 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1833 | if (LocaleCompare("auto-orient",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1834 | { |
cristy | fa5f6c7 | 2013-01-01 14:37:35 +0000 | [diff] [blame] | 1835 | new_image=AutoOrientImage(_image,_image->orientation,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1836 | break; |
| 1837 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1838 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1839 | } |
| 1840 | case 'b': |
| 1841 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1842 | if (LocaleCompare("black-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1843 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1844 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1845 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1846 | (void) BlackThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1847 | break; |
| 1848 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1849 | if (LocaleCompare("blue-shift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1850 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1851 | geometry_info.rho=1.5; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1852 | if (IfNormalOp) { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1853 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1854 | if ((flags & RhoValue) == 0) |
| 1855 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1856 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1857 | new_image=BlueShiftImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1858 | break; |
| 1859 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1860 | if (LocaleCompare("blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1861 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1862 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1863 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1864 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1865 | if ((flags & SigmaValue) == 0) |
| 1866 | geometry_info.sigma=1.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1867 | new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1868 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1869 | break; |
| 1870 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1871 | if (LocaleCompare("border",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1872 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1873 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1874 | compose; |
| 1875 | |
| 1876 | const char* |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1877 | value; |
| 1878 | |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1879 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1880 | if ((flags & (WidthValue | HeightValue)) == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1881 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1882 | compose=OverCompositeOp; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1883 | value=GetImageOption(_image_info,"compose"); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 1884 | if (value != (const char *) NULL) |
cristy | 64ad8f9 | 2012-08-03 00:58:24 +0000 | [diff] [blame] | 1885 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1886 | MagickFalse,value); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1887 | new_image=BorderImage(_image,&geometry,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1888 | break; |
| 1889 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1890 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1891 | { |
| 1892 | double |
| 1893 | brightness, |
| 1894 | contrast; |
| 1895 | |
| 1896 | GeometryInfo |
| 1897 | geometry_info; |
| 1898 | |
| 1899 | MagickStatusType |
| 1900 | flags; |
| 1901 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1902 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1903 | if ((flags & RhoValue) == 0) |
| 1904 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1905 | brightness=geometry_info.rho; |
| 1906 | contrast=0.0; |
| 1907 | if ((flags & SigmaValue) != 0) |
| 1908 | contrast=geometry_info.sigma; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1909 | (void) BrightnessContrastImage(_image,brightness,contrast, |
| 1910 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1911 | break; |
| 1912 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 1913 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1914 | } |
| 1915 | case 'c': |
| 1916 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1917 | if (LocaleCompare("cdl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1918 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1919 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1920 | char |
| 1921 | *color_correction_collection; |
| 1922 | |
| 1923 | /* |
| 1924 | Color correct with a color decision list. |
| 1925 | */ |
cristy | 3a5987c | 2013-11-07 14:18:46 +0000 | [diff] [blame] | 1926 | color_correction_collection=FileToString(arg1,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1927 | if (color_correction_collection == (char *) NULL) |
| 1928 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1929 | (void) ColorDecisionListImage(_image,color_correction_collection, |
| 1930 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1931 | break; |
| 1932 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1933 | if (LocaleCompare("charcoal",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1934 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1935 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 1936 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 1937 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1938 | if ((flags & SigmaValue) == 0) |
| 1939 | geometry_info.sigma=1.0; |
| 1940 | if ((flags & XiValue) == 0) |
| 1941 | geometry_info.xi=1.0; |
cristy | ee3f752 | 2012-12-21 19:27:44 +0000 | [diff] [blame] | 1942 | new_image=CharcoalImage(_image,geometry_info.rho,geometry_info.sigma, |
| 1943 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1944 | break; |
| 1945 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1946 | if (LocaleCompare("chop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1947 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1948 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1949 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1950 | (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); |
| 1951 | new_image=ChopImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1952 | break; |
| 1953 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1954 | if (LocaleCompare("clamp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1955 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1956 | (void) ClampImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1957 | break; |
| 1958 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1959 | if (LocaleCompare("clip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1960 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1961 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1962 | (void) ClipImage(_image,_exception); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 1963 | else /* "+mask" remove the write mask */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1964 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1965 | break; |
| 1966 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1967 | if (LocaleCompare("clip-mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1968 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1969 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1970 | CacheView |
| 1971 | *mask_view; |
| 1972 | |
| 1973 | Image |
| 1974 | *mask_image; |
| 1975 | |
| 1976 | register Quantum |
| 1977 | *restrict q; |
| 1978 | |
| 1979 | register ssize_t |
| 1980 | x; |
| 1981 | |
| 1982 | ssize_t |
| 1983 | y; |
| 1984 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1985 | if (IfPlusOp) { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 1986 | /* use "+clip-mask" Remove the write mask for -clip-path */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1987 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 1988 | break; |
| 1989 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 1990 | mask_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1991 | if (mask_image == (Image *) NULL) |
| 1992 | break; |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 1993 | if (IfMagickFalse(SetImageStorageClass(mask_image,DirectClass,_exception))) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 1994 | break; |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 1995 | /* Create a write mask from cli_wand mask image */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1996 | /* FUTURE: use Alpha operations instead and create a Grey Image */ |
cristy | 46ff267 | 2012-12-14 15:32:26 +0000 | [diff] [blame] | 1997 | mask_view=AcquireAuthenticCacheView(mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 1998 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1999 | { |
| 2000 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2001 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2002 | if (q == (Quantum *) NULL) |
| 2003 | break; |
| 2004 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 2005 | { |
cristy | dc2d327 | 2013-02-12 14:00:44 +0000 | [diff] [blame] | 2006 | if (mask_image->alpha_trait != BlendPixelTrait) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2007 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
cristy | 81ac797 | 2013-03-31 19:25:23 +0000 | [diff] [blame] | 2008 | SetPixelGray(mask_image,GetPixelAlpha(mask_image,q),q); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2009 | q+=GetPixelChannels(mask_image); |
| 2010 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2011 | if (IfMagickFalse(SyncCacheViewAuthenticPixels(mask_view,_exception))) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2012 | break; |
| 2013 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2014 | /* clean up and set the write mask */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2015 | mask_view=DestroyCacheView(mask_view); |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 2016 | mask_image->alpha_trait=BlendPixelTrait; |
cristy | 81ac797 | 2013-03-31 19:25:23 +0000 | [diff] [blame] | 2017 | (void) SetImageColorspace(_image,GRAYColorspace,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2018 | (void) SetImageMask(_image,mask_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2019 | mask_image=DestroyImage(mask_image); |
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("clip-path",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2023 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2024 | (void) ClipImagePath(_image,arg1,IsNormalOp,_exception); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2025 | /* Note: Use "+clip-mask" remove the write mask added */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2026 | break; |
| 2027 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2028 | if (LocaleCompare("colorize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2029 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2030 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2031 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2032 | new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2033 | break; |
| 2034 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2035 | if (LocaleCompare("color-matrix",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2036 | { |
| 2037 | KernelInfo |
| 2038 | *kernel; |
| 2039 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2040 | kernel=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2041 | if (kernel == (KernelInfo *) NULL) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2042 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2043 | new_image=ColorMatrixImage(_image,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2044 | kernel=DestroyKernelInfo(kernel); |
| 2045 | break; |
| 2046 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2047 | if (LocaleCompare("colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2048 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2049 | /* Reduce the number of colors in the image. |
| 2050 | FUTURE: also provide 'plus version with image 'color counts' |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2051 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2052 | _quantize_info->number_colors=StringToUnsignedLong(arg1); |
| 2053 | if (_quantize_info->number_colors == 0) |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2054 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2055 | if ((_image->storage_class == DirectClass) || |
| 2056 | _image->colors > _quantize_info->number_colors) |
| 2057 | (void) QuantizeImage(_quantize_info,_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2058 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2059 | (void) CompressImageColormap(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2060 | break; |
| 2061 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2062 | if (LocaleCompare("colorspace",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2063 | { |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2064 | /* WARNING: this is both a image_info setting (already done) |
| 2065 | and a operator to change image colorspace. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2066 | |
| 2067 | FUTURE: default colorspace should be sRGB! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2068 | Unless some type of 'linear colorspace' mode is set. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2069 | |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2070 | Note that +colorspace sets "undefined" or no effect on |
| 2071 | new images, but forces images already in memory back to RGB! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2072 | That seems to be a little strange! |
anthony | d2cdc86 | 2011-10-07 14:07:17 +0000 | [diff] [blame] | 2073 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2074 | (void) TransformImageColorspace(_image, |
cristy | e0b9b8f | 2013-03-28 12:39:39 +0000 | [diff] [blame] | 2075 | IfNormalOp ? _image_info->colorspace : sRGBColorspace, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2076 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2077 | break; |
| 2078 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2079 | if (LocaleCompare("contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2080 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2081 | CLIWandWarnReplaced(IfNormalOp?"-level":"+level"); |
| 2082 | (void) ContrastImage(_image,IsNormalOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2083 | break; |
| 2084 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2085 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2086 | { |
| 2087 | double |
| 2088 | black_point, |
| 2089 | white_point; |
| 2090 | |
| 2091 | MagickStatusType |
| 2092 | flags; |
| 2093 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2094 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2095 | if ((flags & RhoValue) == 0) |
| 2096 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2097 | black_point=geometry_info.rho; |
| 2098 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 2099 | black_point; |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2100 | if ((flags & PercentValue) != 0) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2101 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2102 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2103 | } |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2104 | white_point=(double) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2105 | white_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2106 | (void) ContrastStretchImage(_image,black_point,white_point, |
| 2107 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2108 | break; |
| 2109 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2110 | if (LocaleCompare("convolve",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2111 | { |
| 2112 | KernelInfo |
| 2113 | *kernel_info; |
| 2114 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2115 | kernel_info=AcquireKernelInfo(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2116 | if (kernel_info == (KernelInfo *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2117 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | a12d8ba | 2012-04-29 16:33:41 +0000 | [diff] [blame] | 2118 | new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info, |
| 2119 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2120 | kernel_info=DestroyKernelInfo(kernel_info); |
| 2121 | break; |
| 2122 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2123 | if (LocaleCompare("crop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2124 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2125 | /* WARNING: This can generate multiple images! */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2126 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2127 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2128 | new_image=CropImageToTiles(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2129 | break; |
| 2130 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2131 | if (LocaleCompare("cycle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2132 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2133 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2134 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2135 | (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1), |
| 2136 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2137 | break; |
| 2138 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2139 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2140 | } |
| 2141 | case 'd': |
| 2142 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2143 | if (LocaleCompare("decipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2144 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2145 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2146 | StringInfo |
| 2147 | *passkey; |
| 2148 | |
cristy | 3a5987c | 2013-11-07 14:18:46 +0000 | [diff] [blame] | 2149 | passkey=FileToStringInfo(arg1,~0UL,_exception); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2150 | if (passkey == (StringInfo *) NULL) |
| 2151 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 2152 | |
| 2153 | (void) PasskeyDecipherImage(_image,passkey,_exception); |
| 2154 | passkey=DestroyStringInfo(passkey); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2155 | break; |
| 2156 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2157 | if (LocaleCompare("depth",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2158 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2159 | /* The _image_info->depth setting has already been set |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2160 | We just need to apply it to all images in current sequence |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2161 | |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2162 | WARNING: Depth from 8 to 16 causes 'quantum rounding to images! |
| 2163 | That is it really is an operation, not a setting! Arrgghhh |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2164 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2165 | FUTURE: this should not be an operator!!! |
anthony | dcf510d | 2011-10-30 13:51:40 +0000 | [diff] [blame] | 2166 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2167 | (void) SetImageDepth(_image,_image_info->depth,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2168 | break; |
| 2169 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2170 | if (LocaleCompare("deskew",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2171 | { |
| 2172 | double |
| 2173 | threshold; |
| 2174 | |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2175 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2176 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2177 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2178 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2179 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2180 | else |
| 2181 | threshold=40.0*QuantumRange/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2182 | new_image=DeskewImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2183 | break; |
| 2184 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2185 | if (LocaleCompare("despeckle",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2186 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2187 | new_image=DespeckleImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2188 | break; |
| 2189 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2190 | if (LocaleCompare("distort",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2191 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2192 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2193 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2194 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2195 | ssize_t |
| 2196 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2197 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2198 | parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1); |
| 2199 | if ( parse < 0 ) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2200 | CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod", |
| 2201 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2202 | if ((DistortImageMethod) parse == ResizeDistortion) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2203 | { |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2204 | double |
| 2205 | resize_args[2]; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2206 | /* Special Case - Argument is actually a resize geometry! |
| 2207 | ** Convert that to an appropriate distortion argument array. |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2208 | ** FUTURE: make a separate special resize operator |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2209 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2210 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2211 | CLIWandExceptArgBreak(OptionError,"InvalidGeometry", |
| 2212 | option,arg2); |
| 2213 | (void) ParseRegionGeometry(_image,arg2,&geometry,_exception); |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 2214 | resize_args[0]=(double) geometry.width; |
| 2215 | resize_args[1]=(double) geometry.height; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2216 | new_image=DistortImage(_image,(DistortImageMethod) parse, |
| 2217 | (size_t)2,resize_args,MagickTrue,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2218 | break; |
| 2219 | } |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2220 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2221 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2222 | if (args == (double *)NULL ) |
| 2223 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2224 | |
| 2225 | new_image=DistortImage(_image,(DistortImageMethod) parse,count,args, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2226 | IsPlusOp,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2227 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2228 | break; |
| 2229 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2230 | if (LocaleCompare("draw",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2231 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2232 | (void) CloneString(&_draw_info->primitive,arg1); |
| 2233 | (void) DrawImage(_image,_draw_info,_exception); |
| 2234 | (void) CloneString(&_draw_info->primitive,(char *)NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2235 | break; |
| 2236 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2237 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2238 | } |
| 2239 | case 'e': |
| 2240 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2241 | if (LocaleCompare("edge",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2242 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2243 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2244 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2245 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | 9dc4c51 | 2013-03-24 01:38:00 +0000 | [diff] [blame] | 2246 | new_image=EdgeImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2247 | break; |
| 2248 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2249 | if (LocaleCompare("emboss",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2250 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2251 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2252 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2253 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2254 | if ((flags & SigmaValue) == 0) |
| 2255 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2256 | new_image=EmbossImage(_image,geometry_info.rho, |
| 2257 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2258 | break; |
| 2259 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2260 | if (LocaleCompare("encipher",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2261 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2262 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2263 | StringInfo |
| 2264 | *passkey; |
| 2265 | |
cristy | 3a5987c | 2013-11-07 14:18:46 +0000 | [diff] [blame] | 2266 | passkey=FileToStringInfo(arg1,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2267 | if (passkey != (StringInfo *) NULL) |
| 2268 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2269 | (void) PasskeyEncipherImage(_image,passkey,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2270 | passkey=DestroyStringInfo(passkey); |
| 2271 | } |
| 2272 | break; |
| 2273 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2274 | if (LocaleCompare("enhance",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2275 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2276 | new_image=EnhanceImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2277 | break; |
| 2278 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2279 | if (LocaleCompare("equalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2280 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2281 | (void) EqualizeImage(_image,_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("evaluate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2285 | { |
| 2286 | double |
| 2287 | constant; |
| 2288 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2289 | parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 2290 | if ( parse < 0 ) |
| 2291 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 2292 | option,arg1); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2293 | if (IfMagickFalse(IsGeometry(arg2))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2294 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2295 | constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2296 | (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant, |
| 2297 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2298 | break; |
| 2299 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2300 | if (LocaleCompare("extent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2301 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2302 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2303 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2304 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2305 | if (geometry.width == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2306 | geometry.width=_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2307 | if (geometry.height == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2308 | geometry.height=_image->rows; |
| 2309 | new_image=ExtentImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2310 | break; |
| 2311 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2312 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2313 | } |
| 2314 | case 'f': |
| 2315 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2316 | if (LocaleCompare("flip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2317 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2318 | new_image=FlipImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2319 | break; |
| 2320 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2321 | if (LocaleCompare("flop",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2322 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2323 | new_image=FlopImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2324 | break; |
| 2325 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2326 | if (LocaleCompare("floodfill",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2327 | { |
| 2328 | PixelInfo |
| 2329 | target; |
| 2330 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2331 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2332 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2333 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 2334 | (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception); |
| 2335 | (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2336 | geometry.y,IsPlusOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2337 | break; |
| 2338 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2339 | if (LocaleCompare("frame",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2340 | { |
| 2341 | FrameInfo |
| 2342 | frame_info; |
| 2343 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2344 | CompositeOperator |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2345 | compose; |
| 2346 | |
| 2347 | const char* |
| 2348 | value; |
| 2349 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2350 | value=GetImageOption(_image_info,"compose"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2351 | compose=OverCompositeOp; /* use Over not _image->compose */ |
cristy | 4b89261 | 2012-08-03 19:31:31 +0000 | [diff] [blame] | 2352 | if (value != (const char *) NULL) |
| 2353 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 2354 | MagickFalse,value); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2355 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2356 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2357 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2358 | frame_info.width=geometry.width; |
| 2359 | frame_info.height=geometry.height; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2360 | frame_info.outer_bevel=geometry.x; |
| 2361 | frame_info.inner_bevel=geometry.y; |
| 2362 | frame_info.x=(ssize_t) frame_info.width; |
| 2363 | frame_info.y=(ssize_t) frame_info.height; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2364 | frame_info.width=_image->columns+2*frame_info.width; |
| 2365 | frame_info.height=_image->rows+2*frame_info.height; |
| 2366 | new_image=FrameImage(_image,&frame_info,compose,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2367 | break; |
| 2368 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2369 | if (LocaleCompare("function",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2370 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2371 | double |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2372 | *args; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2373 | |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2374 | ssize_t |
| 2375 | count; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2376 | |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 2377 | parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1); |
| 2378 | if ( parse < 0 ) |
| 2379 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2380 | option,arg1); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2381 | /* convert argument string into an array of doubles */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2382 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 2383 | if (args == (double *)NULL ) |
| 2384 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 2385 | |
| 2386 | (void) FunctionImage(_image,(MagickFunction)parse,count,args, |
| 2387 | _exception); |
| 2388 | args=(double *) RelinquishMagickMemory(args); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2389 | break; |
| 2390 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2391 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2392 | } |
| 2393 | case 'g': |
| 2394 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2395 | if (LocaleCompare("gamma",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2396 | { |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2397 | double |
| 2398 | constant; |
| 2399 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2400 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2401 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2402 | constant=StringToDouble(arg1,(char **) NULL); |
| 2403 | #if 0 |
| 2404 | /* Using Gamma, via a cache */ |
| 2405 | if (IfPlusOp) |
cristy | 3e3ec3a | 2012-11-03 23:11:06 +0000 | [diff] [blame] | 2406 | constant=PerceptibleReciprocal(constant); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2407 | (void) GammaImage(_image,constant,_exception); |
| 2408 | #else |
| 2409 | /* Using Evaluate POW, direct update of values - more accurite */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2410 | if (IfNormalOp) |
cristy | 3e3ec3a | 2012-11-03 23:11:06 +0000 | [diff] [blame] | 2411 | constant=PerceptibleReciprocal(constant); |
anthony | 7a4d610 | 2012-07-01 09:48:25 +0000 | [diff] [blame] | 2412 | (void) EvaluateImage(_image,PowEvaluateOperator,constant,_exception); |
| 2413 | #endif |
| 2414 | /* Set gamma setting -- Old meaning of "+gamma" |
| 2415 | * _image->gamma=StringToDouble(arg1,(char **) NULL); |
| 2416 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2417 | break; |
| 2418 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2419 | if (LocaleCompare("gaussian-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2420 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2421 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2422 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2423 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2424 | if ((flags & SigmaValue) == 0) |
| 2425 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2426 | new_image=GaussianBlurImage(_image,geometry_info.rho, |
| 2427 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2428 | break; |
| 2429 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2430 | if (LocaleCompare("gaussian",option+1) == 0) |
| 2431 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2432 | CLIWandWarnReplaced("-gaussian-blur"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2433 | CLISimpleOperatorImage(cli_wand,"-gaussian-blur",arg1,NULL); |
| 2434 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2435 | if (LocaleCompare("geometry",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2436 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2437 | /* |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2438 | Record Image offset for composition. (A Setting) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2439 | Resize last _image. (ListOperator) -- DEPRECIATE |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2440 | FUTURE: Why if no 'offset' does this resize ALL images? |
| 2441 | Also why is the setting recorded in the IMAGE non-sense! |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2442 | */ |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2443 | if (IfPlusOp) |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2444 | { /* remove the previous composition geometry offset! */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2445 | if (_image->geometry != (char *) NULL) |
| 2446 | _image->geometry=DestroyString(_image->geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2447 | break; |
| 2448 | } |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2449 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2450 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2451 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2452 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2453 | (void) CloneString(&_image->geometry,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2454 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2455 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2456 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2457 | break; |
| 2458 | } |
cristy | ab94359 | 2013-03-29 16:47:23 +0000 | [diff] [blame] | 2459 | if (LocaleCompare("grayscale",option+1) == 0) |
cristy | e0b9b8f | 2013-03-28 12:39:39 +0000 | [diff] [blame] | 2460 | { |
cristy | ab94359 | 2013-03-29 16:47:23 +0000 | [diff] [blame] | 2461 | parse=ParseCommandOption(MagickPixelIntensityOptions, |
cristy | e0b9b8f | 2013-03-28 12:39:39 +0000 | [diff] [blame] | 2462 | MagickFalse,arg1); |
cristy | ab94359 | 2013-03-29 16:47:23 +0000 | [diff] [blame] | 2463 | if (parse < 0) |
| 2464 | CLIWandExceptArgBreak(OptionError,"UnrecognizedIntensityMethod", |
| 2465 | option,arg1); |
| 2466 | (void) GrayscaleImage(_image,(PixelIntensityMethod) parse,_exception); |
cristy | e0b9b8f | 2013-03-28 12:39:39 +0000 | [diff] [blame] | 2467 | break; |
| 2468 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2469 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2470 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2471 | case 'i': |
| 2472 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2473 | if (LocaleCompare("identify",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2474 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2475 | const char |
| 2476 | *format, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2477 | *text; |
| 2478 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2479 | format=GetImageOption(_image_info,"format"); |
cristy | f9b9b66 | 2013-05-25 12:50:16 +0000 | [diff] [blame] | 2480 | if (format == (char *) NULL) |
| 2481 | { |
| 2482 | (void) IdentifyImage(_image,stdout,_image_info->verbose, |
| 2483 | _exception); |
| 2484 | break; |
| 2485 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2486 | text=InterpretImageProperties(_image_info,_image,format,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2487 | if (text == (char *) NULL) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 2488 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
cristy | f9b9b66 | 2013-05-25 12:50:16 +0000 | [diff] [blame] | 2489 | option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2490 | (void) fputs(text,stdout); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2491 | text=DestroyString((char *)text); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2492 | break; |
| 2493 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2494 | if (LocaleCompare("implode",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2495 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2496 | flags=ParseGeometry(arg1,&geometry_info); |
| 2497 | if ((flags & RhoValue) == 0) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2498 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 2499 | new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate, |
| 2500 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2501 | break; |
| 2502 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2503 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2504 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2505 | /* FUTURE: New to IMv7 |
| 2506 | Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2507 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2508 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2509 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 2510 | new_image=InterpolativeResizeImage(_image,geometry.width, |
| 2511 | geometry.height,_image->interpolate,_exception); |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2512 | break; |
| 2513 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2514 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2515 | } |
| 2516 | case 'l': |
| 2517 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2518 | if (LocaleCompare("lat",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2519 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2520 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2521 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2522 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | b5c691e | 2012-09-14 17:12:40 +0000 | [diff] [blame] | 2523 | if ((flags & SigmaValue) == 0) |
| 2524 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2525 | if ((flags & PercentValue) != 0) |
| 2526 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2527 | new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2528 | (size_t) geometry_info.sigma,(double) geometry_info.xi, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2529 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2530 | break; |
| 2531 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2532 | if (LocaleCompare("level",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2533 | { |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2534 | double |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2535 | black_point, |
| 2536 | gamma, |
| 2537 | white_point; |
| 2538 | |
| 2539 | MagickStatusType |
| 2540 | flags; |
| 2541 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2542 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2543 | if ((flags & RhoValue) == 0) |
| 2544 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2545 | black_point=geometry_info.rho; |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2546 | white_point=(double) QuantumRange; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2547 | if ((flags & SigmaValue) != 0) |
| 2548 | white_point=geometry_info.sigma; |
| 2549 | gamma=1.0; |
| 2550 | if ((flags & XiValue) != 0) |
| 2551 | gamma=geometry_info.xi; |
| 2552 | if ((flags & PercentValue) != 0) |
| 2553 | { |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2554 | black_point*=(double) (QuantumRange/100.0); |
| 2555 | white_point*=(double) (QuantumRange/100.0); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2556 | } |
| 2557 | if ((flags & SigmaValue) == 0) |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2558 | white_point=(double) QuantumRange-black_point; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2559 | if (IfPlusOp || ((flags & AspectValue) != 0)) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2560 | (void) LevelizeImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2561 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2562 | (void) LevelImage(_image,black_point,white_point,gamma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2563 | break; |
| 2564 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2565 | if (LocaleCompare("level-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2566 | { |
| 2567 | char |
| 2568 | token[MaxTextExtent]; |
| 2569 | |
| 2570 | const char |
| 2571 | *p; |
| 2572 | |
| 2573 | PixelInfo |
| 2574 | black_point, |
| 2575 | white_point; |
| 2576 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2577 | p=(const char *) arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2578 | GetMagickToken(p,&p,token); /* get black point color */ |
| 2579 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2580 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2581 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2582 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2583 | (void) QueryColorCompliance("#000000",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2584 | &black_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2585 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2586 | GetMagickToken(p,&p,token); |
| 2587 | if (*token == '\0') |
| 2588 | white_point=black_point; /* set everything to that color */ |
| 2589 | else |
| 2590 | { |
| 2591 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 2592 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 2593 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2594 | (void) QueryColorCompliance(token,AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2595 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2596 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2597 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2598 | &white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2599 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2600 | (void) LevelImageColors(_image,&black_point,&white_point, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2601 | IsPlusOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2602 | break; |
| 2603 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2604 | if (LocaleCompare("linear-stretch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2605 | { |
| 2606 | double |
| 2607 | black_point, |
| 2608 | white_point; |
| 2609 | |
| 2610 | MagickStatusType |
| 2611 | flags; |
| 2612 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2613 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2614 | if ((flags & RhoValue) == 0) |
| 2615 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2616 | black_point=geometry_info.rho; |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2617 | white_point=(double) _image->columns*_image->rows; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2618 | if ((flags & SigmaValue) != 0) |
| 2619 | white_point=geometry_info.sigma; |
| 2620 | if ((flags & PercentValue) != 0) |
| 2621 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2622 | black_point*=(double) _image->columns*_image->rows/100.0; |
| 2623 | white_point*=(double) _image->columns*_image->rows/100.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2624 | } |
| 2625 | if ((flags & SigmaValue) == 0) |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 2626 | white_point=(double) _image->columns*_image->rows- |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2627 | black_point; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2628 | (void) LinearStretchImage(_image,black_point,white_point,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2629 | break; |
| 2630 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2631 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2632 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2633 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2634 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 2635 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2636 | flags=ParseRegionGeometry(_image,arg1,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2637 | if ((flags & XValue) == 0) |
| 2638 | geometry.x=1; |
| 2639 | if ((flags & YValue) == 0) |
| 2640 | geometry.y=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2641 | new_image=LiquidRescaleImage(_image,geometry.width, |
| 2642 | geometry.height,1.0*geometry.x,1.0*geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2643 | break; |
| 2644 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2645 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2646 | } |
| 2647 | case 'm': |
| 2648 | { |
cristy | 7220ee4 | 2013-04-14 01:30:34 +0000 | [diff] [blame] | 2649 | if (LocaleCompare("magnify",option+1) == 0) |
| 2650 | { |
| 2651 | new_image=MagnifyImage(_image,_exception); |
| 2652 | break; |
| 2653 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2654 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2655 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2656 | CLIWandWarnReplaced("-remap"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2657 | CLISimpleOperatorImage(cli_wand,"-remap",NULL,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2658 | break; |
| 2659 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2660 | if (LocaleCompare("mask",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2661 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2662 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2663 | Image |
| 2664 | *mask; |
| 2665 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2666 | if (IfPlusOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 2667 | { /* Remove a mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2668 | (void) SetImageMask(_image,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2669 | break; |
| 2670 | } |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 2671 | /* Set the image mask. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2672 | mask=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2673 | if (mask == (Image *) NULL) |
| 2674 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2675 | (void) SetImageMask(_image,mask,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2676 | mask=DestroyImage(mask); |
| 2677 | break; |
| 2678 | } |
cristy | 52ad9e9 | 2013-02-08 23:23:29 +0000 | [diff] [blame] | 2679 | if (LocaleCompare("matte",option+1) == 0) |
| 2680 | { |
| 2681 | CLIWandWarnReplaced(IfNormalOp?"-alpha Set":"-alpha Off"); |
| 2682 | (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : |
| 2683 | DeactivateAlphaChannel, _exception); |
| 2684 | break; |
| 2685 | } |
| 2686 | if (LocaleCompare("median",option+1) == 0) |
| 2687 | { |
| 2688 | CLIWandWarnReplaced("-statistic Median"); |
| 2689 | CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); |
| 2690 | break; |
| 2691 | } |
| 2692 | if (LocaleCompare("mode",option+1) == 0) |
| 2693 | { |
| 2694 | /* FUTURE: note this is also a special "montage" option */ |
| 2695 | CLIWandWarnReplaced("-statistic Mode"); |
| 2696 | CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1); |
| 2697 | break; |
| 2698 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2699 | if (LocaleCompare("modulate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2700 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2701 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2702 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2703 | (void) ModulateImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2704 | break; |
| 2705 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2706 | if (LocaleCompare("monitor",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2707 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2708 | (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress : |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2709 | (MagickProgressMonitor) NULL,(void *) NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2710 | break; |
| 2711 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2712 | if (LocaleCompare("monochrome",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2713 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2714 | (void) SetImageType(_image,BilevelType,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2715 | break; |
| 2716 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2717 | if (LocaleCompare("morphology",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2718 | { |
| 2719 | char |
| 2720 | token[MaxTextExtent]; |
| 2721 | |
| 2722 | const char |
| 2723 | *p; |
| 2724 | |
| 2725 | KernelInfo |
| 2726 | *kernel; |
| 2727 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2728 | ssize_t |
| 2729 | iterations; |
| 2730 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2731 | p=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2732 | GetMagickToken(p,&p,token); |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2733 | parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
| 2734 | if ( parse < 0 ) |
| 2735 | CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", |
| 2736 | option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2737 | iterations=1L; |
| 2738 | GetMagickToken(p,&p,token); |
| 2739 | if ((*p == ':') || (*p == ',')) |
| 2740 | GetMagickToken(p,&p,token); |
| 2741 | if ((*p != '\0')) |
| 2742 | iterations=(ssize_t) StringToLong(p); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2743 | kernel=AcquireKernelInfo(arg2); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2744 | if (kernel == (KernelInfo *) NULL) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2745 | CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel", |
| 2746 | option,arg2); |
| 2747 | new_image=MorphologyImage(_image,(MorphologyMethod)parse, |
| 2748 | iterations,kernel,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2749 | kernel=DestroyKernelInfo(kernel); |
| 2750 | break; |
| 2751 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2752 | if (LocaleCompare("motion-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2753 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2754 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2755 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2756 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2757 | if ((flags & SigmaValue) == 0) |
| 2758 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2759 | new_image=MotionBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2760 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2761 | break; |
| 2762 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2763 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2764 | } |
| 2765 | case 'n': |
| 2766 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2767 | if (LocaleCompare("negate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2768 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2769 | (void) NegateImage(_image, IsPlusOp, _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2770 | break; |
| 2771 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2772 | if (LocaleCompare("noise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2773 | { |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2774 | double |
| 2775 | attenuate; |
| 2776 | |
| 2777 | const char* |
| 2778 | value; |
| 2779 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2780 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2781 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2782 | CLIWandWarnReplaced("-statistic NonPeak"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2783 | CLISimpleOperatorImage(cli_wand,"-statistic","NonPeak",arg1); |
| 2784 | break; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2785 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2786 | parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1); |
| 2787 | if ( parse < 0 ) |
| 2788 | CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType", |
| 2789 | option,arg1); |
| 2790 | attenuate=1.0; |
| 2791 | value=GetImageOption(_image_info,"attenuate"); |
| 2792 | if (value != (const char *) NULL) |
| 2793 | attenuate=StringToDouble(value,(char **) NULL); |
| 2794 | new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate, |
| 2795 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2796 | break; |
| 2797 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2798 | if (LocaleCompare("normalize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2799 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2800 | (void) NormalizeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2801 | break; |
| 2802 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2803 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2804 | } |
| 2805 | case 'o': |
| 2806 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2807 | if (LocaleCompare("opaque",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2808 | { |
| 2809 | PixelInfo |
| 2810 | target; |
| 2811 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2812 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2813 | (void) OpaquePaintImage(_image,&target,&_draw_info->fill,IsPlusOp, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2814 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2815 | break; |
| 2816 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2817 | if (LocaleCompare("ordered-dither",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2818 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2819 | (void) OrderedPosterizeImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2820 | break; |
| 2821 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2822 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2823 | } |
| 2824 | case 'p': |
| 2825 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2826 | if (LocaleCompare("paint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2827 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2828 | flags=ParseGeometry(arg1,&geometry_info); |
| 2829 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 2830 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2831 | new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma, |
| 2832 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2833 | break; |
| 2834 | } |
cristy | 7884a93 | 2012-11-04 14:33:51 +0000 | [diff] [blame] | 2835 | if (LocaleCompare("perceptible",option+1) == 0) |
| 2836 | { |
| 2837 | (void) PerceptibleImage(_image,StringToDouble(arg1,(char **) NULL), |
| 2838 | _exception); |
| 2839 | break; |
| 2840 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2841 | if (LocaleCompare("polaroid",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2842 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2843 | const char |
| 2844 | *caption; |
| 2845 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2846 | double |
| 2847 | angle; |
| 2848 | |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2849 | if (IfPlusOp) { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2850 | RandomInfo |
| 2851 | *random_info; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2852 | |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2853 | random_info=AcquireRandomInfo(); |
| 2854 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2855 | random_info=DestroyRandomInfo(random_info); |
| 2856 | } |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2857 | else { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2858 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2859 | if ((flags & RhoValue) == 0) |
| 2860 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2861 | angle=geometry_info.rho; |
| 2862 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2863 | caption=GetImageProperty(_image,"caption",_exception); |
| 2864 | new_image=PolaroidImage(_image,_draw_info,caption,angle, |
| 2865 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2866 | break; |
| 2867 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2868 | if (LocaleCompare("posterize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2869 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2870 | flags=ParseGeometry(arg1,&geometry_info); |
| 2871 | if ((flags & RhoValue) == 0) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2872 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2873 | (void) PosterizeImage(_image,(size_t) geometry_info.rho, |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 2874 | _quantize_info->dither_method,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2875 | break; |
| 2876 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2877 | if (LocaleCompare("preview",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +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() |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2881 | Why??? |
cristy | 947cb4c | 2011-10-20 18:41:46 +0000 | [diff] [blame] | 2882 | */ |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 2883 | parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1); |
| 2884 | if ( parse < 0 ) |
| 2885 | CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType", |
| 2886 | option,arg1); |
| 2887 | new_image=PreviewImage(_image,(PreviewType)parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2888 | break; |
| 2889 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2890 | if (LocaleCompare("profile",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2891 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2892 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2893 | const char |
| 2894 | *name; |
| 2895 | |
| 2896 | const StringInfo |
| 2897 | *profile; |
| 2898 | |
| 2899 | Image |
| 2900 | *profile_image; |
| 2901 | |
| 2902 | ImageInfo |
| 2903 | *profile_info; |
| 2904 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2905 | if (IfPlusOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2906 | { /* Remove a profile from the _image. */ |
| 2907 | (void) ProfileImage(_image,arg1,(const unsigned char *) |
| 2908 | NULL,0,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2909 | break; |
| 2910 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2911 | /* Associate a profile with the _image. */ |
| 2912 | profile_info=CloneImageInfo(_image_info); |
| 2913 | profile=GetImageProfile(_image,"iptc"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2914 | if (profile != (StringInfo *) NULL) |
| 2915 | profile_info->profile=(void *) CloneStringInfo(profile); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2916 | profile_image=GetImageCache(profile_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2917 | profile_info=DestroyImageInfo(profile_info); |
| 2918 | if (profile_image == (Image *) NULL) |
| 2919 | { |
| 2920 | StringInfo |
| 2921 | *profile; |
| 2922 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2923 | profile_info=CloneImageInfo(_image_info); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2924 | (void) CopyMagickString(profile_info->filename,arg1, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2925 | MaxTextExtent); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2926 | profile=FileToStringInfo(profile_info->filename,~0UL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2927 | if (profile != (StringInfo *) NULL) |
| 2928 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2929 | (void) ProfileImage(_image,profile_info->magick, |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2930 | GetStringInfoDatum(profile),(size_t) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2931 | GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2932 | profile=DestroyStringInfo(profile); |
| 2933 | } |
| 2934 | profile_info=DestroyImageInfo(profile_info); |
| 2935 | break; |
| 2936 | } |
| 2937 | ResetImageProfileIterator(profile_image); |
| 2938 | name=GetNextImageProfile(profile_image); |
| 2939 | while (name != (const char *) NULL) |
| 2940 | { |
| 2941 | profile=GetImageProfile(profile_image,name); |
| 2942 | if (profile != (StringInfo *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2943 | (void) ProfileImage(_image,name,GetStringInfoDatum(profile), |
| 2944 | (size_t) GetStringInfoLength(profile),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2945 | name=GetNextImageProfile(profile_image); |
| 2946 | } |
| 2947 | profile_image=DestroyImage(profile_image); |
| 2948 | break; |
| 2949 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 2950 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2951 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2952 | case 'r': |
| 2953 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2954 | if (LocaleCompare("radial-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2955 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2956 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 2957 | if ((flags & RhoValue) == 0) |
| 2958 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2959 | new_image=RadialBlurImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2960 | break; |
| 2961 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2962 | if (LocaleCompare("raise",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2963 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2964 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2965 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2966 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2967 | (void) RaiseImage(_image,&geometry,IsNormalOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2968 | break; |
| 2969 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2970 | if (LocaleCompare("random-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2971 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2972 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 2973 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2974 | (void) RandomThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2975 | break; |
| 2976 | } |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2977 | if (LocaleCompare("recolor",option+1) == 0) |
| 2978 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 2979 | CLIWandWarnReplaced("-color-matrix"); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 2980 | CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL); |
| 2981 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2982 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2983 | { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 2984 | /* Note: arguments do not have percent escapes expanded */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2985 | Image |
| 2986 | *remap_image; |
| 2987 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2988 | remap_image=GetImageCache(_image_info,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2989 | if (remap_image == (Image *) NULL) |
| 2990 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 2991 | (void) RemapImage(_quantize_info,_image,remap_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2992 | remap_image=DestroyImage(remap_image); |
| 2993 | break; |
| 2994 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2995 | if (LocaleCompare("repage",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 2996 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 2997 | if (IfNormalOp) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 2998 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 2999 | if (IfMagickFalse(IsGeometry(arg1))) |
cristy | 0d0de74 | 2012-03-25 19:32:48 +0000 | [diff] [blame] | 3000 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3001 | arg1); |
| 3002 | (void) ResetImagePage(_image,arg1); |
| 3003 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3004 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3005 | (void) ParseAbsoluteGeometry("0x0+0+0",&_image->page); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3006 | break; |
| 3007 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3008 | if (LocaleCompare("resample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3009 | { |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 3010 | /* FUTURE: Roll into a resize special operation */ |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3011 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3012 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3013 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3014 | if ((flags & SigmaValue) == 0) |
| 3015 | geometry_info.sigma=geometry_info.rho; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3016 | new_image=ResampleImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3017 | geometry_info.sigma,_image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3018 | break; |
| 3019 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3020 | if (LocaleCompare("resize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3021 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3022 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3023 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3024 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3025 | new_image=ResizeImage(_image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3026 | _image->filter,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3027 | break; |
| 3028 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3029 | if (LocaleCompare("roll",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3030 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3031 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3032 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3033 | (void) ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3034 | new_image=RollImage(_image,geometry.x,geometry.y,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3035 | break; |
| 3036 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3037 | if (LocaleCompare("rotate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3038 | { |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3039 | flags=ParseGeometry(arg1,&geometry_info); |
| 3040 | if ((flags & RhoValue) == 0) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3041 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | ad255a0 | 2012-04-19 15:02:01 +0000 | [diff] [blame] | 3042 | if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows)) |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3043 | break; |
| 3044 | if ((flags & LessValue) != 0 && (_image->columns >= _image->rows)) |
| 3045 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3046 | new_image=RotateImage(_image,geometry_info.rho,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3047 | break; |
| 3048 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3049 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3050 | } |
| 3051 | case 's': |
| 3052 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3053 | if (LocaleCompare("sample",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3054 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3055 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3056 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3057 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3058 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3059 | new_image=SampleImage(_image,geometry.width,geometry.height, |
| 3060 | _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("scale",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3064 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3065 | /* FUTURE: Roll into a resize special operator */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3066 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3067 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3068 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3069 | new_image=ScaleImage(_image,geometry.width,geometry.height, |
| 3070 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3071 | break; |
| 3072 | } |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3073 | if (LocaleCompare("segment",option+1) == 0) |
| 3074 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3075 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3076 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3077 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3078 | if ((flags & SigmaValue) == 0) |
| 3079 | geometry_info.sigma=1.0; |
| 3080 | (void) SegmentImage(_image,_image->colorspace, |
| 3081 | _image_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 3082 | _exception); |
| 3083 | break; |
| 3084 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3085 | if (LocaleCompare("selective-blur",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3086 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3087 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3088 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3089 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3090 | if ((flags & SigmaValue) == 0) |
| 3091 | geometry_info.sigma=1.0; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3092 | if ((flags & PercentValue) != 0) |
| 3093 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3094 | new_image=SelectiveBlurImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3095 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3096 | break; |
| 3097 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3098 | if (LocaleCompare("separate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3099 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3100 | /* WARNING: This can generate multiple images! */ |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3101 | /* FUTURE - this may be replaced by a "-channel" method */ |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3102 | new_image=SeparateImages(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3103 | break; |
| 3104 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3105 | if (LocaleCompare("sepia-tone",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3106 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3107 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3108 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
| 3109 | new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1, |
| 3110 | (double) QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3111 | break; |
| 3112 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3113 | if (LocaleCompare("shade",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3114 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3115 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3116 | if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0)) |
| 3117 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3118 | new_image=ShadeImage(_image,IsNormalOp,geometry_info.rho, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3119 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3120 | break; |
| 3121 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3122 | if (LocaleCompare("shadow",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3123 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3124 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3125 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3126 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3127 | if ((flags & SigmaValue) == 0) |
| 3128 | geometry_info.sigma=1.0; |
| 3129 | if ((flags & XiValue) == 0) |
| 3130 | geometry_info.xi=4.0; |
| 3131 | if ((flags & PsiValue) == 0) |
| 3132 | geometry_info.psi=4.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3133 | new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3134 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3135 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3136 | break; |
| 3137 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3138 | if (LocaleCompare("sharpen",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3139 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3140 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3141 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3142 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3143 | if ((flags & SigmaValue) == 0) |
| 3144 | geometry_info.sigma=1.0; |
| 3145 | if ((flags & XiValue) == 0) |
| 3146 | geometry_info.xi=0.0; |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3147 | new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3148 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3149 | break; |
| 3150 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3151 | if (LocaleCompare("shave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3152 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3153 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3154 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3155 | flags=ParsePageGeometry(_image,arg1,&geometry,_exception); |
| 3156 | new_image=ShaveImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3157 | break; |
| 3158 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3159 | if (LocaleCompare("shear",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3160 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3161 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3162 | if ((flags & RhoValue) == 0) |
| 3163 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3164 | if ((flags & SigmaValue) == 0) |
| 3165 | geometry_info.sigma=geometry_info.rho; |
cristy | 4b89261 | 2012-08-03 19:31:31 +0000 | [diff] [blame] | 3166 | new_image=ShearImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3167 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3168 | break; |
| 3169 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3170 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3171 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3172 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3173 | if ((flags & RhoValue) == 0) |
| 3174 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3175 | if ((flags & SigmaValue) == 0) |
| 3176 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3177 | if ((flags & PercentValue) != 0) |
| 3178 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3179 | 100.0; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3180 | (void) SigmoidalContrastImage(_image,IsNormalOp,geometry_info.rho, |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 3181 | geometry_info.sigma,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3182 | break; |
| 3183 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3184 | if (LocaleCompare("sketch",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3185 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3186 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3187 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3188 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3189 | if ((flags & SigmaValue) == 0) |
| 3190 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3191 | new_image=SketchImage(_image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3192 | geometry_info.sigma,geometry_info.xi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3193 | break; |
| 3194 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3195 | if (LocaleCompare("solarize",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3196 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3197 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3198 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3199 | (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double) |
| 3200 | QuantumRange+1.0),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3201 | break; |
| 3202 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3203 | if (LocaleCompare("sparse-color",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3204 | { |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3205 | parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1); |
| 3206 | if ( parse < 0 ) |
| 3207 | CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod", |
| 3208 | option,arg1); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3209 | new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2, |
| 3210 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3211 | break; |
| 3212 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3213 | if (LocaleCompare("splice",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3214 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3215 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3216 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3217 | flags=ParseGravityGeometry(_image,arg1,&geometry,_exception); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3218 | new_image=SpliceImage(_image,&geometry,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3219 | break; |
| 3220 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3221 | if (LocaleCompare("spread",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3222 | { |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3223 | flags=ParseGeometry(arg1,&geometry_info); |
| 3224 | if ((flags & RhoValue) == 0) |
| 3225 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3226 | new_image=SpreadImage(_image,geometry_info.rho,_image->interpolate, |
| 3227 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3228 | break; |
| 3229 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3230 | if (LocaleCompare("statistic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3231 | { |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3232 | parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1); |
| 3233 | if ( parse < 0 ) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 3234 | CLIWandExceptArgBreak(OptionError,"UnrecognizedStatisticType", |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3235 | option,arg1); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3236 | flags=ParseGeometry(arg2,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3237 | if ((flags & RhoValue) == 0) |
| 3238 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 3239 | if ((flags & SigmaValue) == 0) |
| 3240 | geometry_info.sigma=geometry_info.rho; |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 3241 | new_image=StatisticImage(_image,(StatisticType)parse, |
| 3242 | (size_t) geometry_info.rho,(size_t) geometry_info.sigma, |
| 3243 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3244 | break; |
| 3245 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3246 | if (LocaleCompare("strip",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3247 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3248 | (void) StripImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3249 | break; |
| 3250 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3251 | if (LocaleCompare("swirl",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3252 | { |
cristy | 898c604 | 2012-06-24 00:36:34 +0000 | [diff] [blame] | 3253 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 3254 | if ((flags & RhoValue) == 0) |
cristy | 898c604 | 2012-06-24 00:36:34 +0000 | [diff] [blame] | 3255 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3256 | new_image=SwirlImage(_image,geometry_info.rho, |
| 3257 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3258 | break; |
| 3259 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3260 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3261 | } |
| 3262 | case 't': |
| 3263 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3264 | if (LocaleCompare("threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3265 | { |
| 3266 | double |
| 3267 | threshold; |
| 3268 | |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3269 | threshold=(double) QuantumRange/2; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3270 | if (IfNormalOp) { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3271 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3272 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3273 | threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3274 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3275 | (void) BilevelImage(_image,threshold,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3276 | break; |
| 3277 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3278 | if (LocaleCompare("thumbnail",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3279 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3280 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3281 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3282 | (void) ParseRegionGeometry(_image,arg1,&geometry,_exception); |
| 3283 | new_image=ThumbnailImage(_image,geometry.width,geometry.height, |
| 3284 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3285 | break; |
| 3286 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3287 | if (LocaleCompare("tint",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3288 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3289 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3290 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3291 | new_image=TintImage(_image,arg1,&_draw_info->fill,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3292 | break; |
| 3293 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3294 | if (LocaleCompare("transform",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3295 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3296 | CLIWandWarnReplaced("+distort AffineProjection"); |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3297 | new_image=AffineTransformImage(_image,&_draw_info->affine,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3298 | break; |
| 3299 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3300 | if (LocaleCompare("transparent",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3301 | { |
| 3302 | PixelInfo |
| 3303 | target; |
| 3304 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3305 | (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception); |
| 3306 | (void) TransparentPaintImage(_image,&target,(Quantum) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3307 | TransparentAlpha,IsPlusOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3308 | break; |
| 3309 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3310 | if (LocaleCompare("transpose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3311 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3312 | new_image=TransposeImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3313 | break; |
| 3314 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3315 | if (LocaleCompare("transverse",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3316 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3317 | new_image=TransverseImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3318 | break; |
| 3319 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3320 | if (LocaleCompare("trim",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3321 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3322 | new_image=TrimImage(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3323 | break; |
| 3324 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3325 | if (LocaleCompare("type",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3326 | { |
anthony | ab3a50c | 2011-10-27 11:48:57 +0000 | [diff] [blame] | 3327 | /* Note that "type" setting should have already been defined */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3328 | (void) SetImageType(_image,_image_info->type,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3329 | break; |
| 3330 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3331 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3332 | } |
| 3333 | case 'u': |
| 3334 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3335 | if (LocaleCompare("unique",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3336 | { |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3337 | /* FUTURE: move to SyncImageSettings() and AcqireImage()??? |
| 3338 | Option is not documented, bt appears to be for "identify". |
| 3339 | We may need a identify specific verbose! |
| 3340 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3341 | if (IsPlusOp) { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3342 | (void) DeleteImageArtifact(_image,"identify:unique-colors"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3343 | break; |
| 3344 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3345 | (void) SetImageArtifact(_image,"identify:unique-colors","true"); |
| 3346 | (void) SetImageArtifact(_image,"verbose","true"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3347 | break; |
| 3348 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3349 | if (LocaleCompare("unique-colors",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3350 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3351 | new_image=UniqueImageColors(_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3352 | break; |
| 3353 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3354 | if (LocaleCompare("unsharp",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3355 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3356 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3357 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3358 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3359 | if ((flags & SigmaValue) == 0) |
| 3360 | geometry_info.sigma=1.0; |
| 3361 | if ((flags & XiValue) == 0) |
| 3362 | geometry_info.xi=1.0; |
| 3363 | if ((flags & PsiValue) == 0) |
| 3364 | geometry_info.psi=0.05; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3365 | new_image=UnsharpMaskImage(_image,geometry_info.rho, |
cristy | 3afd401 | 2013-03-25 11:30:44 +0000 | [diff] [blame] | 3366 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3367 | break; |
| 3368 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3369 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3370 | } |
| 3371 | case 'v': |
| 3372 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3373 | if (LocaleCompare("verbose",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3374 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3375 | /* FUTURE: move to SyncImageSettings() and AcquireImage()??? |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3376 | three places! ImageArtifact ImageOption _image_info->verbose |
anthony | 5330ae0 | 2012-03-20 14:17:01 +0000 | [diff] [blame] | 3377 | Some how new images also get this artifact! |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3378 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3379 | (void) SetImageArtifact(_image,option+1, |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3380 | IfNormalOp ? "true" : "false" ); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3381 | break; |
| 3382 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3383 | if (LocaleCompare("vignette",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3384 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3385 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3386 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3387 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3388 | if ((flags & SigmaValue) == 0) |
| 3389 | geometry_info.sigma=1.0; |
| 3390 | if ((flags & XiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3391 | geometry_info.xi=0.1*_image->columns; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3392 | if ((flags & PsiValue) == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3393 | geometry_info.psi=0.1*_image->rows; |
cristy | 8e2392e | 2013-11-11 17:58:38 +0000 | [diff] [blame] | 3394 | if ((flags & PercentValue) != 0) |
| 3395 | { |
cristy | 720d756 | 2013-11-14 19:18:11 +0000 | [diff] [blame] | 3396 | geometry_info.xi*=(double) _image->columns/100.0; |
| 3397 | geometry_info.psi*=(double) _image->rows/100.0; |
cristy | 8e2392e | 2013-11-11 17:58:38 +0000 | [diff] [blame] | 3398 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3399 | new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3400 | (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3401 | ceil(geometry_info.psi-0.5),_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3402 | break; |
| 3403 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3404 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3405 | } |
| 3406 | case 'w': |
| 3407 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3408 | if (LocaleCompare("wave",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3409 | { |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3410 | flags=ParseGeometry(arg1,&geometry_info); |
anthony | 22de272 | 2012-04-19 14:43:00 +0000 | [diff] [blame] | 3411 | if ((flags & (RhoValue|SigmaValue)) == 0) |
| 3412 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3413 | if ((flags & SigmaValue) == 0) |
| 3414 | geometry_info.sigma=1.0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3415 | new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma, |
| 3416 | _image->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3417 | break; |
| 3418 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3419 | if (LocaleCompare("white-threshold",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3420 | { |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3421 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 3422 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3423 | (void) WhiteThresholdImage(_image,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3424 | break; |
| 3425 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3426 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3427 | } |
| 3428 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3429 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3430 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3431 | /* clean up percent escape interpreted strings */ |
| 3432 | if (arg1 != arg1n ) |
| 3433 | arg1=DestroyString((char *)arg1); |
| 3434 | if (arg2 != arg2n ) |
| 3435 | arg2=DestroyString((char *)arg2); |
| 3436 | |
| 3437 | /* Replace current image with any image that was generated |
| 3438 | and set image point to last image (so image->next is correct) */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3439 | if (new_image != (Image *) NULL) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3440 | ReplaceImageInListReturnLast(&_image,new_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3441 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3442 | return(MagickTrue); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3443 | #undef _image_info |
| 3444 | #undef _draw_info |
| 3445 | #undef _quantize_info |
| 3446 | #undef _image |
| 3447 | #undef _exception |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3448 | #undef IfNormalOp |
| 3449 | #undef IfPlusOp |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3450 | #undef IsNormalOp |
| 3451 | #undef IsPlusOp |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3452 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3453 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3454 | WandPrivate MagickBooleanType CLISimpleOperatorImages(MagickCLI *cli_wand, |
| 3455 | const char *option,const char *arg1,const char *arg2) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3456 | { |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3457 | #if !USE_WAND_METHODS |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3458 | size_t |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3459 | n, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3460 | i; |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3461 | #endif |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3462 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3463 | assert(cli_wand != (MagickCLI *) NULL); |
| 3464 | assert(cli_wand->signature == WandSignature); |
| 3465 | assert(cli_wand->wand.signature == WandSignature); |
| 3466 | assert(cli_wand->wand.images != (Image *) NULL); /* images must be present */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3467 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3468 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3469 | (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), |
| 3470 | "- Simple Operator: %s \"%s\" \"%s\"", option,arg1,arg2); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3471 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3472 | #if !USE_WAND_METHODS |
| 3473 | /* FUTURE add appropriate tracing */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3474 | i=0; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3475 | n=GetImageListLength(cli_wand->wand.images); |
| 3476 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3477 | while (1) { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3478 | i++; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3479 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3480 | if ( cli_wand->wand.images->next == (Image *) NULL ) |
| 3481 | break; |
| 3482 | cli_wand->wand.images=cli_wand->wand.images->next; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3483 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3484 | assert( i == n ); |
| 3485 | cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3486 | #else |
| 3487 | MagickResetIterator(&cli_wand->wand); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3488 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3489 | CLISimpleOperatorImage(cli_wand, option, arg1, arg2); |
| 3490 | MagickResetIterator(&cli_wand->wand); |
| 3491 | #endif |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3492 | return(MagickTrue); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3493 | } |
| 3494 | |
| 3495 | /* |
| 3496 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3497 | % % |
| 3498 | % % |
| 3499 | % % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3500 | + 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] | 3501 | % % |
| 3502 | % % |
| 3503 | % % |
| 3504 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3505 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3506 | % CLIListOperatorImages() applies a single operation that is apply to the |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3507 | % entire image list as a whole. The result is often a complete replacment |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3508 | % of the image list with a completely new list, or with just a single image |
| 3509 | % result. |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3510 | % |
| 3511 | % The format of the MogrifyImage method is: |
| 3512 | % |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3513 | % MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, |
| 3514 | % const char *option,const char *arg1,const char *arg2) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3515 | % |
| 3516 | % A description of each parameter follows: |
| 3517 | % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3518 | % o cli_wand: structure holding settings to be applied |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3519 | % |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3520 | % o option: The option string for the operation |
| 3521 | % |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3522 | % o arg1, arg2: optional argument strings to the operation |
anthony | e5fcd36 | 2012-04-09 04:02:09 +0000 | [diff] [blame] | 3523 | % arg2 is currently not used |
anthony | 8b10b46 | 2012-02-08 12:32:44 +0000 | [diff] [blame] | 3524 | % |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3525 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3526 | WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, |
| 3527 | const char *option,const char *arg1n,const char *arg2n) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3528 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3529 | const char /* percent escaped versions of the args */ |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 3530 | *arg1, |
| 3531 | *arg2; |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3532 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3533 | Image |
| 3534 | *new_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3535 | |
cristy | a30f8e6 | 2013-02-19 15:03:45 +0000 | [diff] [blame] | 3536 | MagickStatusType |
| 3537 | status; |
| 3538 | |
| 3539 | ssize_t |
| 3540 | parse; |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3541 | |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3542 | #define _image_info (cli_wand->wand.image_info) |
| 3543 | #define _images (cli_wand->wand.images) |
| 3544 | #define _exception (cli_wand->wand.exception) |
| 3545 | #define _draw_info (cli_wand->draw_info) |
| 3546 | #define _quantize_info (cli_wand->quantize_info) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3547 | #define _process_flags (cli_wand->process_flags) |
| 3548 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3549 | #define IfNormalOp (*option=='-') |
| 3550 | #define IfPlusOp (*option!='-') |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3551 | #define IsNormalOp IsMagickTrue(IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3552 | |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3553 | assert(cli_wand != (MagickCLI *) NULL); |
| 3554 | assert(cli_wand->signature == WandSignature); |
| 3555 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3556 | assert(_images != (Image *) NULL); /* _images must be present */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3557 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3558 | if (IfMagickTrue(cli_wand->wand.debug)) |
| 3559 | (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), |
| 3560 | "- List Operator: %s \"%s\" \"%s\"", option,arg1n,arg2n); |
| 3561 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3562 | arg1 = arg1n; |
| 3563 | arg2 = arg2n; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3564 | |
| 3565 | /* Interpret Percent Escapes in Arguments - using first image */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3566 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 3567 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 3568 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 3569 | /* Interpret Percent escapes in argument 1 */ |
| 3570 | if (arg1n != (char *) NULL) { |
| 3571 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 3572 | if (arg1 == (char *) NULL) { |
| 3573 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3574 | arg1=arg1n; /* use the given argument as is */ |
| 3575 | } |
| 3576 | } |
| 3577 | if (arg2n != (char *) NULL) { |
| 3578 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 3579 | if (arg2 == (char *) NULL) { |
| 3580 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 3581 | arg2=arg2n; /* use the given argument as is */ |
| 3582 | } |
| 3583 | } |
| 3584 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 3585 | #undef _process_flags |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3586 | #undef _option_type |
| 3587 | |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3588 | status=MagickTrue; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3589 | new_images=NewImageList(); |
| 3590 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3591 | switch (*(option+1)) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3592 | { |
| 3593 | case 'a': |
| 3594 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3595 | if (LocaleCompare("append",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3596 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3597 | new_images=AppendImages(_images,IsNormalOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3598 | break; |
| 3599 | } |
cristy | 52ad9e9 | 2013-02-08 23:23:29 +0000 | [diff] [blame] | 3600 | if (LocaleCompare("average",option+1) == 0) |
| 3601 | { |
| 3602 | CLIWandWarnReplaced("-evaluate-sequence Mean"); |
| 3603 | CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); |
| 3604 | break; |
| 3605 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3606 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3607 | } |
| 3608 | case 'c': |
| 3609 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3610 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3611 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3612 | new_images=ChannelFxImage(_images,arg1,_exception); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3613 | break; |
| 3614 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3615 | if (LocaleCompare("clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3616 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3617 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3618 | *clut_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3619 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3620 | /* FUTURE - make this a compose option, and thus can be used |
| 3621 | with layers compose or even compose last image over all other |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3622 | _images. |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3623 | */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3624 | new_images=RemoveFirstImageFromList(&_images); |
| 3625 | clut_image=RemoveLastImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3626 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3627 | if (clut_image == (Image *) NULL) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3628 | break; |
cristy | e52fb5e | 2012-04-06 23:30:20 +0000 | [diff] [blame] | 3629 | (void) ClutImage(new_images,clut_image,new_images->interpolate,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3630 | clut_image=DestroyImage(clut_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3631 | break; |
| 3632 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3633 | if (LocaleCompare("coalesce",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3634 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3635 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3636 | break; |
| 3637 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3638 | if (LocaleCompare("combine",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3639 | { |
anthony | 5a4ff37 | 2013-05-01 04:48:57 +0000 | [diff] [blame] | 3640 | parse = (ssize_t) sRGBColorspace; /* default (backward compatible) */ |
| 3641 | if ( IfPlusOp ) |
| 3642 | parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 3643 | arg1); |
cristy | 8448a0d | 2013-02-15 18:20:53 +0000 | [diff] [blame] | 3644 | if (parse < 0) |
| 3645 | CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace",option, |
| 3646 | arg1); |
cristy | 46f354c | 2012-07-04 13:31:29 +0000 | [diff] [blame] | 3647 | new_images=CombineImages(_images,(ColorspaceType) parse,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3648 | break; |
| 3649 | } |
cristy | e863c05 | 2013-09-04 11:31:30 +0000 | [diff] [blame] | 3650 | if (LocaleCompare("compare",option+1) == 0) |
| 3651 | { |
| 3652 | double |
| 3653 | distortion; |
| 3654 | |
| 3655 | Image |
| 3656 | *image, |
| 3657 | *reconstruct_image; |
| 3658 | |
| 3659 | MetricType |
| 3660 | metric; |
| 3661 | |
| 3662 | /* |
| 3663 | Mathematically and visually annotate the difference between an |
| 3664 | image and its reconstruction. |
| 3665 | */ |
| 3666 | image=RemoveFirstImageFromList(&_images); |
| 3667 | reconstruct_image=RemoveFirstImageFromList(&_images); |
| 3668 | /* FUTURE - produce Exception, rather than silent fail */ |
| 3669 | if (reconstruct_image == (Image *) NULL) |
| 3670 | break; |
| 3671 | metric=UndefinedErrorMetric; |
| 3672 | option=GetImageOption(_image_info,"metric"); |
| 3673 | if (option != (const char *) NULL) |
| 3674 | metric=(MetricType) ParseCommandOption(MagickMetricOptions, |
| 3675 | MagickFalse,option); |
| 3676 | new_images=CompareImages(image,reconstruct_image,metric,&distortion, |
| 3677 | _exception); |
| 3678 | (void) distortion; |
| 3679 | reconstruct_image=DestroyImage(reconstruct_image); |
| 3680 | image=DestroyImage(image); |
| 3681 | break; |
| 3682 | } |
cristy | 790190d | 2013-10-04 00:51:51 +0000 | [diff] [blame] | 3683 | if (LocaleCompare("complex",option+1) == 0) |
| 3684 | { |
| 3685 | parse=ParseCommandOption(MagickComplexOptions,MagickFalse,arg1); |
| 3686 | if (parse < 0) |
| 3687 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
| 3688 | option,arg1); |
cristy | b8f66bb | 2013-10-04 15:21:58 +0000 | [diff] [blame] | 3689 | new_images=ComplexImages(_images,(ComplexOperator) parse,_exception); |
cristy | 790190d | 2013-10-04 00:51:51 +0000 | [diff] [blame] | 3690 | break; |
| 3691 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3692 | if (LocaleCompare("composite",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3693 | { |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3694 | CompositeOperator |
| 3695 | compose; |
| 3696 | |
| 3697 | const char* |
| 3698 | value; |
| 3699 | |
| 3700 | MagickBooleanType |
| 3701 | clip_to_self; |
| 3702 | |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3703 | Image |
| 3704 | *mask_image, |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3705 | *source_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3706 | |
| 3707 | RectangleInfo |
| 3708 | geometry; |
| 3709 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3710 | /* Compose value from "-compose" option only */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3711 | value=GetImageOption(_image_info,"compose"); |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3712 | if (value == (const char *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3713 | compose=OverCompositeOp; /* use Over not source_image->compose */ |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 3714 | else |
| 3715 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 3716 | MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3717 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3718 | /* Get "clip-to-self" expert setting (false is normal) */ |
cristy | ca0e82c | 2012-04-10 11:53:24 +0000 | [diff] [blame] | 3719 | value=GetImageOption(_image_info,"compose:clip-to-self"); |
| 3720 | if (value == (const char *) NULL) |
| 3721 | clip_to_self=MagickTrue; |
| 3722 | else |
| 3723 | clip_to_self=IsStringTrue(GetImageOption(_image_info, |
| 3724 | "compose:clip-to-self")); /* if this is true */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3725 | value=GetImageOption(_image_info,"compose:outside-overlay"); |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3726 | if (value != (const char *) NULL) { /* or this false */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3727 | /* FUTURE: depreciate warning for "compose:outside-overlay"*/ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3728 | clip_to_self= IsMagickFalse(IsStringNotFalse(value)); |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3729 | } |
| 3730 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3731 | new_images=RemoveFirstImageFromList(&_images); |
| 3732 | source_image=RemoveFirstImageFromList(&_images); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3733 | if (source_image == (Image *) NULL) |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3734 | break; /* FUTURE - produce Exception, rather than silent fail */ |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3735 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3736 | /* FUTURE - this should not be here! - should be part of -geometry */ |
| 3737 | (void) TransformImage(&source_image,(char *) NULL, |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3738 | source_image->geometry,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3739 | SetGeometry(source_image,&geometry); |
| 3740 | (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); |
| 3741 | GravityAdjustGeometry(new_images->columns,new_images->rows, |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3742 | new_images->gravity, &geometry); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3743 | mask_image=RemoveFirstImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3744 | if (mask_image != (Image *) NULL) |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3745 | { |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 3746 | if ((compose == DisplaceCompositeOp) || |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3747 | (compose == DistortCompositeOp)) |
| 3748 | status&=CompositeImage(source_image,mask_image, |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3749 | CopyGreenCompositeOp,MagickTrue,0,0,_exception); |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3750 | else |
cristy | 15007e8 | 2013-02-17 18:46:40 +0000 | [diff] [blame] | 3751 | { |
| 3752 | Image |
| 3753 | *image; |
| 3754 | |
| 3755 | RectangleInfo |
| 3756 | source_geometry; |
| 3757 | |
| 3758 | source_geometry.width=mask_image->columns; |
| 3759 | source_geometry.height=mask_image->rows; |
| 3760 | source_geometry.x=(-geometry.x); |
| 3761 | source_geometry.y=(-geometry.y); |
| 3762 | geometry.x=0; |
| 3763 | geometry.y=0; |
| 3764 | image=ExtentImage(source_image,&source_geometry,_exception); |
| 3765 | if (image != (Image *) NULL) |
| 3766 | { |
| 3767 | source_image=DestroyImage(source_image); |
| 3768 | source_image=image; |
| 3769 | } |
| 3770 | status&=CompositeImage(source_image,mask_image, |
| 3771 | IntensityCompositeOp,MagickTrue,0,0,_exception); |
| 3772 | } |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3773 | mask_image=DestroyImage(mask_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3774 | } |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 3775 | status&=CompositeImage(new_images,source_image,compose,clip_to_self, |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 3776 | geometry.x,geometry.y,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3777 | source_image=DestroyImage(source_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3778 | break; |
| 3779 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3780 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3781 | } |
| 3782 | case 'd': |
| 3783 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3784 | if (LocaleCompare("deconstruct",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3785 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 3786 | CLIWandWarnReplaced("-layer CompareAny"); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3787 | CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3788 | break; |
| 3789 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3790 | if (LocaleCompare("delete",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3791 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3792 | if (IfNormalOp) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3793 | DeleteImages(&_images,arg1,_exception); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3794 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3795 | DeleteImages(&_images,"-1",_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3796 | break; |
| 3797 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3798 | if (LocaleCompare("duplicate",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3799 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3800 | if (IfNormalOp) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3801 | { |
| 3802 | const char |
| 3803 | *p; |
| 3804 | |
| 3805 | size_t |
| 3806 | number_duplicates; |
| 3807 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3808 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3809 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option, |
| 3810 | arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3811 | number_duplicates=(size_t) StringToLong(arg1); |
| 3812 | p=strchr(arg1,','); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3813 | if (p == (const char *) NULL) |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3814 | new_images=DuplicateImages(_images,number_duplicates,"-1", |
| 3815 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3816 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3817 | new_images=DuplicateImages(_images,number_duplicates,p, |
| 3818 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3819 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3820 | else |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3821 | new_images=DuplicateImages(_images,1,"-1",_exception); |
| 3822 | AppendImageToList(&_images, new_images); |
anthony | 36a8c2c | 2012-02-10 00:08:44 +0000 | [diff] [blame] | 3823 | new_images=(Image *)NULL; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3824 | break; |
| 3825 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3826 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3827 | } |
| 3828 | case 'e': |
| 3829 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3830 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3831 | { |
cristy | 790190d | 2013-10-04 00:51:51 +0000 | [diff] [blame] | 3832 | parse=ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); |
| 3833 | if (parse < 0) |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3834 | CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator", |
cristy | 790190d | 2013-10-04 00:51:51 +0000 | [diff] [blame] | 3835 | option,arg1); |
anthony | 2a0ec8c | 2012-03-24 04:35:56 +0000 | [diff] [blame] | 3836 | new_images=EvaluateImages(_images,(MagickEvaluateOperator)parse, |
cristy | 790190d | 2013-10-04 00:51:51 +0000 | [diff] [blame] | 3837 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3838 | break; |
| 3839 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3840 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3841 | } |
| 3842 | case 'f': |
| 3843 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3844 | if (LocaleCompare("fft",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3845 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3846 | new_images=ForwardFourierTransformImage(_images,IsNormalOp,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3847 | break; |
| 3848 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3849 | if (LocaleCompare("flatten",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3850 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 3851 | /* REDIRECTED to use -layers flatten instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 3852 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3853 | break; |
| 3854 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3855 | if (LocaleCompare("fx",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3856 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3857 | new_images=FxImage(_images,arg1,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3858 | break; |
| 3859 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3860 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3861 | } |
| 3862 | case 'h': |
| 3863 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3864 | if (LocaleCompare("hald-clut",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3865 | { |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3866 | /* FUTURE - make this a compose option (and thus layers compose ) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3867 | or perhaps compose last image over all other _images. |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3868 | */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3869 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3870 | *hald_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3871 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3872 | new_images=RemoveFirstImageFromList(&_images); |
| 3873 | hald_image=RemoveLastImageFromList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3874 | if (hald_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3875 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3876 | (void) HaldClutImage(new_images,hald_image,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3877 | hald_image=DestroyImage(hald_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3878 | break; |
| 3879 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3880 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3881 | } |
| 3882 | case 'i': |
| 3883 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3884 | if (LocaleCompare("ift",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3885 | { |
| 3886 | Image |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3887 | *magnitude_image, |
| 3888 | *phase_image; |
| 3889 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3890 | magnitude_image=RemoveFirstImageFromList(&_images); |
| 3891 | phase_image=RemoveFirstImageFromList(&_images); |
anthony | e8f5649 | 2012-02-12 12:39:02 +0000 | [diff] [blame] | 3892 | /* FUTURE - produce Exception, rather than silent fail */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3893 | if (phase_image == (Image *) NULL) |
| 3894 | break; |
| 3895 | new_images=InverseFourierTransformImage(magnitude_image,phase_image, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3896 | IsNormalOp,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3897 | magnitude_image=DestroyImage(magnitude_image); |
| 3898 | phase_image=DestroyImage(phase_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3899 | break; |
| 3900 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3901 | if (LocaleCompare("insert",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3902 | { |
| 3903 | Image |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3904 | *insert_image, |
| 3905 | *index_image; |
| 3906 | |
| 3907 | ssize_t |
| 3908 | index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3909 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 3910 | if (IfNormalOp && IfMagickFalse(IsGeometry(arg1))) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3911 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3912 | index=0; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3913 | insert_image=RemoveLastImageFromList(&_images); |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3914 | if (IfNormalOp) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3915 | index=(ssize_t) StringToLong(arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3916 | index_image=insert_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3917 | if (index == 0) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3918 | PrependImageToList(&_images,insert_image); |
| 3919 | else if (index == (ssize_t) GetImageListLength(_images)) |
| 3920 | AppendImageToList(&_images,insert_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3921 | else |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3922 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3923 | index_image=GetImageFromList(_images,index-1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3924 | if (index_image == (Image *) NULL) |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3925 | CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 3926 | InsertImageInList(&index_image,insert_image); |
| 3927 | } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3928 | _images=GetFirstImageInList(index_image); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3929 | break; |
| 3930 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 3931 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3932 | } |
| 3933 | case 'l': |
| 3934 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 3935 | if (LocaleCompare("layers",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3936 | { |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3937 | parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); |
| 3938 | if ( parse < 0 ) |
| 3939 | CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod", |
| 3940 | option,arg1); |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3941 | switch ((LayerMethod) parse) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3942 | { |
| 3943 | case CoalesceLayer: |
| 3944 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3945 | new_images=CoalesceImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3946 | break; |
| 3947 | } |
| 3948 | case CompareAnyLayer: |
| 3949 | case CompareClearLayer: |
| 3950 | case CompareOverlayLayer: |
| 3951 | default: |
| 3952 | { |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3953 | new_images=CompareImagesLayers(_images,(LayerMethod) parse, |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3954 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3955 | break; |
| 3956 | } |
| 3957 | case MergeLayer: |
| 3958 | case FlattenLayer: |
| 3959 | case MosaicLayer: |
| 3960 | case TrimBoundsLayer: |
| 3961 | { |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 3962 | new_images=MergeImageLayers(_images,(LayerMethod) parse, |
anthony | fe1aa78 | 2012-03-24 13:43:04 +0000 | [diff] [blame] | 3963 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3964 | break; |
| 3965 | } |
| 3966 | case DisposeLayer: |
| 3967 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3968 | new_images=DisposeImages(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3969 | break; |
| 3970 | } |
| 3971 | case OptimizeImageLayer: |
| 3972 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3973 | new_images=OptimizeImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3974 | break; |
| 3975 | } |
| 3976 | case OptimizePlusLayer: |
| 3977 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3978 | new_images=OptimizePlusImageLayers(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3979 | break; |
| 3980 | } |
| 3981 | case OptimizeTransLayer: |
| 3982 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3983 | OptimizeImageTransparency(_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3984 | break; |
| 3985 | } |
| 3986 | case RemoveDupsLayer: |
| 3987 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3988 | RemoveDuplicateLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3989 | break; |
| 3990 | } |
| 3991 | case RemoveZeroLayer: |
| 3992 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3993 | RemoveZeroDelayLayers(&_images,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 3994 | break; |
| 3995 | } |
| 3996 | case OptimizeLayer: |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3997 | { /* General Purpose, GIF Animation Optimizer. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 3998 | new_images=CoalesceImages(_images,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 3999 | if (new_images == (Image *) NULL) |
| 4000 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4001 | _images=DestroyImageList(_images); |
| 4002 | _images=OptimizeImageLayers(new_images,_exception); |
| 4003 | if (_images == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4004 | break; |
| 4005 | new_images=DestroyImageList(new_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4006 | OptimizeImageTransparency(_images,_exception); |
| 4007 | (void) RemapImages(_quantize_info,_images,(Image *) NULL, |
| 4008 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4009 | break; |
| 4010 | } |
| 4011 | case CompositeLayer: |
| 4012 | { |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4013 | Image |
| 4014 | *source; |
| 4015 | |
| 4016 | RectangleInfo |
| 4017 | geometry; |
| 4018 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4019 | CompositeOperator |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4020 | compose; |
| 4021 | |
| 4022 | const char* |
| 4023 | value; |
| 4024 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4025 | value=GetImageOption(_image_info,"compose"); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4026 | compose=OverCompositeOp; /* Default to Over */ |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4027 | if (value != (const char *) NULL) |
| 4028 | compose=(CompositeOperator) ParseCommandOption( |
| 4029 | MagickComposeOptions,MagickFalse,value); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4030 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4031 | /* Split image sequence at the first 'NULL:' image. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4032 | source=_images; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4033 | while (source != (Image *) NULL) |
| 4034 | { |
| 4035 | source=GetNextImageInList(source); |
| 4036 | if ((source != (Image *) NULL) && |
| 4037 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 4038 | break; |
| 4039 | } |
| 4040 | if (source != (Image *) NULL) |
| 4041 | { |
| 4042 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 4043 | (GetNextImageInList(source) == (Image *) NULL)) |
| 4044 | source=(Image *) NULL; |
| 4045 | else |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4046 | { /* Separate the two lists, junk the null: image. */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4047 | source=SplitImageList(source->previous); |
| 4048 | DeleteImageFromList(&source); |
| 4049 | } |
| 4050 | } |
| 4051 | if (source == (Image *) NULL) |
| 4052 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4053 | (void) ThrowMagickException(_exception,GetMagickModule(), |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4054 | OptionError,"MissingNullSeparator","layers Composite"); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4055 | break; |
| 4056 | } |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4057 | /* Adjust offset with gravity and virtual canvas. */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4058 | SetGeometry(_images,&geometry); |
| 4059 | (void) ParseAbsoluteGeometry(_images->geometry,&geometry); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4060 | geometry.width=source->page.width != 0 ? |
| 4061 | source->page.width : source->columns; |
| 4062 | geometry.height=source->page.height != 0 ? |
| 4063 | source->page.height : source->rows; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4064 | GravityAdjustGeometry(_images->page.width != 0 ? |
| 4065 | _images->page.width : _images->columns, |
| 4066 | _images->page.height != 0 ? _images->page.height : |
| 4067 | _images->rows,_images->gravity,&geometry); |
anthony | 5f867ae | 2011-10-09 10:28:34 +0000 | [diff] [blame] | 4068 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4069 | /* Compose the two image sequences together */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4070 | CompositeLayers(_images,compose,source,geometry.x,geometry.y, |
| 4071 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4072 | source=DestroyImageList(source); |
| 4073 | break; |
| 4074 | } |
| 4075 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4076 | break; |
| 4077 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4078 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4079 | } |
| 4080 | case 'm': |
| 4081 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4082 | if (LocaleCompare("map",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4083 | { |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4084 | CLIWandWarnReplaced("+remap"); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4085 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4086 | break; |
| 4087 | } |
cristy | e863c05 | 2013-09-04 11:31:30 +0000 | [diff] [blame] | 4088 | if (LocaleCompare("metric",option+1) == 0) |
| 4089 | break; |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4090 | if (LocaleCompare("morph",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4091 | { |
| 4092 | Image |
| 4093 | *morph_image; |
| 4094 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4095 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | 7bc8799 | 2012-03-25 02:32:51 +0000 | [diff] [blame] | 4096 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4097 | morph_image=MorphImages(_images,StringToUnsignedLong(arg1), |
| 4098 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4099 | if (morph_image == (Image *) NULL) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4100 | break; |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4101 | _images=DestroyImageList(_images); |
| 4102 | _images=morph_image; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4103 | break; |
| 4104 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4105 | if (LocaleCompare("mosaic",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4106 | { |
anthony | 319dac6 | 2012-03-06 04:12:44 +0000 | [diff] [blame] | 4107 | /* REDIRECTED to use -layers mosaic instead */ |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 4108 | CLIListOperatorImages(cli_wand,"-layers",option+1,NULL); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4109 | break; |
| 4110 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4111 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4112 | } |
| 4113 | case 'p': |
| 4114 | { |
cristy | 02016cf | 2012-11-13 01:14:41 +0000 | [diff] [blame] | 4115 | if (LocaleCompare("poly",option+1) == 0) |
| 4116 | { |
| 4117 | double |
| 4118 | *args; |
| 4119 | |
| 4120 | ssize_t |
| 4121 | count; |
| 4122 | |
| 4123 | /* convert argument string into an array of doubles */ |
| 4124 | args = StringToArrayOfDoubles(arg2,&count,_exception); |
| 4125 | if (args == (double *)NULL ) |
| 4126 | CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); |
| 4127 | new_images=PolynomialImage(_images,count >> 1,args,_exception); |
| 4128 | args=(double *) RelinquishMagickMemory(args); |
| 4129 | break; |
| 4130 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4131 | if (LocaleCompare("process",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4132 | { |
anthony | b1d483a | 2012-04-14 12:53:56 +0000 | [diff] [blame] | 4133 | /* FUTURE: better parsing using ScriptToken() from string ??? */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4134 | char |
| 4135 | **arguments; |
| 4136 | |
| 4137 | int |
| 4138 | j, |
| 4139 | number_arguments; |
| 4140 | |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4141 | arguments=StringToArgv(arg1,&number_arguments); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4142 | if (arguments == (char **) NULL) |
| 4143 | break; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4144 | if (strchr(arguments[1],'=') != (char *) NULL) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4145 | { |
| 4146 | char |
| 4147 | breaker, |
| 4148 | quote, |
| 4149 | *token; |
| 4150 | |
| 4151 | const char |
| 4152 | *arguments; |
| 4153 | |
| 4154 | int |
| 4155 | next, |
| 4156 | status; |
| 4157 | |
| 4158 | size_t |
| 4159 | length; |
| 4160 | |
| 4161 | TokenInfo |
| 4162 | *token_info; |
| 4163 | |
| 4164 | /* |
anthony | 24aa882 | 2012-03-11 00:56:06 +0000 | [diff] [blame] | 4165 | Support old style syntax, filter="-option arg1". |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4166 | */ |
cristy | 4bc3dac | 2014-01-18 15:17:26 +0000 | [diff] [blame] | 4167 | assert(arg1 != (const char *) NULL); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4168 | length=strlen(arg1); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4169 | token=(char *) NULL; |
| 4170 | if (~length >= (MaxTextExtent-1)) |
| 4171 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 4172 | sizeof(*token)); |
| 4173 | if (token == (char *) NULL) |
| 4174 | break; |
| 4175 | next=0; |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4176 | arguments=arg1; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4177 | token_info=AcquireTokenInfo(); |
| 4178 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 4179 | "\"",'\0',&breaker,&next,"e); |
| 4180 | token_info=DestroyTokenInfo(token_info); |
| 4181 | if (status == 0) |
| 4182 | { |
| 4183 | const char |
| 4184 | *argv; |
| 4185 | |
| 4186 | argv=(&(arguments[next])); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4187 | (void) InvokeDynamicImageFilter(token,&_images,1,&argv, |
| 4188 | _exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4189 | } |
| 4190 | token=DestroyString(token); |
| 4191 | break; |
| 4192 | } |
| 4193 | (void) SubstituteString(&arguments[1],"-",""); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4194 | (void) InvokeDynamicImageFilter(arguments[1],&_images, |
| 4195 | number_arguments-2,(const char **) arguments+2,_exception); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4196 | for (j=0; j < number_arguments; j++) |
| 4197 | arguments[j]=DestroyString(arguments[j]); |
| 4198 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 4199 | break; |
| 4200 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4201 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4202 | } |
| 4203 | case 'r': |
| 4204 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4205 | if (LocaleCompare("remap",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4206 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4207 | (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4208 | break; |
| 4209 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4210 | if (LocaleCompare("reverse",option+1) == 0) |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4211 | { |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4212 | ReverseImageList(&_images); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4213 | break; |
| 4214 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4215 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4216 | } |
| 4217 | case 's': |
| 4218 | { |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4219 | if (LocaleCompare("smush",option+1) == 0) |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4220 | { |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4221 | /* FUTURE: this option needs more work to make better */ |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4222 | ssize_t |
| 4223 | offset; |
| 4224 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4225 | if (IfMagickFalse(IsGeometry(arg1))) |
anthony | f42014d | 2012-03-25 09:53:06 +0000 | [diff] [blame] | 4226 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4227 | offset=(ssize_t) StringToLong(arg1); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4228 | new_images=SmushImages(_images,IsNormalOp,offset,_exception); |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4229 | break; |
| 4230 | } |
| 4231 | if (LocaleCompare("subimage",option+1) == 0) |
| 4232 | { |
| 4233 | Image |
| 4234 | *base_image, |
| 4235 | *compare_image; |
| 4236 | |
| 4237 | const char * |
| 4238 | value; |
| 4239 | |
| 4240 | MetricType |
| 4241 | metric; |
| 4242 | |
| 4243 | double |
| 4244 | similarity; |
| 4245 | |
| 4246 | RectangleInfo |
| 4247 | offset; |
| 4248 | |
| 4249 | base_image=GetImageFromList(_images,0); |
| 4250 | compare_image=GetImageFromList(_images,1); |
| 4251 | |
| 4252 | /* Comparision Metric */ |
cristy | 0816329 | 2013-07-11 00:00:37 +0000 | [diff] [blame] | 4253 | metric=UndefinedErrorMetric; |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4254 | value=GetImageOption(_image_info,"metric"); |
| 4255 | if (value != (const char *) NULL) |
| 4256 | metric=(MetricType) ParseCommandOption(MagickMetricOptions, |
| 4257 | MagickFalse,value); |
| 4258 | |
cristy | 99fcec4 | 2013-03-15 21:37:59 +0000 | [diff] [blame] | 4259 | new_images=SimilarityImage(base_image,compare_image,metric,0.0, |
anthony | cd358fc | 2012-04-16 13:59:03 +0000 | [diff] [blame] | 4260 | &offset,&similarity,_exception); |
| 4261 | |
| 4262 | if ( new_images != (Image *)NULL ) { |
| 4263 | char |
| 4264 | result[MaxTextExtent]; |
| 4265 | |
| 4266 | (void) FormatLocaleString(result,MaxTextExtent,"%lf",similarity); |
| 4267 | (void) SetImageProperty(new_images,"subimage:similarity",result, |
| 4268 | _exception); |
| 4269 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4270 | (long) offset.x); |
| 4271 | (void) SetImageProperty(new_images,"subimage:x",result, |
| 4272 | _exception); |
| 4273 | (void) FormatLocaleString(result,MaxTextExtent,"%+ld", |
| 4274 | (long) offset.y); |
| 4275 | (void) SetImageProperty(new_images,"subimage:y",result, |
| 4276 | _exception); |
| 4277 | (void) FormatLocaleString(result,MaxTextExtent,"%lux%lu%+ld%+ld", |
| 4278 | (unsigned long) offset.width,(unsigned long) offset.height, |
| 4279 | (long) offset.x,(long) offset.y); |
| 4280 | (void) SetImageProperty(new_images,"subimage:offset",result, |
| 4281 | _exception); |
| 4282 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4283 | break; |
| 4284 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4285 | if (LocaleCompare("swap",option+1) == 0) { |
| 4286 | Image |
| 4287 | *p, |
| 4288 | *q, |
| 4289 | *swap; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4290 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4291 | ssize_t |
| 4292 | index, |
| 4293 | swap_index; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4294 | |
cristy | 6b36c94 | 2013-02-17 00:36:24 +0000 | [diff] [blame] | 4295 | index=(-1); |
| 4296 | swap_index=(-2); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4297 | if (IfNormalOp) { |
| 4298 | GeometryInfo |
| 4299 | geometry_info; |
| 4300 | |
| 4301 | MagickStatusType |
| 4302 | flags; |
| 4303 | |
| 4304 | swap_index=(-1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4305 | flags=ParseGeometry(arg1,&geometry_info); |
cristy | 90fbd1c | 2013-02-17 00:35:35 +0000 | [diff] [blame] | 4306 | if ((flags & RhoValue) == 0) |
anthony | b1e21ed | 2012-04-20 12:43:12 +0000 | [diff] [blame] | 4307 | CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4308 | index=(ssize_t) geometry_info.rho; |
| 4309 | if ((flags & SigmaValue) != 0) |
| 4310 | swap_index=(ssize_t) geometry_info.sigma; |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4311 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4312 | p=GetImageFromList(_images,index); |
| 4313 | q=GetImageFromList(_images,swap_index); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4314 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) { |
| 4315 | if (IfNormalOp) |
| 4316 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1) |
| 4317 | else |
| 4318 | CLIWandExceptionBreak(OptionError,"TwoOrMoreImagesRequired",option); |
| 4319 | } |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4320 | if (p == q) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4321 | CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1); |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 4322 | swap=CloneImage(p,0,0,MagickTrue,_exception); |
| 4323 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); |
| 4324 | ReplaceImageInList(&q,swap); |
| 4325 | _images=GetFirstImageInList(q); |
| 4326 | break; |
| 4327 | } |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4328 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4329 | } |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4330 | default: |
anthony | ebb73a2 | 2012-03-22 14:25:52 +0000 | [diff] [blame] | 4331 | CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4332 | } |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4333 | |
| 4334 | /* clean up percent escape interpreted strings */ |
| 4335 | if (arg1 != arg1n ) |
| 4336 | arg1=DestroyString((char *)arg1); |
| 4337 | if (arg2 != arg2n ) |
| 4338 | arg2=DestroyString((char *)arg2); |
| 4339 | |
| 4340 | /* if new image list generated, replace existing image list */ |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4341 | if (new_images == (Image *) NULL) |
cristy | 6398ec7 | 2013-11-28 02:00:27 +0000 | [diff] [blame] | 4342 | return(status == 0 ? MagickFalse : MagickTrue); |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4343 | _images=DestroyImageList(_images); |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4344 | _images=GetFirstImageInList(new_images); |
cristy | 6398ec7 | 2013-11-28 02:00:27 +0000 | [diff] [blame] | 4345 | return(status == 0 ? MagickFalse : MagickTrue); |
anthony | 31f1bf7 | 2012-01-30 12:37:22 +0000 | [diff] [blame] | 4346 | |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4347 | #undef _image_info |
| 4348 | #undef _images |
| 4349 | #undef _exception |
| 4350 | #undef _draw_info |
| 4351 | #undef _quantize_info |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4352 | #undef IfNormalOp |
| 4353 | #undef IfPlusOp |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4354 | #undef IsNormalOp |
anthony | 805a2d4 | 2011-09-25 08:25:12 +0000 | [diff] [blame] | 4355 | } |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4356 | |
| 4357 | /* |
| 4358 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4359 | % % |
| 4360 | % % |
| 4361 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4362 | + C L I N o I m a g e O p e r a t i o n s % |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4363 | % % |
| 4364 | % % |
| 4365 | % % |
| 4366 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4367 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4368 | % CLINoImageOperator() Applies operations that may not actually need images |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4369 | % in an image list. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4370 | % |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4371 | % The classic operators of this type is "-read", which actually creates |
| 4372 | % images even when no images are present. Or image stack operators, which |
| 4373 | % can be applied (push or pop) to an empty image list. |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 4374 | % |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4375 | % Note that these operators may involve other special 'option' prefix |
| 4376 | % characters other than '-' or '+', namely parenthesis and braces. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4377 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4378 | % The format of the CLINoImageOption method is: |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4379 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4380 | % void CLINoImageOption(MagickCLI *cli_wand,const char *option, |
| 4381 | % const char *arg1, const char *arg2) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4382 | % |
| 4383 | % A description of each parameter follows: |
| 4384 | % |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4385 | % o cli_wand: the main CLI Wand to use. (sometimes not required) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4386 | % |
| 4387 | % o option: The special option (with any switch char) to process |
| 4388 | % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4389 | % o arg1 & arg2: Argument for option, if required |
| 4390 | % Currently arg2 is not used. |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4391 | % |
| 4392 | */ |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 4393 | WandPrivate void CLINoImageOperator(MagickCLI *cli_wand, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4394 | const char *option,const char *arg1n,const char *arg2n) |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4395 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4396 | const char /* percent escaped versions of the args */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4397 | *arg1, |
| 4398 | *arg2; |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4399 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4400 | #define _image_info (cli_wand->wand.image_info) |
| 4401 | #define _images (cli_wand->wand.images) |
| 4402 | #define _exception (cli_wand->wand.exception) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4403 | #define _process_flags (cli_wand->process_flags) |
| 4404 | #define _option_type ((CommandOptionFlags) cli_wand->command->flags) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4405 | #define IfNormalOp (*option=='-') |
| 4406 | #define IfPlusOp (*option!='-') |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4407 | |
| 4408 | assert(cli_wand != (MagickCLI *) NULL); |
| 4409 | assert(cli_wand->signature == WandSignature); |
| 4410 | assert(cli_wand->wand.signature == WandSignature); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4411 | |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 4412 | if (IfMagickTrue(cli_wand->wand.debug)) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4413 | (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), |
| 4414 | "- NoImage Operator: %s \"%s\" \"%s\"", option,arg1n,arg2n); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4415 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4416 | arg1 = arg1n; |
| 4417 | arg2 = arg2n; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4418 | |
| 4419 | /* Interpret Percent Escapes in Arguments - using first image */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4420 | if ( (((_process_flags & ProcessInterpretProperities) != 0 ) |
| 4421 | || ((_option_type & AlwaysInterpretArgsFlag) != 0) |
| 4422 | ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { |
| 4423 | /* Interpret Percent escapes in argument 1 */ |
| 4424 | if (arg1n != (char *) NULL) { |
| 4425 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 4426 | if (arg1 == (char *) NULL) { |
| 4427 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 4428 | arg1=arg1n; /* use the given argument as is */ |
| 4429 | } |
| 4430 | } |
| 4431 | if (arg2n != (char *) NULL) { |
| 4432 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4433 | if (arg2 == (char *) NULL) { |
| 4434 | CLIWandException(OptionWarning,"InterpretPropertyFailure",option); |
| 4435 | arg2=arg2n; /* use the given argument as is */ |
| 4436 | } |
| 4437 | } |
| 4438 | } |
| 4439 | #undef _process_flags |
| 4440 | #undef _option_type |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4441 | |
| 4442 | do { /* break to exit code */ |
| 4443 | /* |
| 4444 | No-op options (ignore these) |
| 4445 | */ |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4446 | if (LocaleCompare("noop",option+1) == 0) /* zero argument */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4447 | break; |
| 4448 | if (LocaleCompare("sans",option+1) == 0) /* one argument */ |
| 4449 | break; |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4450 | if (LocaleCompare("sans0",option+1) == 0) /* zero argument */ |
| 4451 | break; |
| 4452 | if (LocaleCompare("sans1",option+1) == 0) /* one argument */ |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4453 | break; |
| 4454 | if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ |
| 4455 | break; |
| 4456 | /* |
| 4457 | Image Reading |
| 4458 | */ |
| 4459 | if ( ( LocaleCompare("read",option+1) == 0 ) || |
| 4460 | ( LocaleCompare("--",option) == 0 ) ) { |
| 4461 | /* Do Glob filename Expansion for 'arg1' then read all images. |
| 4462 | * |
| 4463 | * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring |
| 4464 | * (but attaching to the filenames in the generated argument list) any |
| 4465 | * [...] read modifiers that may be present. |
| 4466 | * |
| 4467 | * For example: It will expand '*.gif[20x20]' into a list such as |
| 4468 | * 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]' |
| 4469 | * |
| 4470 | * NOTE: In IMv6 this was done globally across all images. This |
| 4471 | * meant you could include IM options in '@filename' lists, but you |
| 4472 | * could not include comments. Doing it only for image read makes |
| 4473 | * it far more secure. |
| 4474 | * |
| 4475 | * Note: arguments do not have percent escapes expanded for security |
| 4476 | * reasons. |
| 4477 | */ |
| 4478 | int argc; |
| 4479 | char **argv; |
| 4480 | ssize_t i; |
| 4481 | |
| 4482 | argc = 1; |
| 4483 | argv = (char **) &arg1; |
| 4484 | |
| 4485 | /* Expand 'glob' expressions in the given filename. |
| 4486 | Expansion handles any 'coder:' prefix, or read modifiers attached |
| 4487 | to the filename, including them in the resulting expanded list. |
| 4488 | */ |
| 4489 | if (IfMagickFalse( ExpandFilenames(&argc,&argv) )) |
| 4490 | CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed", |
| 4491 | option,GetExceptionMessage(errno)); |
| 4492 | |
| 4493 | /* loop over expanded filename list, and read then all in */ |
| 4494 | for (i=0; i<argc; i++) { |
| 4495 | Image * |
| 4496 | new_images; |
| 4497 | if (IfMagickTrue(_image_info->ping)) |
| 4498 | new_images=PingImages(_image_info,argv[i],_exception); |
| 4499 | else |
| 4500 | new_images=ReadImages(_image_info,argv[i],_exception); |
| 4501 | AppendImageToList(&_images, new_images); |
| 4502 | } |
| 4503 | argv=DestroyStringList(argv); /* Destroy the Expanded Filename list */ |
| 4504 | break; |
| 4505 | } |
| 4506 | /* |
| 4507 | Image Writing |
| 4508 | Note: Writing a empty image list is valid in specific cases |
| 4509 | */ |
| 4510 | if (LocaleCompare("write",option+1) == 0) { |
| 4511 | /* Note: arguments do not have percent escapes expanded */ |
| 4512 | char |
| 4513 | key[MaxTextExtent]; |
| 4514 | |
| 4515 | Image |
| 4516 | *write_images; |
| 4517 | |
| 4518 | ImageInfo |
| 4519 | *write_info; |
| 4520 | |
| 4521 | /* Need images, unless a "null:" output coder is used */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4522 | if ( _images == (Image *) NULL ) { |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4523 | if ( LocaleCompare(arg1,"null:") == 0 ) |
| 4524 | break; |
| 4525 | CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1); |
| 4526 | } |
| 4527 | |
| 4528 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); |
| 4529 | (void) DeleteImageRegistry(key); |
| 4530 | write_images=_images; |
| 4531 | if (IfPlusOp) |
| 4532 | write_images=CloneImageList(_images,_exception); |
| 4533 | write_info=CloneImageInfo(_image_info); |
| 4534 | (void) WriteImages(write_info,write_images,arg1,_exception); |
| 4535 | write_info=DestroyImageInfo(write_info); |
| 4536 | if (IfPlusOp) |
| 4537 | write_images=DestroyImageList(write_images); |
| 4538 | break; |
| 4539 | } |
| 4540 | /* |
| 4541 | Parenthesis and Brace operations |
| 4542 | */ |
| 4543 | if (LocaleCompare("(",option) == 0) { |
| 4544 | /* stack 'push' images */ |
| 4545 | Stack |
| 4546 | *node; |
| 4547 | |
| 4548 | size_t |
| 4549 | size; |
| 4550 | |
| 4551 | size=0; |
| 4552 | node=cli_wand->image_list_stack; |
| 4553 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4554 | size++; |
| 4555 | if ( size >= MAX_STACK_DEPTH ) |
| 4556 | CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option); |
| 4557 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4558 | if (node == (Stack *) NULL) |
| 4559 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 4560 | "MemoryAllocationFailed",option); |
| 4561 | node->data = (void *)cli_wand->wand.images; |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4562 | node->next = cli_wand->image_list_stack; |
| 4563 | cli_wand->image_list_stack = node; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4564 | cli_wand->wand.images = NewImageList(); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4565 | |
| 4566 | /* handle respect-parenthesis */ |
| 4567 | if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info, |
| 4568 | "respect-parenthesis")))) |
| 4569 | option="{"; /* fall-thru so as to push image settings too */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4570 | else |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4571 | break; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4572 | /* fall thru to operation */ |
anthony | 52bef75 | 2012-03-27 13:54:47 +0000 | [diff] [blame] | 4573 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4574 | if (LocaleCompare("{",option) == 0) { |
| 4575 | /* stack 'push' of image_info settings */ |
| 4576 | Stack |
| 4577 | *node; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4578 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4579 | size_t |
| 4580 | size; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4581 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4582 | size=0; |
| 4583 | node=cli_wand->image_info_stack; |
| 4584 | for ( ; node != (Stack *)NULL; node=node->next) |
| 4585 | size++; |
| 4586 | if ( size >= MAX_STACK_DEPTH ) |
| 4587 | CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option); |
| 4588 | node=(Stack *) AcquireMagickMemory(sizeof(*node)); |
| 4589 | if (node == (Stack *) NULL) |
| 4590 | CLIWandExceptionBreak(ResourceLimitFatalError, |
| 4591 | "MemoryAllocationFailed",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4592 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4593 | node->data = (void *)cli_wand->wand.image_info; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4594 | node->next = cli_wand->image_info_stack; |
| 4595 | |
| 4596 | cli_wand->image_info_stack = node; |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4597 | cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); |
| 4598 | if (cli_wand->wand.image_info == (ImageInfo *)NULL) { |
| 4599 | CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 4600 | option); |
| 4601 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4602 | node = (Stack *)RelinquishMagickMemory(node); |
| 4603 | break; |
| 4604 | } |
| 4605 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4606 | break; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4607 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4608 | if (LocaleCompare(")",option) == 0) { |
| 4609 | /* pop images from stack */ |
| 4610 | Stack |
| 4611 | *node; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4612 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4613 | node = (Stack *)cli_wand->image_list_stack; |
| 4614 | if ( node == (Stack *)NULL) |
| 4615 | CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option); |
| 4616 | cli_wand->image_list_stack = node->next; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4617 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4618 | AppendImageToList((Image **)&node->data,cli_wand->wand.images); |
| 4619 | cli_wand->wand.images= (Image *)node->data; |
| 4620 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4621 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4622 | /* handle respect-parenthesis - of the previous 'pushed' settings */ |
| 4623 | node = cli_wand->image_info_stack; |
| 4624 | if ( node != (Stack *)NULL) |
| 4625 | { |
| 4626 | if (IfMagickTrue(IsStringTrue(GetImageOption( |
| 4627 | cli_wand->wand.image_info,"respect-parenthesis")))) |
| 4628 | option="}"; /* fall-thru so as to pop image settings too */ |
| 4629 | else |
| 4630 | break; |
| 4631 | } |
| 4632 | else |
| 4633 | break; |
| 4634 | /* fall thru to next if */ |
| 4635 | } |
| 4636 | if (LocaleCompare("}",option) == 0) { |
| 4637 | /* pop image_info settings from stack */ |
| 4638 | Stack |
| 4639 | *node; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4640 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4641 | node = (Stack *)cli_wand->image_info_stack; |
| 4642 | if ( node == (Stack *)NULL) |
| 4643 | CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option); |
| 4644 | cli_wand->image_info_stack = node->next; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4645 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4646 | (void) DestroyImageInfo(cli_wand->wand.image_info); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4647 | cli_wand->wand.image_info = (ImageInfo *)node->data; |
| 4648 | node = (Stack *)RelinquishMagickMemory(node); |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4649 | |
| 4650 | GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); |
| 4651 | cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); |
| 4652 | cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); |
| 4653 | |
| 4654 | break; |
| 4655 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4656 | if (LocaleCompare("print",option+1) == 0) |
| 4657 | { |
| 4658 | (void) FormatLocaleFile(stdout,"%s",arg1); |
| 4659 | break; |
| 4660 | } |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4661 | if (LocaleCompare("set",option+1) == 0) |
| 4662 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4663 | /* Settings are applied to each image in memory in turn (if any). |
| 4664 | While a option: only need to be applied once globally. |
| 4665 | |
| 4666 | NOTE: rguments have not been automatically percent expaneded |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4667 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4668 | |
| 4669 | /* escape the 'key' once only, using first image. */ |
| 4670 | arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); |
| 4671 | if (arg1 == (char *) NULL) |
| 4672 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 4673 | option); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4674 | |
| 4675 | if (LocaleNCompare(arg1,"registry:",9) == 0) |
| 4676 | { |
| 4677 | if (IfPlusOp) |
| 4678 | { |
| 4679 | (void) DeleteImageRegistry(arg1+9); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4680 | arg1=DestroyString((char *)arg1); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4681 | break; |
| 4682 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4683 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4684 | if (arg2 == (char *) NULL) { |
| 4685 | arg1=DestroyString((char *)arg1); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4686 | CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", |
| 4687 | option); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4688 | } |
| 4689 | (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception); |
| 4690 | arg1=DestroyString((char *)arg1); |
| 4691 | arg2=DestroyString((char *)arg2); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4692 | break; |
| 4693 | } |
| 4694 | if (LocaleNCompare(arg1,"option:",7) == 0) |
| 4695 | { |
| 4696 | /* delete equivelent artifact from all images (if any) */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4697 | if (_images != (Image *)NULL) |
| 4698 | { |
| 4699 | MagickResetIterator(&cli_wand->wand); |
| 4700 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
| 4701 | (void) DeleteImageArtifact(_images,arg1+7); |
| 4702 | MagickResetIterator(&cli_wand->wand); |
| 4703 | } |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4704 | /* now set/delete the global option as needed */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4705 | /* FUTURE: make escapes in a global 'option:' delayed */ |
| 4706 | arg2=(char *)NULL; |
| 4707 | if (IfNormalOp) |
| 4708 | { |
| 4709 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4710 | if (arg2 == (char *) NULL) |
| 4711 | CLIWandExceptionBreak(OptionWarning, |
| 4712 | "InterpretPropertyFailure",option); |
| 4713 | } |
| 4714 | (void) SetImageOption(_image_info,arg1+7,arg2); |
| 4715 | arg1=DestroyString((char *)arg1); |
| 4716 | arg2=DestroyString((char *)arg2); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4717 | break; |
| 4718 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4719 | /* Set Artifacts/Properties/Attributes all images (required) */ |
| 4720 | if ( _images == (Image *) NULL ) |
| 4721 | CLIWandExceptArgBreak(OptionWarning,"NoImageForProperty",option,arg1); |
| 4722 | |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4723 | MagickResetIterator(&cli_wand->wand); |
| 4724 | while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) ) |
| 4725 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4726 | arg2=(char *)NULL; |
| 4727 | if (IfNormalOp) |
| 4728 | { |
| 4729 | arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); |
| 4730 | if (arg2 == (char *) NULL) |
| 4731 | CLIWandExceptionBreak(OptionWarning, |
| 4732 | "InterpretPropertyFailure",option); |
| 4733 | } |
| 4734 | if (LocaleNCompare(arg1,"artifact:",9) == 0) |
| 4735 | (void) SetImageArtifact(_images,arg1+9,arg2); |
| 4736 | else if (LocaleNCompare(arg1,"property:",9) == 0) |
| 4737 | (void) SetImageProperty(_images,arg1+9,arg2,_exception); |
| 4738 | else |
| 4739 | (void) SetImageProperty(_images,arg1,arg2,_exception); |
| 4740 | arg2=DestroyString((char *)arg2); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4741 | } |
| 4742 | MagickResetIterator(&cli_wand->wand); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4743 | arg1=DestroyString((char *)arg1); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4744 | break; |
| 4745 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4746 | if (LocaleCompare("clone",option+1) == 0) { |
| 4747 | Image |
| 4748 | *new_images; |
| 4749 | |
| 4750 | if (*option == '+') |
| 4751 | arg1="-1"; |
| 4752 | if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse))) |
| 4753 | CLIWandExceptionBreak(OptionError,"InvalidArgument",option); |
| 4754 | if ( cli_wand->image_list_stack == (Stack *)NULL) |
| 4755 | CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); |
| 4756 | new_images = (Image *)cli_wand->image_list_stack->data; |
| 4757 | if (new_images == (Image *) NULL) |
| 4758 | CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); |
| 4759 | new_images=CloneImages(new_images,arg1,_exception); |
| 4760 | if (new_images == (Image *) NULL) |
| 4761 | CLIWandExceptionBreak(OptionError,"NoSuchImage",option); |
| 4762 | AppendImageToList(&_images,new_images); |
| 4763 | break; |
| 4764 | } |
| 4765 | /* |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4766 | Informational Operations. |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4767 | |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4768 | Note that these do not require either a cli-wand or images! |
| 4769 | Though currently a cli-wand much be provided regardless. |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4770 | */ |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4771 | if (LocaleCompare("version",option+1) == 0) |
| 4772 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 4773 | ListMagickVersion(stdout); |
cristy | 422d550 | 2012-12-22 22:20:57 +0000 | [diff] [blame] | 4774 | break; |
| 4775 | } |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4776 | if (LocaleCompare("list",option+1) == 0) { |
| 4777 | /* |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 4778 | FUTURE: This 'switch' should really be part of MagickCore |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4779 | */ |
| 4780 | ssize_t |
| 4781 | list; |
| 4782 | |
| 4783 | list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); |
| 4784 | if ( list < 0 ) { |
| 4785 | CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); |
| 4786 | break; |
| 4787 | } |
| 4788 | switch (list) |
| 4789 | { |
| 4790 | case MagickCoderOptions: |
| 4791 | { |
| 4792 | (void) ListCoderInfo((FILE *) NULL,_exception); |
| 4793 | break; |
| 4794 | } |
| 4795 | case MagickColorOptions: |
| 4796 | { |
| 4797 | (void) ListColorInfo((FILE *) NULL,_exception); |
| 4798 | break; |
| 4799 | } |
| 4800 | case MagickConfigureOptions: |
| 4801 | { |
| 4802 | (void) ListConfigureInfo((FILE *) NULL,_exception); |
| 4803 | break; |
| 4804 | } |
| 4805 | case MagickDelegateOptions: |
| 4806 | { |
| 4807 | (void) ListDelegateInfo((FILE *) NULL,_exception); |
| 4808 | break; |
| 4809 | } |
| 4810 | case MagickFontOptions: |
| 4811 | { |
| 4812 | (void) ListTypeInfo((FILE *) NULL,_exception); |
| 4813 | break; |
| 4814 | } |
| 4815 | case MagickFormatOptions: |
| 4816 | (void) ListMagickInfo((FILE *) NULL,_exception); |
| 4817 | break; |
| 4818 | case MagickLocaleOptions: |
| 4819 | (void) ListLocaleInfo((FILE *) NULL,_exception); |
| 4820 | break; |
| 4821 | case MagickLogOptions: |
| 4822 | (void) ListLogInfo((FILE *) NULL,_exception); |
| 4823 | break; |
| 4824 | case MagickMagicOptions: |
| 4825 | (void) ListMagicInfo((FILE *) NULL,_exception); |
| 4826 | break; |
| 4827 | case MagickMimeOptions: |
| 4828 | (void) ListMimeInfo((FILE *) NULL,_exception); |
| 4829 | break; |
| 4830 | case MagickModuleOptions: |
| 4831 | (void) ListModuleInfo((FILE *) NULL,_exception); |
| 4832 | break; |
| 4833 | case MagickPolicyOptions: |
| 4834 | (void) ListPolicyInfo((FILE *) NULL,_exception); |
| 4835 | break; |
| 4836 | case MagickResourceOptions: |
| 4837 | (void) ListMagickResourceInfo((FILE *) NULL,_exception); |
| 4838 | break; |
| 4839 | case MagickThresholdOptions: |
| 4840 | (void) ListThresholdMaps((FILE *) NULL,_exception); |
| 4841 | break; |
| 4842 | default: |
| 4843 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
| 4844 | _exception); |
| 4845 | break; |
| 4846 | } |
| 4847 | break; |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4848 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4849 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4850 | CLIWandException(OptionError,"UnrecognizedOption",option); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4851 | |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 4852 | DisableMSCWarning(4127) |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4853 | } while (0); /* break to exit code. */ |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 4854 | RestoreMSCWarning |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4855 | |
anthony | 4837ac2 | 2012-05-18 23:39:48 +0000 | [diff] [blame] | 4856 | /* clean up percent escape interpreted strings */ |
| 4857 | if (arg1 != arg1n ) |
| 4858 | arg1=DestroyString((char *)arg1); |
| 4859 | if (arg2 != arg2n ) |
| 4860 | arg2=DestroyString((char *)arg2); |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4861 | |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4862 | #undef _image_info |
| 4863 | #undef _images |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 4864 | #undef _exception |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 4865 | #undef IfNormalOp |
| 4866 | #undef IfPlusOp |
anthony | 43f425d | 2012-02-26 12:58:58 +0000 | [diff] [blame] | 4867 | } |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4868 | |
| 4869 | /* |
| 4870 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4871 | % % |
| 4872 | % % |
| 4873 | % % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4874 | + C L I O p t i o n % |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4875 | % % |
| 4876 | % % |
| 4877 | % % |
| 4878 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4879 | % |
| 4880 | % CLIOption() Processes the given option using the given CLI Magick Wand. |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4881 | % The option arguments can be variable in number, though at this time no more |
| 4882 | % that two is actually used by any option (this may change). Excess options |
| 4883 | % are simply ignored. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4884 | % |
| 4885 | % If the cli_wand->command pointer is non-null, then it is assumed that the |
| 4886 | % option has already been search for up from the CommandOptions[] table in |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4887 | % "MagickCore/options.c" using GetCommandOptionInfo(). If not set this |
| 4888 | % routine will do the lookup instead. The pointer is reset afterward. |
| 4889 | % |
| 4890 | % This action allows the caller to lookup and pre-handle any 'special' |
| 4891 | % options, (such as implicit reads) before calling this general option |
| 4892 | % handler to deal with 'standard' command line options. |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4893 | % |
| 4894 | % The format of the CLIOption method is: |
| 4895 | % |
| 4896 | % void CLIOption(MagickCLI *cli_wand,const char *option, ...) |
| 4897 | % |
| 4898 | % A description of each parameter follows: |
| 4899 | % |
| 4900 | % o cli_wand: the main CLI Wand to use. |
| 4901 | % |
| 4902 | % o option: The special option (with any switch char) to process |
| 4903 | % |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4904 | % o args: any required arguments for an option (variable number) |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4905 | % |
| 4906 | % Example Usage... |
| 4907 | % |
| 4908 | % CLIoption(cli_wand,"-read","rose:"); |
| 4909 | % CLIoption(cli_wand,"-virtual-pixel","transparent"); |
| 4910 | % CLIoption(cli_wand,"-distort","SRT:","30"); |
| 4911 | % CLIoption(cli_wand,"-write","rotated_rose.png"); |
| 4912 | % |
| 4913 | */ |
| 4914 | WandExport void CLIOption(MagickCLI *cli_wand,const char *option,...) |
| 4915 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4916 | const char /* extracted option args from args */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4917 | *arg1, |
| 4918 | *arg2; |
| 4919 | |
| 4920 | CommandOptionFlags |
| 4921 | option_type; |
| 4922 | |
| 4923 | assert(cli_wand != (MagickCLI *) NULL); |
| 4924 | assert(cli_wand->signature == WandSignature); |
| 4925 | assert(cli_wand->wand.signature == WandSignature); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4926 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4927 | do { /* Break Code Block for error handling */ |
| 4928 | |
| 4929 | /* get information about option */ |
| 4930 | if ( cli_wand->command == (const OptionInfo *) NULL ) |
| 4931 | cli_wand->command = GetCommandOptionInfo(option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4932 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4933 | (void) FormatLocaleFile(stderr, "CLIOption \"%s\" matched \"%s\"\n", |
| 4934 | option, cli_wand->command->mnemonic ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4935 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4936 | option_type=(CommandOptionFlags) cli_wand->command->flags; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4937 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4938 | if ( option_type == UndefinedOptionFlag ) |
| 4939 | CLIWandExceptionReturn(OptionFatalError,"UnrecognizedOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4940 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4941 | assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4942 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4943 | /* depreciated options */ |
| 4944 | if ( (option_type & DeprecateOptionFlag) != 0 ) |
| 4945 | CLIWandExceptionBreak(OptionError,"DeprecatedOptionNoCode",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4946 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4947 | /* options that this module does not handle */ |
| 4948 | if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) |
| 4949 | CLIWandExceptionBreak(OptionFatalError,"InvalidUseOfOption",option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4950 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4951 | /* Get argument strings from VarArgs |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4952 | How can you determine if enough arguments was supplied? |
| 4953 | What happens if not enough arguments were supplied? |
| 4954 | */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4955 | { size_t |
| 4956 | count = cli_wand->command->type; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4957 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4958 | va_list |
| 4959 | operands; |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4960 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4961 | va_start(operands,option); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4962 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4963 | arg1=arg2=NULL; |
| 4964 | if ( count >= 1 ) |
| 4965 | arg1=(const char *) va_arg(operands, const char *); |
| 4966 | if ( count >= 2 ) |
| 4967 | arg2=(const char *) va_arg(operands, const char *); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4968 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4969 | va_end(operands); |
anthony | 52cb3df | 2012-04-24 03:29:32 +0000 | [diff] [blame] | 4970 | #if 0 |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4971 | (void) FormatLocaleFile(stderr, |
| 4972 | "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n", |
| 4973 | option,(long) count,option_type,arg1,arg2); |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 4974 | #endif |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 4975 | } |
| 4976 | |
| 4977 | /* |
| 4978 | Call the appropriate option handler |
| 4979 | */ |
| 4980 | |
| 4981 | /* FUTURE: this is temporary - get 'settings' to handle distribution of |
| 4982 | settings to images attributes,proprieties,artifacts */ |
| 4983 | if ( cli_wand->wand.images != (Image *)NULL ) |
| 4984 | SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, |
| 4985 | cli_wand->wand.exception); |
| 4986 | |
| 4987 | if ( (option_type & SettingOptionFlags) != 0 ) { |
| 4988 | CLISettingOptionInfo(cli_wand, option, arg1, arg2); |
| 4989 | // FUTURE: Sync Specific Settings into Image Properities (not global) |
| 4990 | } |
| 4991 | |
| 4992 | /* Operators that do not need images - read, write, stack, clone */ |
| 4993 | if ( (option_type & NoImageOperatorFlag) != 0) |
| 4994 | CLINoImageOperator(cli_wand, option, arg1, arg2); |
| 4995 | |
| 4996 | /* FUTURE: The not a setting part below is a temporary hack due to |
| 4997 | * some options being both a Setting and a Simple operator. |
| 4998 | * Specifically -monitor, -depth, and -colorspace */ |
| 4999 | if ( cli_wand->wand.images == (Image *)NULL ) |
| 5000 | if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) && |
| 5001 | ((option_type & SettingOptionFlags) == 0 )) /* temp hack */ |
| 5002 | CLIWandExceptionBreak(OptionError,"NoImagesFound",option); |
| 5003 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 5004 | /* Operators which loop of individual images, simply */ |
| 5005 | if ( (option_type & SimpleOperatorFlag) != 0 && |
| 5006 | cli_wand->wand.images != (Image *)NULL) /* temp hack */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 5007 | CLISimpleOperatorImages(cli_wand, option, arg1, arg2); |
| 5008 | |
| 5009 | /* Operators that work on the image list as a whole */ |
| 5010 | if ( (option_type & ListOperatorFlag) != 0 ) |
| 5011 | CLIListOperatorImages(cli_wand, option, arg1, arg2); |
| 5012 | |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 5013 | DisableMSCWarning(4127) |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 5014 | } while (0); /* end Break code block */ |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 5015 | RestoreMSCWarning |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 5016 | |
| 5017 | cli_wand->command = (const OptionInfo *) NULL; /* prevent re-use later */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 5018 | } |