blob: 205665f312544cb89ead33e4da63ea5d3afcda40 [file] [log] [blame]
anthony805a2d42011-09-25 08:25:12 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% OOO PPPP EEEE RRRR AA TTTTTT III OOO N N %
7% O O P P E R R A A TT I O O NN N %
8% O O PPPP EEE RRRR AAAA TT I O O N N N %
9% O O P E R R A A TT I O O N NN %
10% OOO P EEEE R RR A A TT III OOO N N %
11% %
12% %
13% MagickWand Module Methods %
14% %
15% Software Design %
16% John Cristy %
cristy0a0ca4f2011-09-28 01:15:28 +000017% September 2011 %
anthony805a2d42011-09-25 08:25:12 +000018% %
19% %
20% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
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
37% the given image(s) according to the current "image_info" and "draw_info"
38% settings.
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%
44% Anthony Thyssen, Sept 2011
45*/
cristyc689f1f2011-10-05 21:13:24 +000046#if 0
anthony805a2d42011-09-25 08:25:12 +000047
48/*
49 Include declarations.
50*/
51#include "MagickWand/studio.h"
52#include "MagickWand/MagickWand.h"
53#include "MagickWand/mogrify-private.h"
54#include "MagickCore/monitor-private.h"
55#include "MagickCore/thread-private.h"
56#include "MagickCore/string-private.h"
57
58/*
59 Define declarations.
60*/
61#define UndefinedCompressionQuality 0UL
62/*
63 Constant declaration. (temporary exports)
64*/
65static const char
66 BackgroundColor[] = "#fff", /* white */
67 BorderColor[] = "#dfdfdf", /* gray */
68 MatteColor[] = "#bdbdbd"; /* gray */
69
70/*
71** Function to report on the progress of image operations
72*/
73static MagickBooleanType MonitorProgress(const char *text,
74 const MagickOffsetType offset,const MagickSizeType extent,
75 void *wand_unused(client_data))
76{
77 char
78 message[MaxTextExtent],
79 tag[MaxTextExtent];
80
81 const char
82 *locale_message;
83
84 register char
85 *p;
86
87 if (extent < 2)
88 return(MagickTrue);
89 (void) CopyMagickMemory(tag,text,MaxTextExtent);
90 p=strrchr(tag,'/');
91 if (p != (char *) NULL)
92 *p='\0';
93 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
94 locale_message=GetLocaleMessage(message);
95 if (locale_message == message)
96 locale_message=tag;
97 if (p == (char *) NULL)
98 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
99 locale_message,(long) offset,(unsigned long) extent,(long)
100 (100L*offset/(extent-1)));
101 else
102 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
103 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
104 (100L*offset/(extent-1)));
105 if (offset == (MagickOffsetType) (extent-1))
106 (void) FormatLocaleFile(stderr,"\n");
107 (void) fflush(stderr);
108 return(MagickTrue);
109}
110
111/*
112** GetImageCache() will read an image into a image cache if not already
113** present then return the image that is in the cache under that filename.
114*/
115static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
116 ExceptionInfo *exception)
117{
118 char
119 key[MaxTextExtent];
120
121 ExceptionInfo
122 *sans_exception;
123
124 Image
125 *image;
126
127 ImageInfo
128 *read_info;
129
130 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
131 sans_exception=AcquireExceptionInfo();
132 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
133 sans_exception=DestroyExceptionInfo(sans_exception);
134 if (image != (Image *) NULL)
135 return(image);
136 read_info=CloneImageInfo(image_info);
137 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
138 image=ReadImage(read_info,exception);
139 read_info=DestroyImageInfo(read_info);
140 if (image != (Image *) NULL)
141 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
142 return(image);
143}
144
145/*
anthonya89dd172011-10-04 13:29:35 +0000146 SparseColorOption() parse the complex -sparse-color argument into an
147 an array of floating point values than call SparseColorImage().
148 Argument is a complex mix of floating-point pixel coodinates, and color
149 specifications (or direct floating point numbers). The number of floats
150 needed to represent a color varies depending on teh current channel
151 setting.
anthony805a2d42011-09-25 08:25:12 +0000152*/
153static Image *SparseColorOption(const Image *image,
154 const SparseColorMethod method,const char *arguments,
155 const MagickBooleanType color_from_image,ExceptionInfo *exception)
156{
157 char
158 token[MaxTextExtent];
159
160 const char
161 *p;
162
163 double
164 *sparse_arguments;
165
166 Image
167 *sparse_image;
168
169 PixelInfo
170 color;
171
172 MagickBooleanType
173 error;
174
175 register size_t
176 x;
177
178 size_t
179 number_arguments,
180 number_colors;
181
182 assert(image != (Image *) NULL);
183 assert(image->signature == MagickSignature);
184 if (image->debug != MagickFalse)
185 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
186 assert(exception != (ExceptionInfo *) NULL);
187 assert(exception->signature == MagickSignature);
188 /*
189 Limit channels according to image - and add up number of color channel.
190 */
191 number_colors=0;
192 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
193 number_colors++;
194 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
195 number_colors++;
196 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
197 number_colors++;
198 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
199 (image->colorspace == CMYKColorspace))
200 number_colors++;
201 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
202 (image->matte != MagickFalse))
203 number_colors++;
204
205 /*
206 Read string, to determine number of arguments needed,
207 */
208 p=arguments;
209 x=0;
210 while( *p != '\0' )
211 {
212 GetMagickToken(p,&p,token);
213 if ( token[0] == ',' ) continue;
214 if ( isalpha((int) token[0]) || token[0] == '#' ) {
215 if ( color_from_image ) {
216 (void) ThrowMagickException(exception,GetMagickModule(),
217 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
218 "Color arg given, when colors are coming from image");
219 return( (Image *)NULL);
220 }
221 x += number_colors; /* color argument */
222 }
223 else {
224 x++; /* floating point argument */
225 }
226 }
227 error=MagickTrue;
228 if ( color_from_image ) {
229 /* just the control points are being given */
230 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
231 number_arguments=(x/2)*(2+number_colors);
232 }
233 else {
234 /* control points and color values */
235 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
236 number_arguments=x;
237 }
238 if ( error ) {
239 (void) ThrowMagickException(exception,GetMagickModule(),
240 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
241 "Invalid number of Arguments");
242 return( (Image *)NULL);
243 }
244
245 /* Allocate and fill in the floating point arguments */
246 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
247 sizeof(*sparse_arguments));
248 if (sparse_arguments == (double *) NULL) {
249 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
250 "MemoryAllocationFailed","%s","SparseColorOption");
251 return( (Image *)NULL);
252 }
253 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
254 sizeof(*sparse_arguments));
255 p=arguments;
256 x=0;
257 while( *p != '\0' && x < number_arguments ) {
258 /* X coordinate */
259 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
260 if ( token[0] == '\0' ) break;
261 if ( isalpha((int) token[0]) || token[0] == '#' ) {
262 (void) ThrowMagickException(exception,GetMagickModule(),
263 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
264 "Color found, instead of X-coord");
265 error = MagickTrue;
266 break;
267 }
268 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
269 /* Y coordinate */
270 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
271 if ( token[0] == '\0' ) break;
272 if ( isalpha((int) token[0]) || token[0] == '#' ) {
273 (void) ThrowMagickException(exception,GetMagickModule(),
274 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
275 "Color found, instead of Y-coord");
276 error = MagickTrue;
277 break;
278 }
279 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
280 /* color values for this control point */
281#if 0
282 if ( (color_from_image ) {
283 /* get color from image */
284 /* HOW??? */
285 }
286 else
287#endif
288 {
289 /* color name or function given in string argument */
290 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
291 if ( token[0] == '\0' ) break;
292 if ( isalpha((int) token[0]) || token[0] == '#' ) {
293 /* Color string given */
cristy269c9412011-10-13 23:41:15 +0000294 (void) QueryColorCompliance(token,AllCompliance,&color,
anthonya89dd172011-10-04 13:29:35 +0000295 exception);
anthony805a2d42011-09-25 08:25:12 +0000296 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
297 sparse_arguments[x++] = QuantumScale*color.red;
298 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
299 sparse_arguments[x++] = QuantumScale*color.green;
300 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
301 sparse_arguments[x++] = QuantumScale*color.blue;
302 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
303 (image->colorspace == CMYKColorspace))
304 sparse_arguments[x++] = QuantumScale*color.black;
305 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
306 (image->matte != MagickFalse))
307 sparse_arguments[x++] = QuantumScale*color.alpha;
308 }
309 else {
310 /* Colors given as a set of floating point values - experimental */
311 /* NB: token contains the first floating point value to use! */
312 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
313 {
314 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
315 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
316 break;
317 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
318 token[0] = ','; /* used this token - get another */
319 }
320 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
321 {
322 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
323 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
324 break;
325 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
326 token[0] = ','; /* used this token - get another */
327 }
328 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
329 {
330 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
331 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
332 break;
333 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
334 token[0] = ','; /* used this token - get another */
335 }
336 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
337 (image->colorspace == CMYKColorspace))
338 {
339 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
340 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
341 break;
342 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
343 token[0] = ','; /* used this token - get another */
344 }
345 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
346 (image->matte != MagickFalse))
347 {
348 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
349 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
350 break;
351 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
352 token[0] = ','; /* used this token - get another */
353 }
354 }
355 }
356 }
357 if ( number_arguments != x && !error ) {
358 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
359 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
360 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
361 return( (Image *)NULL);
362 }
363 if ( error )
364 return( (Image *)NULL);
365
366 /* Call the Interpolation function with the parsed arguments */
367 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
368 exception);
369 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
370 return( sparse_image );
371}
372
373/*
374%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
375% %
376% %
377% %
anthony1afdc7a2011-10-05 11:54:28 +0000378+ A p p l y S e t t i n g O p t i o n %
anthony805a2d42011-09-25 08:25:12 +0000379% %
380% %
381% %
382%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383%
anthony1afdc7a2011-10-05 11:54:28 +0000384% ApplySettingOption() saves the given single settings option into a CLI wand
385% holding the image_info, draw_info, quantize_info structures that is later
386% used for reading, processing, and writing images.
anthony805a2d42011-09-25 08:25:12 +0000387%
anthony1afdc7a2011-10-05 11:54:28 +0000388% No image in the wand is actually modified (setting options only)
anthony805a2d42011-09-25 08:25:12 +0000389%
anthony1afdc7a2011-10-05 11:54:28 +0000390% The format of the ApplySettingOption method is:
391%
392% MagickBooleanType ApplySettingOption(MagickWand *wand,
anthony805a2d42011-09-25 08:25:12 +0000393% const int argc, const char **argv,ExceptionInfo *exception)
394%
395% A description of each parameter follows:
396%
anthony1afdc7a2011-10-05 11:54:28 +0000397% o wand: structure holding settings to be applied
anthony805a2d42011-09-25 08:25:12 +0000398%
399% o argc: Specifies a pointer to an integer describing the number of
400% elements in the argument vector.
401%
402% o argv: Specifies a pointer to a text array containing the command line
403% arguments.
404%
405% o exception: return any errors or warnings in this structure.
406%
407*/
anthony74b1cfc2011-10-06 12:44:16 +0000408WandExport MagickBooleanType ApplySettingsOption(ImageInfo *image_info,
cristy0a0ca4f2011-09-28 01:15:28 +0000409 const int argc,const char **argv,ExceptionInfo *exception)
anthony805a2d42011-09-25 08:25:12 +0000410{
411 GeometryInfo
412 geometry_info;
413
anthony1afdc7a2011-10-05 11:54:28 +0000414 ImageInfo
415 *image_info;
416
417 DrawInfo
anthony74b1cfc2011-10-06 12:44:16 +0000418 *draw_info;
419
420 const char
421 *option;
anthony1afdc7a2011-10-05 11:54:28 +0000422
423 assert(wand != (MagickWand *) NULL);
424 assert(wand->signature == WandSignature);
425 assert(wand->draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */
426 assert(wand->quantize_info == (QuantizeInfo *) NULL);
427 if (wand->debug != MagickFalse)
428 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
anthony805a2d42011-09-25 08:25:12 +0000429 if (argc < 0)
430 return(MagickTrue);
anthony1afdc7a2011-10-05 11:54:28 +0000431
anthony74b1cfc2011-10-06 12:44:16 +0000432 option=argv[0]+1;
anthony1afdc7a2011-10-05 11:54:28 +0000433 image_info=wand->image_info;
434 draw_info=wand->_info;
435
anthony74b1cfc2011-10-06 12:44:16 +0000436#define IfSetOption ((*argv[0])=='-')
437
438 switch (*option)
anthony805a2d42011-09-25 08:25:12 +0000439 {
440 case 'a':
441 {
anthony74b1cfc2011-10-06 12:44:16 +0000442 if (LocaleCompare("adjoin",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000443 {
anthony74b1cfc2011-10-06 12:44:16 +0000444 image_info->adjoin = IfSetOption ? MagickTrue : MagickFalse;
anthony805a2d42011-09-25 08:25:12 +0000445 break;
446 }
anthony74b1cfc2011-10-06 12:44:16 +0000447 if (LocaleCompare("affine",option) == 0)
anthony1afdc7a2011-10-05 11:54:28 +0000448 {
anthony74b1cfc2011-10-06 12:44:16 +0000449 if (IfSetOption)
anthony1afdc7a2011-10-05 11:54:28 +0000450 (void) ParseAffineGeometry(argv[1],draw_info->affine,
451 exception);
anthony74b1cfc2011-10-06 12:44:16 +0000452 else
453 GetAffineMatrix(draw_info->affine);
anthony1afdc7a2011-10-05 11:54:28 +0000454 break;
455 }
anthony74b1cfc2011-10-06 12:44:16 +0000456 if (LocaleCompare("antialias",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000457 {
anthony1afdc7a2011-10-05 11:54:28 +0000458 image_info->antialias =
459 draw_info->stroke_antialias =
460 draw_info->text_antialias =
anthony74b1cfc2011-10-06 12:44:16 +0000461 IfSetOption ? MagickTrue : MagickFalse;
anthony805a2d42011-09-25 08:25:12 +0000462 break;
463 }
anthony74b1cfc2011-10-06 12:44:16 +0000464 if (LocaleCompare("authenticate",option) == 0)
anthony5f867ae2011-10-09 10:28:34 +0000465 {
anthony74b1cfc2011-10-06 12:44:16 +0000466 (void) SetImageOption(image_info,option,
anthony6dc09cd2011-10-12 08:56:49 +0000467 IfSetOption ? argv[1] : (const char*)NULL);
anthony805a2d42011-09-25 08:25:12 +0000468 break;
469 }
470 break;
471 }
472 case 'b':
473 {
anthony74b1cfc2011-10-06 12:44:16 +0000474 if (LocaleCompare("background",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000475 {
anthony74b1cfc2011-10-06 12:44:16 +0000476 /* FUTURE: both image_info attribute & ImageOption in use!
477 Note that +background, means fall-back to image attribute
478 so ImageOption is deleted, not set to a default.
479 */
480 if (IfSetOption)
anthony805a2d42011-09-25 08:25:12 +0000481 {
anthony74b1cfc2011-10-06 12:44:16 +0000482 (void) DeleteImageOption(image_info,option);
anthony1afdc7a2011-10-05 11:54:28 +0000483 (void) QueryColorCompliance(BackgroundColor,AllCompliance,
anthony74b1cfc2011-10-06 12:44:16 +0000484 image_info->background_color,exception);
anthony805a2d42011-09-25 08:25:12 +0000485 break;
486 }
anthony74b1cfc2011-10-06 12:44:16 +0000487 (void) SetImageOption(image_info,option,argv[1]);
anthony1afdc7a2011-10-05 11:54:28 +0000488 (void) QueryColorCompliance(argv[1],AllCompliance,
anthony74b1cfc2011-10-06 12:44:16 +0000489 image_info->background_color,exception);
anthony805a2d42011-09-25 08:25:12 +0000490 break;
491 }
anthony74b1cfc2011-10-06 12:44:16 +0000492 if (LocaleCompare("bias",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000493 {
anthony74b1cfc2011-10-06 12:44:16 +0000494 /* FUTURE: bias OBSOLETED, replaced by "convolve:bias"
495 as it is actually rarely used except in direct convolve
496 Usage outside direct convolve is actally non-sensible!
497 */
498 (void) SetImageOption(image_info,option,
499 IfSetOption ? argv[1] : "0");
anthony805a2d42011-09-25 08:25:12 +0000500 break;
501 }
anthony74b1cfc2011-10-06 12:44:16 +0000502 if (LocaleCompare("black-point-compensation",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000503 {
anthony74b1cfc2011-10-06 12:44:16 +0000504 (void) SetImageOption(image_info,option,
505 IfSetOption ? "true" : "false" );
anthony805a2d42011-09-25 08:25:12 +0000506 break;
507 }
anthony74b1cfc2011-10-06 12:44:16 +0000508 if (LocaleCompare("blue-primary",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000509 {
anthony74b1cfc2011-10-06 12:44:16 +0000510 (void) SetImageOption(image_info,option,
511 IfSetOption ? argv[1] : "0" );
anthony805a2d42011-09-25 08:25:12 +0000512 break;
513 }
anthony74b1cfc2011-10-06 12:44:16 +0000514 if (LocaleCompare("bordercolor",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000515 {
anthony74b1cfc2011-10-06 12:44:16 +0000516 /* FUTURE: both image_info attribute & ImageOption in use! */
517 if (IfSetOption)
anthony805a2d42011-09-25 08:25:12 +0000518 {
anthony74b1cfc2011-10-06 12:44:16 +0000519 (void) SetImageOption(image_info,option,argv[1]);
520 (void) QueryColorCompliance(argv[1],AllCompliece,
521 &image_info->border_color,exception);
522 (void) QueryColorCompliance(argv[1],AllCompliance,
523 &draw_info->border_color,exception);
anthony805a2d42011-09-25 08:25:12 +0000524 break;
525 }
anthony74b1cfc2011-10-06 12:44:16 +0000526 (void) DeleteImageOption(image_info,option);
527 (void) QueryColorCompliance(BorderColor,AllCompliance,
528 &image_info->border_color,exception);
529 (void) QueryColorCompliance(BorderColor,AllCompliance,
530 &draw_info->border_color,exception);
anthony805a2d42011-09-25 08:25:12 +0000531 break;
532 }
anthony74b1cfc2011-10-06 12:44:16 +0000533 if (LocaleCompare("box",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000534 {
anthony74b1cfc2011-10-06 12:44:16 +0000535 const char
536 *value = IfSetOption ? argv[1] : "none";
537 (void) SetImageOption(image_info,option,value);
538 (void) QueryColorCompliance(value,AllCompliance,
539 &draw_info->undercolor,exception);
anthony805a2d42011-09-25 08:25:12 +0000540 break;
541 }
542 break;
543 }
544 case 'c':
545 {
anthony74b1cfc2011-10-06 12:44:16 +0000546 if (LocaleCompare("cache",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000547 {
548 MagickSizeType
549 limit;
550
551 limit=MagickResourceInfinity;
552 if (LocaleCompare("unlimited",argv[1]) != 0)
553 limit=(MagickSizeType) SiPrefixToDouble(argv[1],100.0);
554 (void) SetMagickResourceLimit(MemoryResource,limit);
555 (void) SetMagickResourceLimit(MapResource,2*limit);
556 break;
557 }
anthony74b1cfc2011-10-06 12:44:16 +0000558 if (LocaleCompare("caption",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000559 {
anthony74b1cfc2011-10-06 12:44:16 +0000560 (void) SetImageOption(image_info,option,
anthony6dc09cd2011-10-12 08:56:49 +0000561 IfSetOption ? argv[1] : (const char*)NULL);
anthony805a2d42011-09-25 08:25:12 +0000562 break;
563 }
anthony74b1cfc2011-10-06 12:44:16 +0000564 if (LocaleCompare("channel",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000565 {
anthony74b1cfc2011-10-06 12:44:16 +0000566 image_info->channel=(ChannelType) (
567 IfSetOption ? ParseChannelOption(argv[1]) : DefaultChannels );
anthony965524b2011-10-07 12:34:14 +0000568 /* This is also a SimpleImageOperator */
anthony805a2d42011-09-25 08:25:12 +0000569 break;
570 }
anthony74b1cfc2011-10-06 12:44:16 +0000571 if (LocaleCompare("colorspace",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000572 {
anthony965524b2011-10-07 12:34:14 +0000573 /* This is also a SimpleImageOperator */
anthonyd2cdc862011-10-07 14:07:17 +0000574 /* Undefined colorspace means don't modify images */
anthony965524b2011-10-07 12:34:14 +0000575 image_info->colorspace=UndefinedColorspace;
anthonyd2cdc862011-10-07 14:07:17 +0000576 if (IfSetOption)
577 image_info->colorspace=(ColorspaceType) ParseCommandOption(
578 MagickColorspaceOptions,MagickFalse,argv[1])
anthony805a2d42011-09-25 08:25:12 +0000579 break;
580 }
anthony74b1cfc2011-10-06 12:44:16 +0000581 if (LocaleCompare("comment",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000582 {
anthony965524b2011-10-07 12:34:14 +0000583 (void) SetImageOption(image_info,option,
anthony6dc09cd2011-10-12 08:56:49 +0000584 IfSetOption ? argv[1] : (const char*)NULL);
anthony805a2d42011-09-25 08:25:12 +0000585 break;
586 }
anthony74b1cfc2011-10-06 12:44:16 +0000587 if (LocaleCompare("compose",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000588 {
anthony965524b2011-10-07 12:34:14 +0000589 /* FUTURE: What should be used? image_info or ImageOption ???
anthony5f867ae2011-10-09 10:28:34 +0000590 The former is more efficent, but Crisy prefers the latter!
anthony965524b2011-10-07 12:34:14 +0000591 */
anthony5f867ae2011-10-09 10:28:34 +0000592 (void) SetImageOption(image_info,option,
anthony6dc09cd2011-10-12 08:56:49 +0000593 IfSetOption ? argv[1] : (const char*)NULL);
anthony965524b2011-10-07 12:34:14 +0000594 image_info->compose=(CompositeOperator) ParseCommandOption(
anthony5f867ae2011-10-09 10:28:34 +0000595 MagickComposeOptions,MagickFalse,
596 IfSetOption ? argv[1] : "undefined");
anthony805a2d42011-09-25 08:25:12 +0000597 break;
598 }
anthony74b1cfc2011-10-06 12:44:16 +0000599 if (LocaleCompare("compress",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000600 {
anthony5f867ae2011-10-09 10:28:34 +0000601 /* FUTURE: What should be used? image_info or ImageOption ???
602 The former is more efficent, but Crisy prefers the latter!
603
604 The coders appears to use image_info, not Image_Option
605 however the image attribute (for save) is set from the
606 ImageOption!
607 */
608 if (IfSetOption)
anthony805a2d42011-09-25 08:25:12 +0000609 {
anthony5f867ae2011-10-09 10:28:34 +0000610 image_info->compression=(CompressionType) ParseCommandOption(
611 MagickCompressOptions,MagickFalse,argv[1]);
612 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000613 break;
614 }
anthony5f867ae2011-10-09 10:28:34 +0000615 image_info->compression=UndefinedCompression;
616 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +0000617 break;
618 }
619 break;
620 }
621 case 'd':
622 {
anthony74b1cfc2011-10-06 12:44:16 +0000623 if (LocaleCompare("debug",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000624 {
anthony5f867ae2011-10-09 10:28:34 +0000625 if (IfSetOption)
626 (void) SetLogEventMask(IfSetOption?argv[1]:"none");
627 image_info->debug=IsEventLogging(); /* extract logging*/
628 wand->debug=IsEventLogging();
anthony805a2d42011-09-25 08:25:12 +0000629 break;
630 }
anthony74b1cfc2011-10-06 12:44:16 +0000631 if (LocaleCompare("define",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000632 {
anthony5f867ae2011-10-09 10:28:34 +0000633 /* FUTURE both -set and -define sets ImageOption
634 But differs in that -set tried to set image properity (attribute)
635 */
anthony805a2d42011-09-25 08:25:12 +0000636 if (LocaleNCompare(argv[1],"registry:",9) == 0)
637 {
anthony5f867ae2011-10-09 10:28:34 +0000638 if (IfSetOption)
639 (void) DefineImageRegistry(StringRegistryType,argv[1]+9,
640 exception);
641 else
cristyd15e6592011-10-15 00:13:06 +0000642 (void) DefineImageOption(image_info,argv[1],exception);
anthony805a2d42011-09-25 08:25:12 +0000643 break;
644 }
anthony5f867ae2011-10-09 10:28:34 +0000645 if (IfSetOption)
cristyd15e6592011-10-15 00:13:06 +0000646 (void) DefineImageOption(image_info,argv[1],exception);
anthony5f867ae2011-10-09 10:28:34 +0000647 else
cristyd15e6592011-10-15 00:13:06 +0000648 (void) DeleteImageOption(image_info,argv[1],exception);
anthony805a2d42011-09-25 08:25:12 +0000649 break;
650 }
anthony74b1cfc2011-10-06 12:44:16 +0000651 if (LocaleCompare("delay",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000652 {
anthony5f867ae2011-10-09 10:28:34 +0000653 /* transfered to new images only via AcquireImage()
654 -set delay must be used to set attributes directly.
655 */
656 (void) SetImageOption(image_info,option,
657 IfSetOption ? argv[1] : "0");
anthony805a2d42011-09-25 08:25:12 +0000658 break;
659 }
anthony74b1cfc2011-10-06 12:44:16 +0000660 if (LocaleCompare("density",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000661 {
anthony5f867ae2011-10-09 10:28:34 +0000662 /* FUTURE: At this time everyone is using image_info string
663 The Image Option is not being used.
anthony805a2d42011-09-25 08:25:12 +0000664 */
anthony5f867ae2011-10-09 10:28:34 +0000665 if (IsSetOption)
anthony805a2d42011-09-25 08:25:12 +0000666 {
anthony5f867ae2011-10-09 10:28:34 +0000667 (void) CloneString(&image_info->density,argv[1]);
668 (void) CloneString(&draw_info->density,argv[1]);
669 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000670 break;
671 }
anthony5f867ae2011-10-09 10:28:34 +0000672 if (image_info->density != (char *) NULL)
673 image_info->density=DestroyString(image_info->density);
674 if (draw_info->density != (char *) NULL)
675 draw_info->density=DestroyString(draw_info->density);
676 (void) SetImageOption(image_info,option,"72");
anthony805a2d42011-09-25 08:25:12 +0000677 break;
678 }
anthony74b1cfc2011-10-06 12:44:16 +0000679 if (LocaleCompare("depth",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000680 {
anthony5f867ae2011-10-09 10:28:34 +0000681 /* This is also a SimpleImageOperator! */
682 image_info->depth=IsSetOption?StringToUnsignedLong(argv[1])
683 :MAGICKCORE_QUANTUM_DEPTH;
anthony805a2d42011-09-25 08:25:12 +0000684 break;
685 }
anthony74b1cfc2011-10-06 12:44:16 +0000686 if (LocaleCompare("direction",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000687 {
anthony6dc09cd2011-10-12 08:56:49 +0000688 /* Image Option is only used to set draw_info */
anthony5f867ae2011-10-09 10:28:34 +0000689 (void) SetImageOption(image_info,option,
690 IfSetOption ? argv[1] : "undefined");
691 draw_info->direction=(DirectionType) ParseCommandOption(
692 MagickDirectionOptions,MagickFalse,
693 IfSetOption ? argv[1] : "undefined");
anthony805a2d42011-09-25 08:25:12 +0000694 break;
695 }
anthony74b1cfc2011-10-06 12:44:16 +0000696 if (LocaleCompare("display",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000697 {
anthony5f867ae2011-10-09 10:28:34 +0000698 if (IfSetOption)
699 (void) CloneString(&image_info->server_name,argv[1]);
700 else
701 if (image_info->server_name != (char *) NULL)
702 image_info->server_name=DestroyString(image_info->server_name);
anthony805a2d42011-09-25 08:25:12 +0000703 break;
704 }
anthony74b1cfc2011-10-06 12:44:16 +0000705 if (LocaleCompare("dispose",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000706 {
anthony5f867ae2011-10-09 10:28:34 +0000707 (void) SetImageOption(image_info,option,
708 IfSetOption ? argv[1] : "undefined");
anthony805a2d42011-09-25 08:25:12 +0000709 break;
710 }
anthony74b1cfc2011-10-06 12:44:16 +0000711 if (LocaleCompare("dither",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000712 {
anthony5f867ae2011-10-09 10:28:34 +0000713 /* FUTURE: Merge boolean image_info->dither with Dither type */
714 (void) SetImageOption(image_info,option,
715 IfSetOption ? argv[1] : "none");
716 image_info->dither = quantize_info->dither =
anthony6dc09cd2011-10-12 08:56:49 +0000717 IfSetOption ? MagickTrue : MagickFalse;
anthony5f867ae2011-10-09 10:28:34 +0000718 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
anthony6dc09cd2011-10-12 08:56:49 +0000719 MagickDitherOptions,MagickFalse,
720 IfSetOption ? argv[1] : "none");
anthony5f867ae2011-10-09 10:28:34 +0000721 if (quantize_info->dither_method == NoDitherMethod)
anthony6dc09cd2011-10-12 08:56:49 +0000722 image_info->dither = quantize_info->dither = MagickFalse;
anthony805a2d42011-09-25 08:25:12 +0000723 break;
724 }
725 break;
726 }
727 case 'e':
728 {
anthony74b1cfc2011-10-06 12:44:16 +0000729 if (LocaleCompare("encoding",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000730 {
anthony6dc09cd2011-10-12 08:56:49 +0000731 (void) CloneString(&draw_info->encoding,
732 IfSetOption ? argv[1] : "undefined");
733 (void) SetImageOption(image_info,option,&draw_info->encoding);
anthony805a2d42011-09-25 08:25:12 +0000734 break;
735 }
anthony74b1cfc2011-10-06 12:44:16 +0000736 if (LocaleCompare("endian",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000737 {
anthony6dc09cd2011-10-12 08:56:49 +0000738 const char
739 value;
740
741 value=IfSetOption?argv[1]:"undefined";
742 (void) SetImageOption(image_info,option,value);
anthony805a2d42011-09-25 08:25:12 +0000743 image_info->endian=(EndianType) ParseCommandOption(
anthony6dc09cd2011-10-12 08:56:49 +0000744 MagickEndianOptions,MagickFalse,value);
anthony805a2d42011-09-25 08:25:12 +0000745 break;
746 }
anthony74b1cfc2011-10-06 12:44:16 +0000747 if (LocaleCompare("extract",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000748 {
anthony6dc09cd2011-10-12 08:56:49 +0000749 (void) CloneString(&image_info->extract,
750 IfSetOption?argv[1]:(const char *) NULL);
anthony805a2d42011-09-25 08:25:12 +0000751 break;
752 }
753 break;
754 }
755 case 'f':
756 {
anthony6dc09cd2011-10-12 08:56:49 +0000757 if (LocaleCompare("family",argv[0]+1) == 0)
758 {
759 (void) CloneString(&draw_info->family,
760 IfSetOption ? argv[1] : (const char *) NULL);
761 break;
762 }
anthony74b1cfc2011-10-06 12:44:16 +0000763 if (LocaleCompare("fill",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000764 {
anthony6dc09cd2011-10-12 08:56:49 +0000765 const char
766 value;
767
768 ExceptionInfo
769 *sans;
770
771 value = IfSetOption ? argv[1] : "none";
772 (void) SetImageOption(image_info,option,value);
773
774 sans=AcquireExceptionInfo();
anthony6dc09cd2011-10-12 08:56:49 +0000775 status=QueryColorCompliance(value,AllCompliance,&draw_info->fill,sans);
776 sans=DestroyExceptionInfo(sans);
777
778 if (draw_info->fill_pattern != (Image *) NULL)
779 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
780 if (status == MagickFalse)
781 draw_info->fill_pattern=GetImageCache(image_info,value,
782 exception);
anthony805a2d42011-09-25 08:25:12 +0000783 break;
784 }
anthony74b1cfc2011-10-06 12:44:16 +0000785 if (LocaleCompare("filter",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000786 {
anthony6dc09cd2011-10-12 08:56:49 +0000787 (void) SetImageOption(image_info,option,
788 IfSetOption ? argv[1] : "undefined");
anthony805a2d42011-09-25 08:25:12 +0000789 break;
790 }
anthony6dc09cd2011-10-12 08:56:49 +0000791 if (LocaleCompare("font",argv[0]+1) == 0)
anthony805a2d42011-09-25 08:25:12 +0000792 {
anthony6dc09cd2011-10-12 08:56:49 +0000793 (void) CloneString(&draw_info->font,
794 IfSetOption ? argv[1] : (const char *) NULL);
795 (void) CloneString(&image_info->font,draw_info->font);
anthony805a2d42011-09-25 08:25:12 +0000796 break;
797 }
anthony74b1cfc2011-10-06 12:44:16 +0000798 if (LocaleCompare("format",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000799 {
anthony6dc09cd2011-10-12 08:56:49 +0000800 /* FUTURE: why the ping test, the user could set ping after this! */
anthony805a2d42011-09-25 08:25:12 +0000801 register const char
802 *q;
803
804 for (q=strchr(argv[1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
805 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
806 image_info->ping=MagickFalse;
anthony74b1cfc2011-10-06 12:44:16 +0000807 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000808 break;
809 }
anthony74b1cfc2011-10-06 12:44:16 +0000810 if (LocaleCompare("fuzz",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000811 {
anthony6613bf32011-10-15 07:24:44 +0000812 /* FUTURE: image_info and ImageOption!
813 Option used to set image fuzz! unless blank canvas (from color)
814 image attribute used for color compare operations
815 Can't find anything using image_info->fuzz (except cloning)!
816 */
817 if (IfSetOption)
anthony805a2d42011-09-25 08:25:12 +0000818 {
anthony6613bf32011-10-15 07:24:44 +0000819 image_info->fuzz=SiPrefixToDouble(argv[1],(double) QuantumRange+1.0);
820 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000821 break;
822 }
anthony6613bf32011-10-15 07:24:44 +0000823 image_info->fuzz=0.0;
824 (void) SetImageOption(image_info,option,"0");
anthony805a2d42011-09-25 08:25:12 +0000825 break;
826 }
827 break;
828 }
829 case 'g':
830 {
anthony74b1cfc2011-10-06 12:44:16 +0000831 if (LocaleCompare("gravity",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000832 {
833 if (*argv[0] == '+')
834 {
anthony74b1cfc2011-10-06 12:44:16 +0000835 (void) SetImageOption(image_info,option,"undefined");
anthony6dc09cd2011-10-12 08:56:49 +0000836 draw_info->gravity=UndefinedGravity;
anthony805a2d42011-09-25 08:25:12 +0000837 break;
838 }
anthony74b1cfc2011-10-06 12:44:16 +0000839 (void) SetImageOption(image_info,option,argv[1]);
anthony6dc09cd2011-10-12 08:56:49 +0000840 draw_info->gravity=(GravityType) ParseCommandOption(
841 MagickGravityOptions,MagickFalse,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000842 break;
843 }
anthony74b1cfc2011-10-06 12:44:16 +0000844 if (LocaleCompare("green-primary",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000845 {
846 if (*argv[0] == '+')
847 {
anthony74b1cfc2011-10-06 12:44:16 +0000848 (void) SetImageOption(image_info,option,"0.0");
anthony805a2d42011-09-25 08:25:12 +0000849 break;
850 }
anthony74b1cfc2011-10-06 12:44:16 +0000851 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000852 break;
853 }
854 break;
855 }
856 case 'i':
857 {
anthony74b1cfc2011-10-06 12:44:16 +0000858 if (LocaleCompare("intent",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000859 {
860 if (*argv[0] == '+')
861 {
anthony74b1cfc2011-10-06 12:44:16 +0000862 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +0000863 break;
864 }
anthony74b1cfc2011-10-06 12:44:16 +0000865 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000866 break;
867 }
anthony74b1cfc2011-10-06 12:44:16 +0000868 if (LocaleCompare("interlace",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000869 {
870 if (*argv[0] == '+')
871 {
872 image_info->interlace=UndefinedInterlace;
anthony74b1cfc2011-10-06 12:44:16 +0000873 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +0000874 break;
875 }
876 image_info->interlace=(InterlaceType) ParseCommandOption(
877 MagickInterlaceOptions,MagickFalse,argv[1]);
anthony74b1cfc2011-10-06 12:44:16 +0000878 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000879 break;
880 }
anthony74b1cfc2011-10-06 12:44:16 +0000881 if (LocaleCompare("interline-spacing",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000882 {
883 if (*argv[0] == '+')
884 {
anthony74b1cfc2011-10-06 12:44:16 +0000885 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +0000886 break;
887 }
anthony74b1cfc2011-10-06 12:44:16 +0000888 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000889 break;
890 }
anthony74b1cfc2011-10-06 12:44:16 +0000891 if (LocaleCompare("interpolate",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000892 {
893 if (*argv[0] == '+')
894 {
anthony74b1cfc2011-10-06 12:44:16 +0000895 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +0000896 break;
897 }
anthony74b1cfc2011-10-06 12:44:16 +0000898 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000899 break;
900 }
anthony74b1cfc2011-10-06 12:44:16 +0000901 if (LocaleCompare("interword-spacing",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000902 {
903 if (*argv[0] == '+')
904 {
anthony74b1cfc2011-10-06 12:44:16 +0000905 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +0000906 break;
907 }
anthony74b1cfc2011-10-06 12:44:16 +0000908 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000909 break;
910 }
911 break;
912 }
913 case 'k':
914 {
anthony74b1cfc2011-10-06 12:44:16 +0000915 if (LocaleCompare("kerning",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000916 {
917 if (*argv[0] == '+')
918 {
anthony74b1cfc2011-10-06 12:44:16 +0000919 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +0000920 break;
921 }
anthony74b1cfc2011-10-06 12:44:16 +0000922 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000923 break;
924 }
925 break;
926 }
927 case 'l':
928 {
anthony74b1cfc2011-10-06 12:44:16 +0000929 if (LocaleCompare("label",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000930 {
931 if (*argv[0] == '+')
932 {
anthony74b1cfc2011-10-06 12:44:16 +0000933 (void) DeleteImageOption(image_info,option);
anthony805a2d42011-09-25 08:25:12 +0000934 break;
935 }
anthony74b1cfc2011-10-06 12:44:16 +0000936 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +0000937 break;
938 }
anthony74b1cfc2011-10-06 12:44:16 +0000939 if (LocaleCompare("limit",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000940 {
941 MagickSizeType
942 limit;
943
944 ResourceType
945 type;
946
947 if (*argv[0] == '+')
948 break;
949 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
950 MagickFalse,argv[1]);
951 limit=MagickResourceInfinity;
952 if (LocaleCompare("unlimited",argv[2]) != 0)
953 limit=(MagickSizeType) SiPrefixToDouble(argv[2],100.0);
954 (void) SetMagickResourceLimit(type,limit);
955 break;
956 }
anthony74b1cfc2011-10-06 12:44:16 +0000957 if (LocaleCompare("list",option) == 0)
anthony805a2d42011-09-25 08:25:12 +0000958 {
959 ssize_t
960 list;
961
962 /*
963 Display configuration list.
964 */
965 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[1]);
966 switch (list)
967 {
968 case MagickCoderOptions:
969 {
970 (void) ListCoderInfo((FILE *) NULL,exception);
971 break;
972 }
973 case MagickColorOptions:
974 {
975 (void) ListColorInfo((FILE *) NULL,exception);
976 break;
977 }
978 case MagickConfigureOptions:
979 {
980 (void) ListConfigureInfo((FILE *) NULL,exception);
981 break;
982 }
983 case MagickDelegateOptions:
984 {
985 (void) ListDelegateInfo((FILE *) NULL,exception);
986 break;
987 }
988 case MagickFontOptions:
989 {
990 (void) ListTypeInfo((FILE *) NULL,exception);
991 break;
992 }
993 case MagickFormatOptions:
994 {
995 (void) ListMagickInfo((FILE *) NULL,exception);
996 break;
997 }
998 case MagickLocaleOptions:
999 {
1000 (void) ListLocaleInfo((FILE *) NULL,exception);
1001 break;
1002 }
1003 case MagickLogOptions:
1004 {
1005 (void) ListLogInfo((FILE *) NULL,exception);
1006 break;
1007 }
1008 case MagickMagicOptions:
1009 {
1010 (void) ListMagicInfo((FILE *) NULL,exception);
1011 break;
1012 }
1013 case MagickMimeOptions:
1014 {
1015 (void) ListMimeInfo((FILE *) NULL,exception);
1016 break;
1017 }
1018 case MagickModuleOptions:
1019 {
1020 (void) ListModuleInfo((FILE *) NULL,exception);
1021 break;
1022 }
1023 case MagickPolicyOptions:
1024 {
1025 (void) ListPolicyInfo((FILE *) NULL,exception);
1026 break;
1027 }
1028 case MagickResourceOptions:
1029 {
1030 (void) ListMagickResourceInfo((FILE *) NULL,exception);
1031 break;
1032 }
1033 case MagickThresholdOptions:
1034 {
1035 (void) ListThresholdMaps((FILE *) NULL,exception);
1036 break;
1037 }
1038 default:
1039 {
1040 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
1041 exception);
1042 break;
1043 }
1044 }
1045 break;
1046 }
anthony74b1cfc2011-10-06 12:44:16 +00001047 if (LocaleCompare("log",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001048 {
1049 if (*argv[0] == '+')
1050 break;
1051 (void) SetLogFormat(argv[1]);
1052 break;
1053 }
anthony74b1cfc2011-10-06 12:44:16 +00001054 if (LocaleCompare("loop",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001055 {
1056 if (*argv[0] == '+')
1057 {
anthony74b1cfc2011-10-06 12:44:16 +00001058 (void) SetImageOption(image_info,option,"0");
anthony805a2d42011-09-25 08:25:12 +00001059 break;
1060 }
anthony74b1cfc2011-10-06 12:44:16 +00001061 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001062 break;
1063 }
1064 break;
1065 }
1066 case 'm':
1067 {
anthony74b1cfc2011-10-06 12:44:16 +00001068 if (LocaleCompare("matte",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001069 {
1070 if (*argv[0] == '+')
1071 {
anthony74b1cfc2011-10-06 12:44:16 +00001072 (void) SetImageOption(image_info,option,"false");
anthony805a2d42011-09-25 08:25:12 +00001073 break;
1074 }
anthony74b1cfc2011-10-06 12:44:16 +00001075 (void) SetImageOption(image_info,option,"true");
anthony805a2d42011-09-25 08:25:12 +00001076 break;
1077 }
anthony74b1cfc2011-10-06 12:44:16 +00001078 if (LocaleCompare("mattecolor",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001079 {
1080 if (*argv[0] == '+')
1081 {
anthony74b1cfc2011-10-06 12:44:16 +00001082 (void) SetImageOption(image_info,option,argv[1]);
anthony1afdc7a2011-10-05 11:54:28 +00001083 (void) QueryColorCompliance(MatteColor,AllCompliance,
anthonya89dd172011-10-04 13:29:35 +00001084 &image_info->matte_color,exception);
anthony805a2d42011-09-25 08:25:12 +00001085 break;
1086 }
anthony74b1cfc2011-10-06 12:44:16 +00001087 (void) SetImageOption(image_info,option,argv[1]);
anthony1afdc7a2011-10-05 11:54:28 +00001088 (void) QueryColorCompliance(argv[1],AllCompliance,&image_info->matte_color,
anthony805a2d42011-09-25 08:25:12 +00001089 exception);
1090 break;
1091 }
anthony74b1cfc2011-10-06 12:44:16 +00001092 if (LocaleCompare("monitor",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001093 {
1094 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
1095 (void *) NULL);
1096 break;
1097 }
anthony74b1cfc2011-10-06 12:44:16 +00001098 if (LocaleCompare("monochrome",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001099 {
1100 image_info->monochrome=(*argv[0] == '-') ? MagickTrue : MagickFalse;
1101 break;
1102 }
1103 break;
1104 }
1105 case 'o':
1106 {
anthony74b1cfc2011-10-06 12:44:16 +00001107 if (LocaleCompare("orient",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001108 {
1109 if (*argv[0] == '+')
1110 {
1111 image_info->orientation=UndefinedOrientation;
anthony74b1cfc2011-10-06 12:44:16 +00001112 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +00001113 break;
1114 }
1115 image_info->orientation=(OrientationType) ParseCommandOption(
1116 MagickOrientationOptions,MagickFalse,argv[1]);
anthony74b1cfc2011-10-06 12:44:16 +00001117 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001118 break;
1119 }
1120 }
1121 case 'p':
1122 {
anthony74b1cfc2011-10-06 12:44:16 +00001123 if (LocaleCompare("page",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001124 {
1125 char
1126 *canonical_page,
1127 page[MaxTextExtent];
1128
1129 const char
1130 *image_option;
1131
1132 MagickStatusType
1133 flags;
1134
1135 RectangleInfo
1136 geometry;
1137
1138 if (*argv[0] == '+')
1139 {
anthony74b1cfc2011-10-06 12:44:16 +00001140 (void) DeleteImageOption(image_info,option);
anthony805a2d42011-09-25 08:25:12 +00001141 (void) CloneString(&image_info->page,(char *) NULL);
1142 break;
1143 }
1144 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
1145 image_option=GetImageOption(image_info,"page");
1146 if (image_option != (const char *) NULL)
1147 flags=ParseAbsoluteGeometry(image_option,&geometry);
1148 canonical_page=GetPageGeometry(argv[1]);
1149 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
1150 canonical_page=DestroyString(canonical_page);
1151 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
1152 (unsigned long) geometry.width,(unsigned long) geometry.height);
1153 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1154 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
1155 (unsigned long) geometry.width,(unsigned long) geometry.height,
1156 (long) geometry.x,(long) geometry.y);
anthony74b1cfc2011-10-06 12:44:16 +00001157 (void) SetImageOption(image_info,option,page);
anthony805a2d42011-09-25 08:25:12 +00001158 (void) CloneString(&image_info->page,page);
1159 break;
1160 }
anthony74b1cfc2011-10-06 12:44:16 +00001161 if (LocaleCompare("pen",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001162 {
1163 if (*argv[0] == '+')
1164 {
anthony74b1cfc2011-10-06 12:44:16 +00001165 (void) SetImageOption(image_info,option,"none");
anthony805a2d42011-09-25 08:25:12 +00001166 break;
1167 }
anthony74b1cfc2011-10-06 12:44:16 +00001168 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001169 break;
1170 }
anthony74b1cfc2011-10-06 12:44:16 +00001171 if (LocaleCompare("ping",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001172 {
1173 image_info->ping=(*argv[0] == '-') ? MagickTrue : MagickFalse;
1174 break;
1175 }
anthony74b1cfc2011-10-06 12:44:16 +00001176 if (LocaleCompare("pointsize",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001177 {
1178 if (*argv[0] == '+')
1179 geometry_info.rho=0.0;
1180 else
1181 (void) ParseGeometry(argv[1],&geometry_info);
1182 image_info->pointsize=geometry_info.rho;
1183 break;
1184 }
anthony74b1cfc2011-10-06 12:44:16 +00001185 if (LocaleCompare("precision",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001186 {
1187 (void) SetMagickPrecision(StringToInteger(argv[1]));
1188 break;
1189 }
anthony74b1cfc2011-10-06 12:44:16 +00001190 if (LocaleCompare("preview",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001191 {
1192 /*
1193 Preview image.
1194 */
1195 if (*argv[0] == '+')
1196 {
1197 image_info->preview_type=UndefinedPreview;
1198 break;
1199 }
1200 image_info->preview_type=(PreviewType) ParseCommandOption(
1201 MagickPreviewOptions,MagickFalse,argv[1]);
1202 break;
1203 }
1204 break;
1205 }
1206 case 'q':
1207 {
anthony74b1cfc2011-10-06 12:44:16 +00001208 if (LocaleCompare("quality",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001209 {
1210 /*
1211 Set image compression quality.
1212 */
1213 if (*argv[0] == '+')
1214 {
1215 image_info->quality=UndefinedCompressionQuality;
anthony74b1cfc2011-10-06 12:44:16 +00001216 (void) SetImageOption(image_info,option,"0");
anthony805a2d42011-09-25 08:25:12 +00001217 break;
1218 }
1219 image_info->quality=StringToUnsignedLong(argv[1]);
anthony74b1cfc2011-10-06 12:44:16 +00001220 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001221 break;
1222 }
anthony74b1cfc2011-10-06 12:44:16 +00001223 if (LocaleCompare("quiet",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001224 {
1225 static WarningHandler
1226 warning_handler = (WarningHandler) NULL;
1227
1228 if (*argv[0] == '+')
1229 {
1230 /*
1231 Restore error or warning messages.
1232 */
1233 warning_handler=SetWarningHandler(warning_handler);
1234 break;
1235 }
1236 /*
1237 Suppress error or warning messages.
1238 */
1239 warning_handler=SetWarningHandler((WarningHandler) NULL);
1240 break;
1241 }
1242 break;
1243 }
1244 case 'r':
1245 {
anthony74b1cfc2011-10-06 12:44:16 +00001246 if (LocaleCompare("red-primary",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001247 {
1248 if (*argv[0] == '+')
1249 {
anthony74b1cfc2011-10-06 12:44:16 +00001250 (void) SetImageOption(image_info,option,"0.0");
anthony805a2d42011-09-25 08:25:12 +00001251 break;
1252 }
anthony74b1cfc2011-10-06 12:44:16 +00001253 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001254 break;
1255 }
1256 break;
1257 }
1258 case 's':
1259 {
anthony74b1cfc2011-10-06 12:44:16 +00001260 if (LocaleCompare("sampling-factor",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001261 {
1262 /*
1263 Set image sampling factor.
1264 */
1265 if (*argv[0] == '+')
1266 {
1267 if (image_info->sampling_factor != (char *) NULL)
1268 image_info->sampling_factor=DestroyString(
1269 image_info->sampling_factor);
1270 break;
1271 }
1272 (void) CloneString(&image_info->sampling_factor,argv[1]);
1273 break;
1274 }
anthony74b1cfc2011-10-06 12:44:16 +00001275 if (LocaleCompare("scene",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001276 {
1277 /*
1278 Set image scene.
1279 */
1280 if (*argv[0] == '+')
1281 {
1282 image_info->scene=0;
anthony74b1cfc2011-10-06 12:44:16 +00001283 (void) SetImageOption(image_info,option,"0");
anthony805a2d42011-09-25 08:25:12 +00001284 break;
1285 }
1286 image_info->scene=StringToUnsignedLong(argv[1]);
anthony74b1cfc2011-10-06 12:44:16 +00001287 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001288 break;
1289 }
anthony74b1cfc2011-10-06 12:44:16 +00001290 if (LocaleCompare("seed",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001291 {
1292 size_t
1293 seed;
1294
1295 if (*argv[0] == '+')
1296 {
1297 seed=(size_t) time((time_t *) NULL);
1298 SeedPseudoRandomGenerator(seed);
1299 break;
1300 }
1301 seed=StringToUnsignedLong(argv[1]);
1302 SeedPseudoRandomGenerator(seed);
1303 break;
1304 }
anthony74b1cfc2011-10-06 12:44:16 +00001305 if (LocaleCompare("size",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001306 {
anthony74b1cfc2011-10-06 12:44:16 +00001307 /* FUTURE: convert to ImageOption
1308 Look at special handling for "size" in SetImageOption()
1309 */
anthony805a2d42011-09-25 08:25:12 +00001310 if (*argv[0] == '+')
1311 {
1312 if (image_info->size != (char *) NULL)
1313 image_info->size=DestroyString(image_info->size);
1314 break;
1315 }
1316 (void) CloneString(&image_info->size,argv[1]);
1317 break;
1318 }
anthony74b1cfc2011-10-06 12:44:16 +00001319 if (LocaleCompare("stroke",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001320 {
1321 if (*argv[0] == '+')
1322 {
anthony74b1cfc2011-10-06 12:44:16 +00001323 (void) SetImageOption(image_info,option,"none");
anthony805a2d42011-09-25 08:25:12 +00001324 break;
1325 }
anthony74b1cfc2011-10-06 12:44:16 +00001326 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001327 break;
1328 }
anthony74b1cfc2011-10-06 12:44:16 +00001329 if (LocaleCompare("strokewidth",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001330 {
1331 if (*argv[0] == '+')
1332 {
anthony74b1cfc2011-10-06 12:44:16 +00001333 (void) SetImageOption(image_info,option,"0");
anthony805a2d42011-09-25 08:25:12 +00001334 break;
1335 }
anthony74b1cfc2011-10-06 12:44:16 +00001336 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001337 break;
1338 }
anthony74b1cfc2011-10-06 12:44:16 +00001339 if (LocaleCompare("synchronize",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001340 {
1341 if (*argv[0] == '+')
1342 {
1343 image_info->synchronize=MagickFalse;
1344 break;
1345 }
1346 image_info->synchronize=MagickTrue;
1347 break;
1348 }
1349 break;
1350 }
1351 case 't':
1352 {
anthony74b1cfc2011-10-06 12:44:16 +00001353 if (LocaleCompare("taint",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001354 {
1355 if (*argv[0] == '+')
1356 {
anthony74b1cfc2011-10-06 12:44:16 +00001357 (void) SetImageOption(image_info,option,"false");
anthony805a2d42011-09-25 08:25:12 +00001358 break;
1359 }
anthony74b1cfc2011-10-06 12:44:16 +00001360 (void) SetImageOption(image_info,option,"true");
anthony805a2d42011-09-25 08:25:12 +00001361 break;
1362 }
anthony74b1cfc2011-10-06 12:44:16 +00001363 if (LocaleCompare("texture",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001364 {
1365 if (*argv[0] == '+')
1366 {
1367 if (image_info->texture != (char *) NULL)
1368 image_info->texture=DestroyString(image_info->texture);
1369 break;
1370 }
1371 (void) CloneString(&image_info->texture,argv[1]);
1372 break;
1373 }
anthony74b1cfc2011-10-06 12:44:16 +00001374 if (LocaleCompare("tile-offset",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001375 {
1376 if (*argv[0] == '+')
1377 {
anthony74b1cfc2011-10-06 12:44:16 +00001378 (void) SetImageOption(image_info,option,"0");
anthony805a2d42011-09-25 08:25:12 +00001379 break;
1380 }
anthony74b1cfc2011-10-06 12:44:16 +00001381 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001382 break;
1383 }
anthony74b1cfc2011-10-06 12:44:16 +00001384 if (LocaleCompare("transparent-color",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001385 {
1386 if (*argv[0] == '+')
1387 {
anthony1afdc7a2011-10-05 11:54:28 +00001388 (void) QueryColorCompliance("none",AllCompliance,
anthonya89dd172011-10-04 13:29:35 +00001389 &image_info->transparent_color,exception);
anthony74b1cfc2011-10-06 12:44:16 +00001390 (void) SetImageOption(image_info,option,"none");
anthony805a2d42011-09-25 08:25:12 +00001391 break;
1392 }
anthony1afdc7a2011-10-05 11:54:28 +00001393 (void) QueryColorCompliance("none",AllCompliance,
anthonya89dd172011-10-04 13:29:35 +00001394 &image_info->transparent_color,exception);
anthony74b1cfc2011-10-06 12:44:16 +00001395 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001396 break;
1397 }
anthony74b1cfc2011-10-06 12:44:16 +00001398 if (LocaleCompare("type",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001399 {
1400 if (*argv[0] == '+')
1401 {
1402 image_info->type=UndefinedType;
anthony74b1cfc2011-10-06 12:44:16 +00001403 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +00001404 break;
1405 }
1406 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
1407 MagickFalse,argv[1]);
anthony74b1cfc2011-10-06 12:44:16 +00001408 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001409 break;
1410 }
1411 break;
1412 }
1413 case 'u':
1414 {
anthony74b1cfc2011-10-06 12:44:16 +00001415 if (LocaleCompare("undercolor",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001416 {
1417 if (*argv[0] == '+')
1418 {
anthony74b1cfc2011-10-06 12:44:16 +00001419 (void) DeleteImageOption(image_info,option);
anthony805a2d42011-09-25 08:25:12 +00001420 break;
1421 }
anthony74b1cfc2011-10-06 12:44:16 +00001422 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001423 break;
1424 }
anthony74b1cfc2011-10-06 12:44:16 +00001425 if (LocaleCompare("units",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001426 {
1427 if (*argv[0] == '+')
1428 {
1429 image_info->units=UndefinedResolution;
anthony74b1cfc2011-10-06 12:44:16 +00001430 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +00001431 break;
1432 }
1433 image_info->units=(ResolutionType) ParseCommandOption(
1434 MagickResolutionOptions,MagickFalse,argv[1]);
anthony74b1cfc2011-10-06 12:44:16 +00001435 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001436 break;
1437 }
1438 break;
1439 }
1440 case 'v':
1441 {
anthony74b1cfc2011-10-06 12:44:16 +00001442 if (LocaleCompare("verbose",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001443 {
1444 if (*argv[0] == '+')
1445 {
1446 image_info->verbose=MagickFalse;
1447 break;
1448 }
1449 image_info->verbose=MagickTrue;
1450 image_info->ping=MagickFalse;
1451 break;
1452 }
anthony74b1cfc2011-10-06 12:44:16 +00001453 if (LocaleCompare("view",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001454 {
1455 if (*argv[0] == '+')
1456 {
1457 if (image_info->view != (char *) NULL)
1458 image_info->view=DestroyString(image_info->view);
1459 break;
1460 }
1461 (void) CloneString(&image_info->view,argv[1]);
1462 break;
1463 }
anthony74b1cfc2011-10-06 12:44:16 +00001464 if (LocaleCompare("virtual-pixel",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001465 {
1466 if (*argv[0] == '+')
1467 {
1468 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
anthony74b1cfc2011-10-06 12:44:16 +00001469 (void) SetImageOption(image_info,option,"undefined");
anthony805a2d42011-09-25 08:25:12 +00001470 break;
1471 }
1472 image_info->virtual_pixel_method=(VirtualPixelMethod)
1473 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,argv[1]);
anthony74b1cfc2011-10-06 12:44:16 +00001474 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001475 break;
1476 }
1477 break;
1478 }
1479 case 'w':
1480 {
anthony74b1cfc2011-10-06 12:44:16 +00001481 if (LocaleCompare("white-point",option) == 0)
anthony805a2d42011-09-25 08:25:12 +00001482 {
1483 if (*argv[0] == '+')
1484 {
anthony74b1cfc2011-10-06 12:44:16 +00001485 (void) SetImageOption(image_info,option,"0.0");
anthony805a2d42011-09-25 08:25:12 +00001486 break;
1487 }
anthony74b1cfc2011-10-06 12:44:16 +00001488 (void) SetImageOption(image_info,option,argv[1]);
anthony805a2d42011-09-25 08:25:12 +00001489 break;
1490 }
1491 break;
1492 }
1493 default:
1494 break;
1495 }
1496 return(MagickTrue);
1497}
1498
1499/*
1500%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1501% %
1502% %
1503% %
anthony74b1cfc2011-10-06 12:44:16 +00001504+ A p p l y I m a g e O p e r a t o r %
anthony805a2d42011-09-25 08:25:12 +00001505% %
1506% %
1507% %
1508%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1509%
anthony74b1cfc2011-10-06 12:44:16 +00001510% ApplyImageOperator() apply one simple image operation to just the current
1511% image.
anthony805a2d42011-09-25 08:25:12 +00001512%
1513% The image in the list may be modified in three different ways...
1514%
1515% * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
1516% * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
1517% * replace by a list of images (-separate and -crop only!)
1518%
1519% In each case the result is returned into the list, and the pointer to the
1520% modified image (last image added if replaced by a list of images) is
1521% returned. As the image pointed to may be replaced, the first image in the
1522% list may also change. GetFirstImageInList() should be used by caller if
1523% they wish return the Image pointer to the first image in list.
1524%
anthony74b1cfc2011-10-06 12:44:16 +00001525% The format of the ApplyImageOperator method is:
anthony805a2d42011-09-25 08:25:12 +00001526%
anthony74b1cfc2011-10-06 12:44:16 +00001527% MagickBooleanType ApplyImageOperator(MagickWand *wand,
1528% const int argc,const char **argv)
anthony805a2d42011-09-25 08:25:12 +00001529%
1530% A description of each parameter follows:
1531%
anthony74b1cfc2011-10-06 12:44:16 +00001532% o wand: The CLI wand holding all the settings and pointer to image
anthony805a2d42011-09-25 08:25:12 +00001533%
1534% o argc: Specifies a pointer to an integer describing the number of
1535% elements in the argument vector.
1536%
1537% o argv: Specifies a pointer to a text array containing the command line
1538% arguments.
1539%
anthony805a2d42011-09-25 08:25:12 +00001540% o exception: return any errors or warnings in this structure.
1541%
1542*/
anthony74b1cfc2011-10-06 12:44:16 +00001543MagickExport MagickBooleanType ApplyImageOperator(MagickWand *wand,
1544 const int wand_unused(argc), const char **argv, ExceptionInfo *exception)
anthony805a2d42011-09-25 08:25:12 +00001545{
1546 Image *
1547 new_image;
1548
1549 ChannelType
1550 channel;
1551
anthony5f867ae2011-10-09 10:28:34 +00001552 ComposeOperation
1553 compose;
1554
anthony805a2d42011-09-25 08:25:12 +00001555 const char
1556 *format;
1557
1558 DrawInfo
1559 *draw_info;
1560
1561 GeometryInfo
1562 geometry_info;
1563
1564 RectangleInfo
1565 geometry;
1566
1567 MagickStatusType
1568 status;
1569
1570 PixelInfo
1571 fill;
1572
1573 MagickStatusType
1574 flags;
1575
1576 QuantizeInfo
1577 *quantize_info;
1578
1579 assert(image_info != (const ImageInfo *) NULL);
1580 assert(image_info->signature == MagickSignature);
1581 assert(image != (Image **) NULL);
1582 assert((*image)->signature == MagickSignature);
1583 if ((*image)->debug != MagickFalse)
1584 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
anthonya89dd172011-10-04 13:29:35 +00001585 if (argc < 0)
1586 return(MagickTrue);
anthony805a2d42011-09-25 08:25:12 +00001587 draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
1588 quantize_info=AcquireQuantizeInfo(image_info);
1589 SetGeometryInfo(&geometry_info);
1590 GetPixelInfo(*image,&fill);
1591 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
1592 channel=image_info->channel;
1593 format=GetImageOption(image_info,"format");
1594
1595 new_image = (Image *)NULL;
1596
1597 switch (*(argv[0]+1))
1598 {
1599 case 'a':
1600 {
1601 if (LocaleCompare("adaptive-blur",argv[0]+1) == 0)
1602 {
anthony805a2d42011-09-25 08:25:12 +00001603 (void) SyncImageSettings(image_info,*image);
1604 flags=ParseGeometry(argv[1],&geometry_info);
1605 if ((flags & SigmaValue) == 0)
1606 geometry_info.sigma=1.0;
1607 if ((flags & XiValue) == 0)
1608 geometry_info.xi=0.0;
1609 new_image=AdaptiveBlurImage(*image,geometry_info.rho,
1610 geometry_info.sigma,geometry_info.xi,exception);
1611 break;
1612 }
1613 if (LocaleCompare("adaptive-resize",argv[0]+1) == 0)
1614 {
anthony1afdc7a2011-10-05 11:54:28 +00001615 /* FUTURE: this is really a "interpolate-resize" operator
1616 "adaptive-resize" uses a fixed "Mesh" interpolation
anthony805a2d42011-09-25 08:25:12 +00001617 */
1618 (void) SyncImageSettings(image_info,*image);
1619 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
1620 new_image=AdaptiveResizeImage(*image,geometry.width,
anthonya89dd172011-10-04 13:29:35 +00001621 geometry.height,interpolate_method,exception);
anthony805a2d42011-09-25 08:25:12 +00001622 break;
1623 }
1624 if (LocaleCompare("adaptive-sharpen",argv[0]+1) == 0)
1625 {
1626 /*
1627 Adaptive sharpen image.
1628 */
1629 (void) SyncImageSettings(image_info,*image);
1630 flags=ParseGeometry(argv[1],&geometry_info);
1631 if ((flags & SigmaValue) == 0)
1632 geometry_info.sigma=1.0;
1633 if ((flags & XiValue) == 0)
1634 geometry_info.xi=0.0;
1635 new_image=AdaptiveSharpenImage(*image,geometry_info.rho,
1636 geometry_info.sigma,geometry_info.xi,exception);
1637 break;
1638 }
anthony805a2d42011-09-25 08:25:12 +00001639 if (LocaleCompare("alpha",argv[0]+1) == 0)
1640 {
1641 AlphaChannelType
1642 alpha_type;
1643
1644 (void) SyncImageSettings(image_info,*image);
1645 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
1646 MagickFalse,argv[1]);
1647 (void) SetImageAlphaChannel(*image,alpha_type,exception);
1648 break;
1649 }
1650 if (LocaleCompare("annotate",argv[0]+1) == 0)
1651 {
1652 char
1653 *text,
1654 geometry[MaxTextExtent];
1655
anthony805a2d42011-09-25 08:25:12 +00001656 (void) SyncImageSettings(image_info,*image);
1657 SetGeometryInfo(&geometry_info);
1658 flags=ParseGeometry(argv[1],&geometry_info);
1659 if ((flags & SigmaValue) == 0)
1660 geometry_info.sigma=geometry_info.rho;
1661 text=InterpretImageProperties(image_info,*image,argv[2],
1662 exception);
1663 if (text == (char *) NULL)
1664 break;
1665 (void) CloneString(&draw_info->text,text);
1666 text=DestroyString(text);
1667 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
1668 geometry_info.xi,geometry_info.psi);
1669 (void) CloneString(&draw_info->geometry,geometry);
1670 draw_info->affine.sx=cos(DegreesToRadians(
1671 fmod(geometry_info.rho,360.0)));
1672 draw_info->affine.rx=sin(DegreesToRadians(
1673 fmod(geometry_info.rho,360.0)));
1674 draw_info->affine.ry=(-sin(DegreesToRadians(
1675 fmod(geometry_info.sigma,360.0))));
1676 draw_info->affine.sy=cos(DegreesToRadians(
1677 fmod(geometry_info.sigma,360.0)));
1678 (void) AnnotateImage(*image,draw_info,exception);
1679 break;
1680 }
anthony805a2d42011-09-25 08:25:12 +00001681 if (LocaleCompare("auto-gamma",argv[0]+1) == 0)
1682 {
1683 /*
1684 Auto Adjust Gamma of image based on its mean
1685 */
1686 (void) SyncImageSettings(image_info,*image);
1687 (void) AutoGammaImage(*image,exception);
1688 break;
1689 }
1690 if (LocaleCompare("auto-level",argv[0]+1) == 0)
1691 {
1692 /*
1693 Perfectly Normalize (max/min stretch) the image
1694 */
1695 (void) SyncImageSettings(image_info,*image);
1696 (void) AutoLevelImage(*image,exception);
1697 break;
1698 }
1699 if (LocaleCompare("auto-orient",argv[0]+1) == 0)
1700 {
1701 (void) SyncImageSettings(image_info,*image);
1702 switch ((*image)->orientation)
1703 {
1704 case TopRightOrientation:
1705 {
1706 new_image=FlopImage(*image,exception);
1707 break;
1708 }
1709 case BottomRightOrientation:
1710 {
1711 new_image=RotateImage(*image,180.0,exception);
1712 break;
1713 }
1714 case BottomLeftOrientation:
1715 {
1716 new_image=FlipImage(*image,exception);
1717 break;
1718 }
1719 case LeftTopOrientation:
1720 {
1721 new_image=TransposeImage(*image,exception);
1722 break;
1723 }
1724 case RightTopOrientation:
1725 {
1726 new_image=RotateImage(*image,90.0,exception);
1727 break;
1728 }
1729 case RightBottomOrientation:
1730 {
1731 new_image=TransverseImage(*image,exception);
1732 break;
1733 }
1734 case LeftBottomOrientation:
1735 {
1736 new_image=RotateImage(*image,270.0,exception);
1737 break;
1738 }
1739 default:
1740 break;
1741 }
1742 if (new_image != (Image *) NULL)
1743 new_image->orientation=TopLeftOrientation;
1744 break;
1745 }
1746 break;
1747 }
1748 case 'b':
1749 {
1750 if (LocaleCompare("black-threshold",argv[0]+1) == 0)
1751 {
anthony805a2d42011-09-25 08:25:12 +00001752 (void) SyncImageSettings(image_info,*image);
1753 (void) BlackThresholdImage(*image,argv[1],exception);
1754 InheritException(exception,&(*image)->exception);
1755 break;
1756 }
1757 if (LocaleCompare("blue-shift",argv[0]+1) == 0)
1758 {
anthony805a2d42011-09-25 08:25:12 +00001759 (void) SyncImageSettings(image_info,*image);
1760 geometry_info.rho=1.5;
1761 if (*argv[0] == '-')
1762 flags=ParseGeometry(argv[1],&geometry_info);
1763 new_image=BlueShiftImage(*image,geometry_info.rho,exception);
1764 break;
1765 }
1766 if (LocaleCompare("blur",argv[0]+1) == 0)
1767 {
anthony74b1cfc2011-10-06 12:44:16 +00001768 /* FUTURE: use of "bias" in a blur is non-sensible */
anthony805a2d42011-09-25 08:25:12 +00001769 (void) SyncImageSettings(image_info,*image);
1770 flags=ParseGeometry(argv[1],&geometry_info);
1771 if ((flags & SigmaValue) == 0)
1772 geometry_info.sigma=1.0;
1773 if ((flags & XiValue) == 0)
1774 geometry_info.xi=0.0;
1775 new_image=BlurImage(*image,geometry_info.rho,
1776 geometry_info.sigma,geometry_info.xi,exception);
1777 break;
1778 }
1779 if (LocaleCompare("border",argv[0]+1) == 0)
1780 {
anthony5f867ae2011-10-09 10:28:34 +00001781 ComposeOperator
1782 compose;
1783
1784 const char*
1785 const char*
1786 value;
1787
1788 value=GetImageOption(image_info,"compose");
1789 if (value != (const char *) NULL)
1790 compose=(CompositeOperator) ParseCommandOption(
1791 MagickComposeOptions,MagickFalse,value);
1792 else
1793 compose=OverCompositeOp; /* use Over not image->compose */
1794
anthony805a2d42011-09-25 08:25:12 +00001795 (void) SyncImageSettings(image_info,*image);
1796 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
1797 if ((flags & SigmaValue) == 0)
1798 geometry.height=geometry.width;
anthonya89dd172011-10-04 13:29:35 +00001799 new_image=BorderImage(*image,&geometry,compose,exception);
anthony805a2d42011-09-25 08:25:12 +00001800 break;
1801 }
anthony805a2d42011-09-25 08:25:12 +00001802 if (LocaleCompare("brightness-contrast",argv[0]+1) == 0)
1803 {
1804 double
1805 brightness,
1806 contrast;
1807
1808 GeometryInfo
1809 geometry_info;
1810
1811 MagickStatusType
1812 flags;
1813
anthony805a2d42011-09-25 08:25:12 +00001814 (void) SyncImageSettings(image_info,*image);
1815 flags=ParseGeometry(argv[1],&geometry_info);
1816 brightness=geometry_info.rho;
1817 contrast=0.0;
1818 if ((flags & SigmaValue) != 0)
1819 contrast=geometry_info.sigma;
1820 (void) BrightnessContrastImage(*image,brightness,contrast,
1821 exception);
1822 InheritException(exception,&(*image)->exception);
1823 break;
1824 }
1825 break;
1826 }
1827 case 'c':
1828 {
1829 if (LocaleCompare("cdl",argv[0]+1) == 0)
1830 {
1831 char
1832 *color_correction_collection;
1833
1834 /*
1835 Color correct with a color decision list.
1836 */
1837 (void) SyncImageSettings(image_info,*image);
1838 color_correction_collection=FileToString(argv[1],~0,exception);
1839 if (color_correction_collection == (char *) NULL)
1840 break;
1841 (void) ColorDecisionListImage(*image,color_correction_collection,
1842 exception);
1843 InheritException(exception,&(*image)->exception);
1844 break;
1845 }
1846 if (LocaleCompare("channel",argv[0]+1) == 0)
1847 {
anthony74b1cfc2011-10-06 12:44:16 +00001848 /* The "channel" setting has already been set */
1849 SetPixelChannelMap(*image,image_info->channel);
anthony805a2d42011-09-25 08:25:12 +00001850 break;
1851 }
1852 if (LocaleCompare("charcoal",argv[0]+1) == 0)
1853 {
anthony805a2d42011-09-25 08:25:12 +00001854 (void) SyncImageSettings(image_info,*image);
1855 flags=ParseGeometry(argv[1],&geometry_info);
1856 if ((flags & SigmaValue) == 0)
1857 geometry_info.sigma=1.0;
1858 if ((flags & XiValue) == 0)
1859 geometry_info.xi=1.0;
1860 new_image=CharcoalImage(*image,geometry_info.rho,
1861 geometry_info.sigma,geometry_info.xi,exception);
1862 break;
1863 }
1864 if (LocaleCompare("chop",argv[0]+1) == 0)
1865 {
anthony805a2d42011-09-25 08:25:12 +00001866 (void) SyncImageSettings(image_info,*image);
1867 (void) ParseGravityGeometry(*image,argv[1],&geometry,exception);
1868 new_image=ChopImage(*image,&geometry,exception);
1869 break;
1870 }
1871 if (LocaleCompare("clamp",argv[0]+1) == 0)
1872 {
anthony805a2d42011-09-25 08:25:12 +00001873 (void) SyncImageSettings(image_info,*image);
cristy092d71c2011-10-14 18:01:29 +00001874 (void) ClampImage(*image,exception);
anthony805a2d42011-09-25 08:25:12 +00001875 break;
1876 }
1877 if (LocaleCompare("clip",argv[0]+1) == 0)
1878 {
1879 (void) SyncImageSettings(image_info,*image);
1880 if (*argv[0] == '+')
1881 {
1882 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1883 break;
1884 }
1885 (void) ClipImage(*image,exception);
1886 break;
1887 }
1888 if (LocaleCompare("clip-mask",argv[0]+1) == 0)
1889 {
1890 CacheView
1891 *mask_view;
1892
1893 Image
1894 *mask_image;
1895
1896 register Quantum
1897 *restrict q;
1898
1899 register ssize_t
1900 x;
1901
1902 ssize_t
1903 y;
1904
1905 (void) SyncImageSettings(image_info,*image);
1906 if (*argv[0] == '+')
1907 {
anthony74b1cfc2011-10-06 12:44:16 +00001908 /* Remove the write mask */
anthony805a2d42011-09-25 08:25:12 +00001909 (void) SetImageMask(*image,(Image *) NULL,exception);
1910 break;
1911 }
1912 mask_image=GetImageCache(image_info,argv[1],exception);
1913 if (mask_image == (Image *) NULL)
1914 break;
1915 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1916 return(MagickFalse);
anthony74b1cfc2011-10-06 12:44:16 +00001917 /* create a write mask from clip-mask image */
1918 /* FUTURE: use Alpha operations instead */
anthony805a2d42011-09-25 08:25:12 +00001919 mask_view=AcquireCacheView(mask_image);
1920 for (y=0; y < (ssize_t) mask_image->rows; y++)
1921 {
1922 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1923 exception);
1924 if (q == (Quantum *) NULL)
1925 break;
1926 for (x=0; x < (ssize_t) mask_image->columns; x++)
1927 {
1928 if (mask_image->matte == MagickFalse)
1929 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1930 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1931 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1932 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1933 q+=GetPixelChannels(mask_image);
1934 }
1935 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1936 break;
1937 }
anthony74b1cfc2011-10-06 12:44:16 +00001938 /* set the write mask */
anthony805a2d42011-09-25 08:25:12 +00001939 mask_view=DestroyCacheView(mask_view);
1940 mask_image->matte=MagickTrue;
anthonya89dd172011-10-04 13:29:35 +00001941 (void) SetImageClipMask(*image,mask_image,exception);
anthony805a2d42011-09-25 08:25:12 +00001942 mask_image=DestroyImage(mask_image);
1943 InheritException(exception,&(*image)->exception);
1944 break;
1945 }
1946 if (LocaleCompare("clip-path",argv[0]+1) == 0)
1947 {
1948 (void) SyncImageSettings(image_info,*image);
1949 (void) ClipImagePath(*image,argv[1],*argv[0] == '-' ? MagickTrue :
1950 MagickFalse,exception);
1951 break;
1952 }
1953 if (LocaleCompare("colorize",argv[0]+1) == 0)
1954 {
anthony805a2d42011-09-25 08:25:12 +00001955 (void) SyncImageSettings(image_info,*image);
1956 new_image=ColorizeImage(*image,argv[1],draw_info->fill,
1957 exception);
1958 break;
1959 }
1960 if (LocaleCompare("color-matrix",argv[0]+1) == 0)
1961 {
1962 KernelInfo
1963 *kernel;
1964
1965 (void) SyncImageSettings(image_info,*image);
1966 kernel=AcquireKernelInfo(argv[1]);
1967 if (kernel == (KernelInfo *) NULL)
1968 break;
1969 new_image=ColorMatrixImage(*image,kernel,exception);
1970 kernel=DestroyKernelInfo(kernel);
1971 break;
1972 }
1973 if (LocaleCompare("colors",argv[0]+1) == 0)
1974 {
anthony74b1cfc2011-10-06 12:44:16 +00001975 /* Reduce the number of colors in the image. */
anthony805a2d42011-09-25 08:25:12 +00001976 (void) SyncImageSettings(image_info,*image);
1977 quantize_info->number_colors=StringToUnsignedLong(argv[1]);
1978 if (quantize_info->number_colors == 0)
1979 break;
1980 if (((*image)->storage_class == DirectClass) ||
1981 (*image)->colors > quantize_info->number_colors)
1982 (void) QuantizeImage(quantize_info,*image,exception);
1983 else
1984 (void) CompressImageColormap(*image,exception);
1985 break;
1986 }
1987 if (LocaleCompare("colorspace",argv[0]+1) == 0)
1988 {
anthonyd2cdc862011-10-07 14:07:17 +00001989 /* This is a Image Setting, which should already been set */
1990 /* FUTURE: default colorspace should be sRGB!
1991 Unless some type of 'linear colorspace' mode is set.
1992 Note that +colorspace sets "undefined" or no effect on
1993 new images, but forces images already in memory back to RGB!
1994 */
anthony805a2d42011-09-25 08:25:12 +00001995 (void) SyncImageSettings(image_info,*image);
anthonyd2cdc862011-10-07 14:07:17 +00001996 (void) TransformImageColorspace(*image,
anthony6613bf32011-10-15 07:24:44 +00001997 IfSetOption ? image_info->colorspace : RGBColorspace,
1998 exception);
anthony805a2d42011-09-25 08:25:12 +00001999 break;
2000 }
2001 if (LocaleCompare("contrast",argv[0]+1) == 0)
2002 {
2003 (void) SyncImageSettings(image_info,*image);
2004 (void) ContrastImage(*image,(*argv[0] == '-') ? MagickTrue :
2005 MagickFalse,exception);
2006 break;
2007 }
2008 if (LocaleCompare("contrast-stretch",argv[0]+1) == 0)
2009 {
2010 double
2011 black_point,
2012 white_point;
2013
2014 MagickStatusType
2015 flags;
2016
2017 /*
2018 Contrast stretch image.
2019 */
2020 (void) SyncImageSettings(image_info,*image);
2021 flags=ParseGeometry(argv[1],&geometry_info);
2022 black_point=geometry_info.rho;
2023 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
2024 black_point;
2025 if ((flags & PercentValue) != 0)
2026 {
2027 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2028 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2029 }
2030 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2031 white_point;
2032 (void) ContrastStretchImage(*image,black_point,white_point,
2033 exception);
2034 InheritException(exception,&(*image)->exception);
2035 break;
2036 }
2037 if (LocaleCompare("convolve",argv[0]+1) == 0)
2038 {
2039 KernelInfo
2040 *kernel_info;
2041
2042 (void) SyncImageSettings(image_info,*image);
2043 kernel_info=AcquireKernelInfo(argv[1]);
2044 if (kernel_info == (KernelInfo *) NULL)
2045 break;
2046 kernel_info->bias=(*image)->bias;
2047 new_image=ConvolveImage(*image,kernel_info,exception);
2048 kernel_info=DestroyKernelInfo(kernel_info);
2049 break;
2050 }
2051 if (LocaleCompare("crop",argv[0]+1) == 0)
2052 {
2053 /*
2054 Crop a image to a smaller size
2055 */
2056 (void) SyncImageSettings(image_info,*image);
2057 new_image=CropImageToTiles(*image,argv[1],exception);
2058 break;
2059 }
2060 if (LocaleCompare("cycle",argv[0]+1) == 0)
2061 {
2062 /*
2063 Cycle an image colormap.
2064 */
2065 (void) SyncImageSettings(image_info,*image);
2066 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[1]),
2067 exception);
2068 break;
2069 }
2070 break;
2071 }
2072 case 'd':
2073 {
2074 if (LocaleCompare("decipher",argv[0]+1) == 0)
2075 {
2076 StringInfo
2077 *passkey;
2078
2079 /*
2080 Decipher pixels.
2081 */
2082 (void) SyncImageSettings(image_info,*image);
2083 passkey=FileToStringInfo(argv[1],~0,exception);
2084 if (passkey != (StringInfo *) NULL)
2085 {
2086 (void) PasskeyDecipherImage(*image,passkey,exception);
2087 passkey=DestroyStringInfo(passkey);
2088 }
2089 break;
2090 }
anthony805a2d42011-09-25 08:25:12 +00002091 if (LocaleCompare("depth",argv[0]+1) == 0)
2092 {
anthony5f867ae2011-10-09 10:28:34 +00002093 /* the image_info->depth setting has already bee set
2094 * We just need to apply it to all images in current sequence */
anthony805a2d42011-09-25 08:25:12 +00002095 (void) SyncImageSettings(image_info,*image);
anthony5f867ae2011-10-09 10:28:34 +00002096 (void) SetImageDepth(*image,image_info->depth);
anthony805a2d42011-09-25 08:25:12 +00002097 break;
2098 }
2099 if (LocaleCompare("deskew",argv[0]+1) == 0)
2100 {
2101 double
2102 threshold;
2103
2104 /*
2105 Straighten the image.
2106 */
2107 (void) SyncImageSettings(image_info,*image);
2108 if (*argv[0] == '+')
2109 threshold=40.0*QuantumRange/100.0;
2110 else
2111 threshold=SiPrefixToDouble(argv[1],QuantumRange);
2112 new_image=DeskewImage(*image,threshold,exception);
2113 break;
2114 }
2115 if (LocaleCompare("despeckle",argv[0]+1) == 0)
2116 {
2117 /*
2118 Reduce the speckles within an image.
2119 */
2120 (void) SyncImageSettings(image_info,*image);
2121 new_image=DespeckleImage(*image,exception);
2122 break;
2123 }
2124 if (LocaleCompare("display",argv[0]+1) == 0)
2125 {
2126 (void) CloneString(&draw_info->server_name,argv[1]);
2127 break;
2128 }
2129 if (LocaleCompare("distort",argv[0]+1) == 0)
2130 {
2131 char
2132 *args,
2133 token[MaxTextExtent];
2134
2135 const char
2136 *p;
2137
2138 DistortImageMethod
2139 method;
2140
2141 double
2142 *arguments;
2143
2144 register ssize_t
2145 x;
2146
2147 size_t
2148 number_arguments;
2149
2150 /*
2151 Distort image.
2152 */
2153 (void) SyncImageSettings(image_info,*image);
2154 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
2155 MagickFalse,argv[1]);
2156 if ( method == ResizeDistortion )
2157 {
2158 /* Special Case - Argument is actually a resize geometry!
2159 ** Convert that to an appropriate distortion argument array.
2160 */
2161 double
2162 resize_args[2];
2163 (void) ParseRegionGeometry(*image,argv[2],&geometry,
2164 exception);
2165 resize_args[0]=(double)geometry.width;
2166 resize_args[1]=(double)geometry.height;
2167 new_image=DistortImage(*image,method,(size_t)2,
2168 resize_args,MagickTrue,exception);
2169 break;
2170 }
2171 args=InterpretImageProperties(image_info,*image,argv[2],
2172 exception);
2173 if (args == (char *) NULL)
2174 break;
2175 p=(char *) args;
2176 for (x=0; *p != '\0'; x++)
2177 {
2178 GetMagickToken(p,&p,token);
2179 if (*token == ',')
2180 GetMagickToken(p,&p,token);
2181 }
2182 number_arguments=(size_t) x;
2183 arguments=(double *) AcquireQuantumMemory(number_arguments,
2184 sizeof(*arguments));
2185 if (arguments == (double *) NULL)
2186 ThrowWandFatalException(ResourceLimitFatalError,
2187 "MemoryAllocationFailed",(*image)->filename);
2188 (void) ResetMagickMemory(arguments,0,number_arguments*
2189 sizeof(*arguments));
2190 p=(char *) args;
2191 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
2192 {
2193 GetMagickToken(p,&p,token);
2194 if (*token == ',')
2195 GetMagickToken(p,&p,token);
2196 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
2197 }
2198 args=DestroyString(args);
2199 new_image=DistortImage(*image,method,number_arguments,arguments,
2200 (*argv[0] == '+') ? MagickTrue : MagickFalse,exception);
2201 arguments=(double *) RelinquishMagickMemory(arguments);
2202 break;
2203 }
anthony805a2d42011-09-25 08:25:12 +00002204 if (LocaleCompare("draw",argv[0]+1) == 0)
2205 {
anthony805a2d42011-09-25 08:25:12 +00002206 (void) SyncImageSettings(image_info,*image);
2207 (void) CloneString(&draw_info->primitive,argv[1]);
2208 (void) DrawImage(*image,draw_info,exception);
2209 break;
2210 }
2211 break;
2212 }
2213 case 'e':
2214 {
2215 if (LocaleCompare("edge",argv[0]+1) == 0)
2216 {
anthony805a2d42011-09-25 08:25:12 +00002217 (void) SyncImageSettings(image_info,*image);
2218 flags=ParseGeometry(argv[1],&geometry_info);
2219 if ((flags & SigmaValue) == 0)
2220 geometry_info.sigma=1.0;
2221 new_image=EdgeImage(*image,geometry_info.rho,
2222 geometry_info.sigma,exception);
2223 break;
2224 }
2225 if (LocaleCompare("emboss",argv[0]+1) == 0)
2226 {
anthony805a2d42011-09-25 08:25:12 +00002227 (void) SyncImageSettings(image_info,*image);
2228 flags=ParseGeometry(argv[1],&geometry_info);
2229 if ((flags & SigmaValue) == 0)
2230 geometry_info.sigma=1.0;
2231 new_image=EmbossImage(*image,geometry_info.rho,
2232 geometry_info.sigma,exception);
2233 break;
2234 }
2235 if (LocaleCompare("encipher",argv[0]+1) == 0)
2236 {
2237 StringInfo
2238 *passkey;
2239
anthony805a2d42011-09-25 08:25:12 +00002240 (void) SyncImageSettings(image_info,*image);
2241 passkey=FileToStringInfo(argv[1],~0,exception);
2242 if (passkey != (StringInfo *) NULL)
2243 {
2244 (void) PasskeyEncipherImage(*image,passkey,exception);
2245 passkey=DestroyStringInfo(passkey);
2246 }
2247 break;
2248 }
anthony805a2d42011-09-25 08:25:12 +00002249 if (LocaleCompare("enhance",argv[0]+1) == 0)
2250 {
anthony805a2d42011-09-25 08:25:12 +00002251 (void) SyncImageSettings(image_info,*image);
2252 new_image=EnhanceImage(*image,exception);
2253 break;
2254 }
2255 if (LocaleCompare("equalize",argv[0]+1) == 0)
2256 {
anthony805a2d42011-09-25 08:25:12 +00002257 (void) SyncImageSettings(image_info,*image);
2258 (void) EqualizeImage(*image,exception);
2259 break;
2260 }
2261 if (LocaleCompare("evaluate",argv[0]+1) == 0)
2262 {
2263 double
2264 constant;
2265
2266 MagickEvaluateOperator
2267 op;
2268
2269 (void) SyncImageSettings(image_info,*image);
2270 op=(MagickEvaluateOperator) ParseCommandOption(
2271 MagickEvaluateOptions,MagickFalse,argv[1]);
2272 constant=SiPrefixToDouble(argv[2],QuantumRange);
2273 (void) EvaluateImage(*image,op,constant,exception);
2274 break;
2275 }
2276 if (LocaleCompare("extent",argv[0]+1) == 0)
2277 {
anthony805a2d42011-09-25 08:25:12 +00002278 (void) SyncImageSettings(image_info,*image);
2279 flags=ParseGravityGeometry(*image,argv[1],&geometry,exception);
2280 if (geometry.width == 0)
2281 geometry.width=(*image)->columns;
2282 if (geometry.height == 0)
2283 geometry.height=(*image)->rows;
2284 new_image=ExtentImage(*image,&geometry,exception);
2285 break;
2286 }
2287 break;
2288 }
2289 case 'f':
2290 {
anthony805a2d42011-09-25 08:25:12 +00002291 if (LocaleCompare("features",argv[0]+1) == 0)
2292 {
anthony6dc09cd2011-10-12 08:56:49 +00002293 /* FUTURE: Assign Artifact all images */
2294 (void) SetImageArtifact(*image,"identify:features",
2295 IfSetOption ? argv[1] : (const char *) NULL);
anthony805a2d42011-09-25 08:25:12 +00002296 break;
2297 }
2298 if (LocaleCompare("flip",argv[0]+1) == 0)
2299 {
2300 /*
2301 Flip image scanlines.
2302 */
2303 (void) SyncImageSettings(image_info,*image);
2304 new_image=FlipImage(*image,exception);
2305 break;
2306 }
2307 if (LocaleCompare("flop",argv[0]+1) == 0)
2308 {
2309 /*
2310 Flop image scanlines.
2311 */
2312 (void) SyncImageSettings(image_info,*image);
2313 new_image=FlopImage(*image,exception);
2314 break;
2315 }
2316 if (LocaleCompare("floodfill",argv[0]+1) == 0)
2317 {
2318 PixelInfo
2319 target;
2320
2321 /*
2322 Floodfill image.
2323 */
2324 (void) SyncImageSettings(image_info,*image);
2325 (void) ParsePageGeometry(*image,argv[1],&geometry,exception);
cristy269c9412011-10-13 23:41:15 +00002326 (void) QueryColorCompliance(argv[2],AllCompliance,&target,
anthonya89dd172011-10-04 13:29:35 +00002327 exception);
anthony805a2d42011-09-25 08:25:12 +00002328 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
2329 geometry.y,*argv[0] == '-' ? MagickFalse : MagickTrue,exception);
2330 break;
2331 }
anthony6dc09cd2011-10-12 08:56:49 +00002332 /* FUTURE: should be from ImageOption "format"
anthony805a2d42011-09-25 08:25:12 +00002333 if (LocaleCompare("format",argv[0]+1) == 0)
2334 {
2335 format=argv[1];
2336 break;
2337 }
anthony6dc09cd2011-10-12 08:56:49 +00002338 */
anthony805a2d42011-09-25 08:25:12 +00002339 if (LocaleCompare("frame",argv[0]+1) == 0)
2340 {
2341 FrameInfo
2342 frame_info;
2343
2344 /*
2345 Surround image with an ornamental border.
2346 */
2347 (void) SyncImageSettings(image_info,*image);
2348 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
2349 frame_info.width=geometry.width;
2350 frame_info.height=geometry.height;
2351 if ((flags & HeightValue) == 0)
2352 frame_info.height=geometry.width;
2353 frame_info.outer_bevel=geometry.x;
2354 frame_info.inner_bevel=geometry.y;
2355 frame_info.x=(ssize_t) frame_info.width;
2356 frame_info.y=(ssize_t) frame_info.height;
2357 frame_info.width=(*image)->columns+2*frame_info.width;
2358 frame_info.height=(*image)->rows+2*frame_info.height;
anthony5f867ae2011-10-09 10:28:34 +00002359 new_image=FrameImage(*image,&frame_info,COMPOSE,exception);
anthony805a2d42011-09-25 08:25:12 +00002360 break;
2361 }
2362 if (LocaleCompare("function",argv[0]+1) == 0)
2363 {
2364 char
2365 *arguments,
2366 token[MaxTextExtent];
2367
2368 const char
2369 *p;
2370
2371 double
2372 *parameters;
2373
2374 MagickFunction
2375 function;
2376
2377 register ssize_t
2378 x;
2379
2380 size_t
2381 number_parameters;
2382
2383 /*
2384 Function Modify Image Values
2385 */
2386 (void) SyncImageSettings(image_info,*image);
2387 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
2388 MagickFalse,argv[1]);
2389 arguments=InterpretImageProperties(image_info,*image,argv[2],
2390 exception);
2391 if (arguments == (char *) NULL)
2392 break;
2393 p=(char *) arguments;
2394 for (x=0; *p != '\0'; x++)
2395 {
2396 GetMagickToken(p,&p,token);
2397 if (*token == ',')
2398 GetMagickToken(p,&p,token);
2399 }
2400 number_parameters=(size_t) x;
2401 parameters=(double *) AcquireQuantumMemory(number_parameters,
2402 sizeof(*parameters));
2403 if (parameters == (double *) NULL)
2404 ThrowWandFatalException(ResourceLimitFatalError,
2405 "MemoryAllocationFailed",(*image)->filename);
2406 (void) ResetMagickMemory(parameters,0,number_parameters*
2407 sizeof(*parameters));
2408 p=(char *) arguments;
2409 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
2410 {
2411 GetMagickToken(p,&p,token);
2412 if (*token == ',')
2413 GetMagickToken(p,&p,token);
2414 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
2415 }
2416 arguments=DestroyString(arguments);
2417 (void) FunctionImage(*image,function,number_parameters,parameters,
2418 exception);
2419 parameters=(double *) RelinquishMagickMemory(parameters);
2420 break;
2421 }
2422 break;
2423 }
2424 case 'g':
2425 {
2426 if (LocaleCompare("gamma",argv[0]+1) == 0)
2427 {
anthony805a2d42011-09-25 08:25:12 +00002428 (void) SyncImageSettings(image_info,*image);
2429 if (*argv[0] == '+')
2430 (*image)->gamma=InterpretLocaleValue(argv[1],(char **) NULL);
2431 else
2432 (void) GammaImage(*image,InterpretLocaleValue(argv[1],
2433 (char **) NULL),exception);
2434 break;
2435 }
2436 if ((LocaleCompare("gaussian-blur",argv[0]+1) == 0) ||
2437 (LocaleCompare("gaussian",argv[0]+1) == 0))
2438 {
anthony805a2d42011-09-25 08:25:12 +00002439 (void) SyncImageSettings(image_info,*image);
2440 flags=ParseGeometry(argv[1],&geometry_info);
2441 if ((flags & SigmaValue) == 0)
2442 geometry_info.sigma=1.0;
2443 if ((flags & XiValue) == 0)
2444 geometry_info.xi=0.0;
2445 new_image=GaussianBlurImage(*image,geometry_info.rho,
2446 geometry_info.sigma,geometry_info.xi,exception);
2447 break;
2448 }
2449 if (LocaleCompare("geometry",argv[0]+1) == 0)
2450 {
2451 /*
anthony6613bf32011-10-15 07:24:44 +00002452 Record Image offset for composition,
2453 Resize last image. -- FUTURE depreciate this aspect
anthony805a2d42011-09-25 08:25:12 +00002454 */
2455 (void) SyncImageSettings(image_info,*image);
2456 if (*argv[0] == '+')
2457 {
2458 if ((*image)->geometry != (char *) NULL)
2459 (*image)->geometry=DestroyString((*image)->geometry);
2460 break;
2461 }
2462 flags=ParseRegionGeometry(*image,argv[1],&geometry,exception);
2463 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
2464 (void) CloneString(&(*image)->geometry,argv[1]);
2465 else
2466 new_image=ResizeImage(*image,geometry.width,geometry.height,
2467 (*image)->filter,(*image)->blur,exception);
2468 break;
2469 }
anthony805a2d42011-09-25 08:25:12 +00002470 break;
2471 }
2472 case 'h':
2473 {
2474 if (LocaleCompare("highlight-color",argv[0]+1) == 0)
2475 {
2476 (void) SetImageArtifact(*image,argv[0]+1,argv[1]);
2477 break;
2478 }
2479 break;
2480 }
2481 case 'i':
2482 {
2483 if (LocaleCompare("identify",argv[0]+1) == 0)
2484 {
2485 char
2486 *text;
2487
2488 (void) SyncImageSettings(image_info,*image);
2489 if (format == (char *) NULL)
2490 {
2491 (void) IdentifyImage(*image,stdout,image_info->verbose,
2492 exception);
2493 break;
2494 }
2495 text=InterpretImageProperties(image_info,*image,format,
2496 exception);
2497 if (text == (char *) NULL)
2498 break;
2499 (void) fputs(text,stdout);
2500 (void) fputc('\n',stdout);
2501 text=DestroyString(text);
2502 break;
2503 }
2504 if (LocaleCompare("implode",argv[0]+1) == 0)
2505 {
2506 /*
2507 Implode image.
2508 */
2509 (void) SyncImageSettings(image_info,*image);
2510 (void) ParseGeometry(argv[1],&geometry_info);
anthonya89dd172011-10-04 13:29:35 +00002511 new_image=ImplodeImage(*image,geometry_info.rho,
2512 interpolate_method,exception);
anthony805a2d42011-09-25 08:25:12 +00002513 break;
2514 }
2515 if (LocaleCompare("interline-spacing",argv[0]+1) == 0)
2516 {
2517 if (*argv[0] == '+')
2518 (void) ParseGeometry("0",&geometry_info);
2519 else
2520 (void) ParseGeometry(argv[1],&geometry_info);
2521 draw_info->interline_spacing=geometry_info.rho;
2522 break;
2523 }
anthonya89dd172011-10-04 13:29:35 +00002524 if (LocaleCompare("interpolate",argv[0]+1) == 0)
2525 {
2526 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
2527 MagickInterpolateOptions,MagickFalse,argv[1]);
2528 break;
2529 }
anthony805a2d42011-09-25 08:25:12 +00002530 if (LocaleCompare("interword-spacing",argv[0]+1) == 0)
2531 {
2532 if (*argv[0] == '+')
2533 (void) ParseGeometry("0",&geometry_info);
2534 else
2535 (void) ParseGeometry(argv[1],&geometry_info);
2536 draw_info->interword_spacing=geometry_info.rho;
2537 break;
2538 }
2539 break;
2540 }
2541 case 'k':
2542 {
2543 if (LocaleCompare("kerning",argv[0]+1) == 0)
2544 {
2545 if (*argv[0] == '+')
2546 (void) ParseGeometry("0",&geometry_info);
2547 else
2548 (void) ParseGeometry(argv[1],&geometry_info);
2549 draw_info->kerning=geometry_info.rho;
2550 break;
2551 }
2552 break;
2553 }
2554 case 'l':
2555 {
2556 if (LocaleCompare("lat",argv[0]+1) == 0)
2557 {
2558 /*
2559 Local adaptive threshold image.
2560 */
2561 (void) SyncImageSettings(image_info,*image);
2562 flags=ParseGeometry(argv[1],&geometry_info);
2563 if ((flags & PercentValue) != 0)
2564 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2565 new_image=AdaptiveThresholdImage(*image,(size_t)
2566 geometry_info.rho,(size_t) geometry_info.sigma,(double)
2567 geometry_info.xi,exception);
2568 break;
2569 }
2570 if (LocaleCompare("level",argv[0]+1) == 0)
2571 {
2572 MagickRealType
2573 black_point,
2574 gamma,
2575 white_point;
2576
2577 MagickStatusType
2578 flags;
2579
2580 /*
2581 Parse levels.
2582 */
2583 (void) SyncImageSettings(image_info,*image);
2584 flags=ParseGeometry(argv[1],&geometry_info);
2585 black_point=geometry_info.rho;
2586 white_point=(MagickRealType) QuantumRange;
2587 if ((flags & SigmaValue) != 0)
2588 white_point=geometry_info.sigma;
2589 gamma=1.0;
2590 if ((flags & XiValue) != 0)
2591 gamma=geometry_info.xi;
2592 if ((flags & PercentValue) != 0)
2593 {
2594 black_point*=(MagickRealType) (QuantumRange/100.0);
2595 white_point*=(MagickRealType) (QuantumRange/100.0);
2596 }
2597 if ((flags & SigmaValue) == 0)
2598 white_point=(MagickRealType) QuantumRange-black_point;
2599 if ((*argv[0] == '+') || ((flags & AspectValue) != 0))
2600 (void) LevelizeImage(*image,black_point,white_point,gamma,
2601 exception);
2602 else
2603 (void) LevelImage(*image,black_point,white_point,gamma,
2604 exception);
2605 InheritException(exception,&(*image)->exception);
2606 break;
2607 }
2608 if (LocaleCompare("level-colors",argv[0]+1) == 0)
2609 {
2610 char
2611 token[MaxTextExtent];
2612
2613 const char
2614 *p;
2615
2616 PixelInfo
2617 black_point,
2618 white_point;
2619
2620 p=(const char *) argv[1];
2621 GetMagickToken(p,&p,token); /* get black point color */
2622 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00002623 (void) QueryColorCompliance(token,AllCompliance,
anthonya89dd172011-10-04 13:29:35 +00002624 &black_point,exception);
anthony805a2d42011-09-25 08:25:12 +00002625 else
cristy269c9412011-10-13 23:41:15 +00002626 (void) QueryColorCompliance("#000000",AllCompliance,
anthonya89dd172011-10-04 13:29:35 +00002627 &black_point,exception);
anthony805a2d42011-09-25 08:25:12 +00002628 if (isalpha((int) token[0]) || (token[0] == '#'))
2629 GetMagickToken(p,&p,token);
2630 if (*token == '\0')
2631 white_point=black_point; /* set everything to that color */
2632 else
2633 {
2634 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2635 GetMagickToken(p,&p,token); /* Get white point color. */
2636 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00002637 (void) QueryColorCompliance(token,AllCompliance,
anthonya89dd172011-10-04 13:29:35 +00002638 &white_point,exception);
anthony805a2d42011-09-25 08:25:12 +00002639 else
cristy269c9412011-10-13 23:41:15 +00002640 (void) QueryColorCompliance("#ffffff",AllCompliance,
anthonya89dd172011-10-04 13:29:35 +00002641 &white_point,exception);
anthony805a2d42011-09-25 08:25:12 +00002642 }
2643 (void) LevelImageColors(*image,&black_point,&white_point,
2644 *argv[0] == '+' ? MagickTrue : MagickFalse,exception);
2645 break;
2646 }
2647 if (LocaleCompare("linear-stretch",argv[0]+1) == 0)
2648 {
2649 double
2650 black_point,
2651 white_point;
2652
2653 MagickStatusType
2654 flags;
2655
2656 (void) SyncImageSettings(image_info,*image);
2657 flags=ParseGeometry(argv[1],&geometry_info);
2658 black_point=geometry_info.rho;
2659 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2660 if ((flags & SigmaValue) != 0)
2661 white_point=geometry_info.sigma;
2662 if ((flags & PercentValue) != 0)
2663 {
2664 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2665 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2666 }
2667 if ((flags & SigmaValue) == 0)
2668 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2669 black_point;
2670 (void) LinearStretchImage(*image,black_point,white_point,exception);
2671 InheritException(exception,&(*image)->exception);
2672 break;
2673 }
2674 if (LocaleCompare("linewidth",argv[0]+1) == 0)
2675 {
2676 draw_info->stroke_width=InterpretLocaleValue(argv[1],
2677 (char **) NULL);
2678 break;
2679 }
2680 if (LocaleCompare("liquid-rescale",argv[0]+1) == 0)
2681 {
2682 /*
2683 Liquid rescale image.
2684 */
2685 (void) SyncImageSettings(image_info,*image);
2686 flags=ParseRegionGeometry(*image,argv[1],&geometry,exception);
2687 if ((flags & XValue) == 0)
2688 geometry.x=1;
2689 if ((flags & YValue) == 0)
2690 geometry.y=0;
2691 new_image=LiquidRescaleImage(*image,geometry.width,
2692 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2693 break;
2694 }
2695 if (LocaleCompare("lowlight-color",argv[0]+1) == 0)
2696 {
2697 (void) SetImageArtifact(*image,argv[0]+1,argv[1]);
2698 break;
2699 }
2700 break;
2701 }
2702 case 'm':
2703 {
2704 if (LocaleCompare("map",argv[0]+1) == 0)
2705 {
2706 Image
2707 *remap_image;
2708
2709 /*
2710 Transform image colors to match this set of colors.
2711 */
2712 (void) SyncImageSettings(image_info,*image);
2713 if (*argv[0] == '+')
2714 break;
2715 remap_image=GetImageCache(image_info,argv[1],exception);
2716 if (remap_image == (Image *) NULL)
2717 break;
2718 (void) RemapImage(quantize_info,*image,remap_image,exception);
2719 remap_image=DestroyImage(remap_image);
2720 break;
2721 }
2722 if (LocaleCompare("mask",argv[0]+1) == 0)
2723 {
2724 Image
2725 *mask;
2726
2727 (void) SyncImageSettings(image_info,*image);
2728 if (*argv[0] == '+')
2729 {
2730 /*
2731 Remove a mask.
2732 */
2733 (void) SetImageMask(*image,(Image *) NULL,exception);
2734 break;
2735 }
2736 /*
2737 Set the image mask.
2738 */
2739 mask=GetImageCache(image_info,argv[1],exception);
2740 if (mask == (Image *) NULL)
2741 break;
2742 (void) SetImageMask(*image,mask,exception);
2743 mask=DestroyImage(mask);
2744 break;
2745 }
2746 if (LocaleCompare("matte",argv[0]+1) == 0)
2747 {
2748 (void) SetImageAlphaChannel(*image,(*argv[0] == '-') ?
2749 SetAlphaChannel : DeactivateAlphaChannel,exception);
2750 break;
2751 }
2752 if (LocaleCompare("median",argv[0]+1) == 0)
2753 {
2754 /*
2755 Median filter image.
2756 */
2757 (void) SyncImageSettings(image_info,*image);
2758 flags=ParseGeometry(argv[1],&geometry_info);
2759 if ((flags & SigmaValue) == 0)
2760 geometry_info.sigma=geometry_info.rho;
2761 new_image=StatisticImage(*image,MedianStatistic,(size_t)
2762 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2763 break;
2764 }
2765 if (LocaleCompare("mode",argv[0]+1) == 0)
2766 {
2767 /*
2768 Mode image.
2769 */
2770 (void) SyncImageSettings(image_info,*image);
2771 flags=ParseGeometry(argv[1],&geometry_info);
2772 if ((flags & SigmaValue) == 0)
2773 geometry_info.sigma=geometry_info.rho;
2774 new_image=StatisticImage(*image,ModeStatistic,(size_t)
2775 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2776 break;
2777 }
2778 if (LocaleCompare("modulate",argv[0]+1) == 0)
2779 {
2780 (void) SyncImageSettings(image_info,*image);
2781 (void) ModulateImage(*image,argv[1],exception);
2782 break;
2783 }
2784 if (LocaleCompare("monitor",argv[0]+1) == 0)
2785 {
2786 if (*argv[0] == '+')
2787 {
2788 (void) SetImageProgressMonitor(*image,
2789 (MagickProgressMonitor) NULL,(void *) NULL);
2790 break;
2791 }
2792 (void) SetImageProgressMonitor(*image,MonitorProgress,
2793 (void *) NULL);
2794 break;
2795 }
2796 if (LocaleCompare("monochrome",argv[0]+1) == 0)
2797 {
2798 (void) SyncImageSettings(image_info,*image);
2799 (void) SetImageType(*image,BilevelType,exception);
2800 break;
2801 }
2802 if (LocaleCompare("morphology",argv[0]+1) == 0)
2803 {
2804 char
2805 token[MaxTextExtent];
2806
2807 const char
2808 *p;
2809
2810 KernelInfo
2811 *kernel;
2812
2813 MorphologyMethod
2814 method;
2815
2816 ssize_t
2817 iterations;
2818
2819 /*
2820 Morphological Image Operation
2821 */
2822 (void) SyncImageSettings(image_info,*image);
2823 p=argv[1];
2824 GetMagickToken(p,&p,token);
2825 method=(MorphologyMethod) ParseCommandOption(
2826 MagickMorphologyOptions,MagickFalse,token);
2827 iterations=1L;
2828 GetMagickToken(p,&p,token);
2829 if ((*p == ':') || (*p == ','))
2830 GetMagickToken(p,&p,token);
2831 if ((*p != '\0'))
2832 iterations=(ssize_t) StringToLong(p);
2833 kernel=AcquireKernelInfo(argv[2]);
2834 if (kernel == (KernelInfo *) NULL)
2835 {
2836 (void) ThrowMagickException(exception,GetMagickModule(),
2837 OptionError,"UnabletoParseKernel","morphology");
2838 status=MagickFalse;
2839 break;
2840 }
2841 new_image=MorphologyImage(*image,method,iterations,kernel,
2842 exception);
2843 kernel=DestroyKernelInfo(kernel);
2844 break;
2845 }
2846 if (LocaleCompare("motion-blur",argv[0]+1) == 0)
2847 {
2848 /*
2849 Motion blur image.
2850 */
2851 (void) SyncImageSettings(image_info,*image);
2852 flags=ParseGeometry(argv[1],&geometry_info);
2853 if ((flags & SigmaValue) == 0)
2854 geometry_info.sigma=1.0;
2855 new_image=MotionBlurImage(*image,geometry_info.rho,
2856 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2857 exception);
2858 break;
2859 }
2860 break;
2861 }
2862 case 'n':
2863 {
2864 if (LocaleCompare("negate",argv[0]+1) == 0)
2865 {
2866 (void) SyncImageSettings(image_info,*image);
2867 (void) NegateImage(*image,*argv[0] == '+' ? MagickTrue :
2868 MagickFalse,exception);
2869 break;
2870 }
2871 if (LocaleCompare("noise",argv[0]+1) == 0)
2872 {
2873 (void) SyncImageSettings(image_info,*image);
2874 if (*argv[0] == '-')
2875 {
2876 flags=ParseGeometry(argv[1],&geometry_info);
2877 if ((flags & SigmaValue) == 0)
2878 geometry_info.sigma=geometry_info.rho;
2879 new_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2880 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2881 }
2882 else
2883 {
2884 NoiseType
2885 noise;
2886
2887 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2888 MagickFalse,argv[1]);
anthony5f867ae2011-10-09 10:28:34 +00002889 new_image=AddNoiseImage(*image,noise,exception);
anthony805a2d42011-09-25 08:25:12 +00002890 }
2891 break;
2892 }
2893 if (LocaleCompare("normalize",argv[0]+1) == 0)
2894 {
2895 (void) SyncImageSettings(image_info,*image);
2896 (void) NormalizeImage(*image,exception);
2897 break;
2898 }
2899 break;
2900 }
2901 case 'o':
2902 {
2903 if (LocaleCompare("opaque",argv[0]+1) == 0)
2904 {
2905 PixelInfo
2906 target;
2907
2908 (void) SyncImageSettings(image_info,*image);
cristy269c9412011-10-13 23:41:15 +00002909 (void) QueryColorCompliance(argv[1],AllCompliance,&target,
anthonya89dd172011-10-04 13:29:35 +00002910 exception);
anthony805a2d42011-09-25 08:25:12 +00002911 (void) OpaquePaintImage(*image,&target,&fill,*argv[0] == '-' ?
2912 MagickFalse : MagickTrue,exception);
2913 break;
2914 }
2915 if (LocaleCompare("ordered-dither",argv[0]+1) == 0)
2916 {
2917 (void) SyncImageSettings(image_info,*image);
2918 (void) OrderedPosterizeImage(*image,argv[1],exception);
2919 break;
2920 }
2921 break;
2922 }
2923 case 'p':
2924 {
2925 if (LocaleCompare("paint",argv[0]+1) == 0)
2926 {
2927 (void) SyncImageSettings(image_info,*image);
2928 (void) ParseGeometry(argv[1],&geometry_info);
2929 new_image=OilPaintImage(*image,geometry_info.rho,
2930 geometry_info.sigma,exception);
2931 break;
2932 }
2933 if (LocaleCompare("pen",argv[0]+1) == 0)
2934 {
2935 if (*argv[0] == '+')
2936 {
anthony1afdc7a2011-10-05 11:54:28 +00002937 (void) QueryColorCompliance("none",AllCompliance,&draw_info->fill,
anthonya89dd172011-10-04 13:29:35 +00002938 exception);
anthony805a2d42011-09-25 08:25:12 +00002939 break;
2940 }
anthony1afdc7a2011-10-05 11:54:28 +00002941 (void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->fill,
anthonya89dd172011-10-04 13:29:35 +00002942 exception);
anthony805a2d42011-09-25 08:25:12 +00002943 break;
2944 }
2945 if (LocaleCompare("pointsize",argv[0]+1) == 0)
2946 {
2947 if (*argv[0] == '+')
2948 (void) ParseGeometry("12",&geometry_info);
2949 else
2950 (void) ParseGeometry(argv[1],&geometry_info);
2951 draw_info->pointsize=geometry_info.rho;
2952 break;
2953 }
2954 if (LocaleCompare("polaroid",argv[0]+1) == 0)
2955 {
2956 double
2957 angle;
2958
2959 RandomInfo
2960 *random_info;
2961
2962 /*
2963 Simulate a Polaroid picture.
2964 */
2965 (void) SyncImageSettings(image_info,*image);
2966 random_info=AcquireRandomInfo();
2967 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2968 random_info=DestroyRandomInfo(random_info);
2969 if (*argv[0] == '-')
2970 {
2971 SetGeometryInfo(&geometry_info);
2972 flags=ParseGeometry(argv[1],&geometry_info);
2973 angle=geometry_info.rho;
2974 }
2975 new_image=PolaroidImage(*image,draw_info,angle,
2976 interpolate_method,exception);
2977 break;
2978 }
2979 if (LocaleCompare("posterize",argv[0]+1) == 0)
2980 {
2981 /*
2982 Posterize image.
2983 */
2984 (void) SyncImageSettings(image_info,*image);
2985 (void) PosterizeImage(*image,StringToUnsignedLong(argv[1]),
2986 quantize_info->dither,exception);
2987 break;
2988 }
2989 if (LocaleCompare("preview",argv[0]+1) == 0)
2990 {
2991 PreviewType
2992 preview_type;
2993
2994 /*
2995 Preview image.
2996 */
2997 (void) SyncImageSettings(image_info,*image);
2998 if (*argv[0] == '+')
2999 preview_type=UndefinedPreview;
3000 else
3001 preview_type=(PreviewType) ParseCommandOption(
3002 MagickPreviewOptions,MagickFalse,argv[1]);
3003 new_image=PreviewImage(*image,preview_type,exception);
3004 break;
3005 }
3006 if (LocaleCompare("profile",argv[0]+1) == 0)
3007 {
3008 const char
3009 *name;
3010
3011 const StringInfo
3012 *profile;
3013
3014 Image
3015 *profile_image;
3016
3017 ImageInfo
3018 *profile_info;
3019
3020 (void) SyncImageSettings(image_info,*image);
3021 if (*argv[0] == '+')
3022 {
3023 /*
3024 Remove a profile from the image.
3025 */
3026 (void) ProfileImage(*image,argv[1],(const unsigned char *)
cristy092d71c2011-10-14 18:01:29 +00003027 NULL,0,exception);
anthony805a2d42011-09-25 08:25:12 +00003028 break;
3029 }
3030 /*
3031 Associate a profile with the image.
3032 */
3033 profile_info=CloneImageInfo(image_info);
3034 profile=GetImageProfile(*image,"iptc");
3035 if (profile != (StringInfo *) NULL)
3036 profile_info->profile=(void *) CloneStringInfo(profile);
3037 profile_image=GetImageCache(profile_info,argv[1],exception);
3038 profile_info=DestroyImageInfo(profile_info);
3039 if (profile_image == (Image *) NULL)
3040 {
3041 StringInfo
3042 *profile;
3043
3044 profile_info=CloneImageInfo(image_info);
3045 (void) CopyMagickString(profile_info->filename,argv[1],
3046 MaxTextExtent);
3047 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
3048 if (profile != (StringInfo *) NULL)
3049 {
3050 (void) ProfileImage(*image,profile_info->magick,
3051 GetStringInfoDatum(profile),(size_t)
cristy092d71c2011-10-14 18:01:29 +00003052 GetStringInfoLength(profile),exception);
anthony805a2d42011-09-25 08:25:12 +00003053 profile=DestroyStringInfo(profile);
3054 }
3055 profile_info=DestroyImageInfo(profile_info);
3056 break;
3057 }
3058 ResetImageProfileIterator(profile_image);
3059 name=GetNextImageProfile(profile_image);
3060 while (name != (const char *) NULL)
3061 {
3062 profile=GetImageProfile(profile_image,name);
3063 if (profile != (StringInfo *) NULL)
3064 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
cristy092d71c2011-10-14 18:01:29 +00003065 (size_t) GetStringInfoLength(profile),exception);
anthony805a2d42011-09-25 08:25:12 +00003066 name=GetNextImageProfile(profile_image);
3067 }
3068 profile_image=DestroyImage(profile_image);
3069 break;
3070 }
3071 break;
3072 }
3073 case 'q':
3074 {
3075 if (LocaleCompare("quantize",argv[0]+1) == 0)
3076 {
3077 if (*argv[0] == '+')
3078 {
3079 quantize_info->colorspace=UndefinedColorspace;
3080 break;
3081 }
3082 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
3083 MagickColorspaceOptions,MagickFalse,argv[1]);
3084 break;
3085 }
3086 break;
3087 }
3088 case 'r':
3089 {
3090 if (LocaleCompare("radial-blur",argv[0]+1) == 0)
3091 {
3092 /*
3093 Radial blur image.
3094 */
3095 (void) SyncImageSettings(image_info,*image);
3096 flags=ParseGeometry(argv[1],&geometry_info);
3097 new_image=RadialBlurImage(*image,geometry_info.rho,
3098 geometry_info.sigma,exception);
3099 break;
3100 }
3101 if (LocaleCompare("raise",argv[0]+1) == 0)
3102 {
3103 /*
3104 Surround image with a raise of solid color.
3105 */
3106 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
3107 if ((flags & SigmaValue) == 0)
3108 geometry.height=geometry.width;
3109 (void) RaiseImage(*image,&geometry,*argv[0] == '-' ? MagickTrue :
3110 MagickFalse,exception);
3111 break;
3112 }
3113 if (LocaleCompare("random-threshold",argv[0]+1) == 0)
3114 {
3115 /*
3116 Threshold image.
3117 */
3118 (void) SyncImageSettings(image_info,*image);
3119 (void) RandomThresholdImage(*image,argv[1],exception);
3120 break;
3121 }
3122 if (LocaleCompare("recolor",argv[0]+1) == 0)
3123 {
3124 KernelInfo
3125 *kernel;
3126
3127 (void) SyncImageSettings(image_info,*image);
3128 kernel=AcquireKernelInfo(argv[1]);
3129 if (kernel == (KernelInfo *) NULL)
3130 break;
3131 new_image=ColorMatrixImage(*image,kernel,exception);
3132 kernel=DestroyKernelInfo(kernel);
3133 break;
3134 }
3135 if (LocaleCompare("render",argv[0]+1) == 0)
3136 {
3137 (void) SyncImageSettings(image_info,*image);
3138 draw_info->render=(*argv[0] == '+') ? MagickTrue : MagickFalse;
3139 break;
3140 }
3141 if (LocaleCompare("remap",argv[0]+1) == 0)
3142 {
3143 Image
3144 *remap_image;
3145
3146 /*
3147 Transform image colors to match this set of colors.
3148 */
3149 (void) SyncImageSettings(image_info,*image);
3150 if (*argv[0] == '+')
3151 break;
3152 remap_image=GetImageCache(image_info,argv[1],exception);
3153 if (remap_image == (Image *) NULL)
3154 break;
3155 (void) RemapImage(quantize_info,*image,remap_image,exception);
3156 remap_image=DestroyImage(remap_image);
3157 break;
3158 }
3159 if (LocaleCompare("repage",argv[0]+1) == 0)
3160 {
3161 if (*argv[0] == '+')
3162 {
3163 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
3164 break;
3165 }
3166 (void) ResetImagePage(*image,argv[1]);
3167 InheritException(exception,&(*image)->exception);
3168 break;
3169 }
3170 if (LocaleCompare("resample",argv[0]+1) == 0)
3171 {
3172 /*
3173 Resample image.
3174 */
3175 (void) SyncImageSettings(image_info,*image);
3176 flags=ParseGeometry(argv[1],&geometry_info);
3177 if ((flags & SigmaValue) == 0)
3178 geometry_info.sigma=geometry_info.rho;
3179 new_image=ResampleImage(*image,geometry_info.rho,
3180 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
3181 break;
3182 }
3183 if (LocaleCompare("resize",argv[0]+1) == 0)
3184 {
3185 /*
3186 Resize image.
3187 */
3188 (void) SyncImageSettings(image_info,*image);
3189 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3190 new_image=ResizeImage(*image,geometry.width,geometry.height,
3191 (*image)->filter,(*image)->blur,exception);
3192 break;
3193 }
3194 if (LocaleCompare("roll",argv[0]+1) == 0)
3195 {
3196 /*
3197 Roll image.
3198 */
3199 (void) SyncImageSettings(image_info,*image);
3200 (void) ParsePageGeometry(*image,argv[1],&geometry,exception);
3201 new_image=RollImage(*image,geometry.x,geometry.y,exception);
3202 break;
3203 }
3204 if (LocaleCompare("rotate",argv[0]+1) == 0)
3205 {
3206 char
3207 *geometry;
3208
3209 /*
3210 Check for conditional image rotation.
3211 */
3212 (void) SyncImageSettings(image_info,*image);
3213 if (strchr(argv[1],'>') != (char *) NULL)
3214 if ((*image)->columns <= (*image)->rows)
3215 break;
3216 if (strchr(argv[1],'<') != (char *) NULL)
3217 if ((*image)->columns >= (*image)->rows)
3218 break;
3219 /*
3220 Rotate image.
3221 */
3222 geometry=ConstantString(argv[1]);
3223 (void) SubstituteString(&geometry,">","");
3224 (void) SubstituteString(&geometry,"<","");
3225 (void) ParseGeometry(geometry,&geometry_info);
3226 geometry=DestroyString(geometry);
3227 new_image=RotateImage(*image,geometry_info.rho,exception);
3228 break;
3229 }
3230 break;
3231 }
3232 case 's':
3233 {
3234 if (LocaleCompare("sample",argv[0]+1) == 0)
3235 {
3236 /*
3237 Sample image with pixel replication.
3238 */
3239 (void) SyncImageSettings(image_info,*image);
3240 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3241 new_image=SampleImage(*image,geometry.width,geometry.height,
3242 exception);
3243 break;
3244 }
3245 if (LocaleCompare("scale",argv[0]+1) == 0)
3246 {
3247 /*
3248 Resize image.
3249 */
3250 (void) SyncImageSettings(image_info,*image);
3251 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3252 new_image=ScaleImage(*image,geometry.width,geometry.height,
3253 exception);
3254 break;
3255 }
3256 if (LocaleCompare("selective-blur",argv[0]+1) == 0)
3257 {
3258 /*
3259 Selectively blur pixels within a contrast threshold.
3260 */
3261 (void) SyncImageSettings(image_info,*image);
3262 flags=ParseGeometry(argv[1],&geometry_info);
3263 if ((flags & PercentValue) != 0)
3264 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
3265 new_image=SelectiveBlurImage(*image,geometry_info.rho,
3266 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3267 break;
3268 }
3269 if (LocaleCompare("separate",argv[0]+1) == 0)
3270 {
3271 /*
3272 Break channels into separate images.
3273 WARNING: This can generate multiple images!
3274 */
3275 (void) SyncImageSettings(image_info,*image);
3276 new_image=SeparateImages(*image,exception);
3277 break;
3278 }
3279 if (LocaleCompare("sepia-tone",argv[0]+1) == 0)
3280 {
3281 double
3282 threshold;
3283
3284 /*
3285 Sepia-tone image.
3286 */
3287 (void) SyncImageSettings(image_info,*image);
3288 threshold=SiPrefixToDouble(argv[1],QuantumRange);
3289 new_image=SepiaToneImage(*image,threshold,exception);
3290 break;
3291 }
3292 if (LocaleCompare("segment",argv[0]+1) == 0)
3293 {
3294 /*
3295 Segment image.
3296 */
3297 (void) SyncImageSettings(image_info,*image);
3298 flags=ParseGeometry(argv[1],&geometry_info);
3299 if ((flags & SigmaValue) == 0)
3300 geometry_info.sigma=1.0;
3301 (void) SegmentImage(*image,(*image)->colorspace,
3302 image_info->verbose,geometry_info.rho,geometry_info.sigma,
3303 exception);
3304 break;
3305 }
3306 if (LocaleCompare("set",argv[0]+1) == 0)
3307 {
3308 char
3309 *value;
3310
anthony805a2d42011-09-25 08:25:12 +00003311 if (*argv[0] == '+')
3312 {
3313 if (LocaleNCompare(argv[1],"registry:",9) == 0)
3314 (void) DeleteImageRegistry(argv[1]+9);
3315 else
3316 if (LocaleNCompare(argv[1],"argv[0]:",7) == 0)
3317 {
3318 (void) DeleteImageOption(image_info,argv[1]+7);
3319 (void) DeleteImageArtifact(*image,argv[1]+7);
3320 }
3321 else
3322 (void) DeleteImageProperty(*image,argv[1]);
3323 break;
3324 }
3325 value=InterpretImageProperties(image_info,*image,argv[2],
3326 exception);
3327 if (value == (char *) NULL)
3328 break;
3329 if (LocaleNCompare(argv[1],"registry:",9) == 0)
3330 (void) SetImageRegistry(StringRegistryType,argv[1]+9,value,
3331 exception);
3332 else
anthonya89dd172011-10-04 13:29:35 +00003333 if (LocaleNCompare(argv[1],"option:",7) == 0)
anthony805a2d42011-09-25 08:25:12 +00003334 {
3335 (void) SetImageOption(image_info,argv[1]+7,value);
anthony805a2d42011-09-25 08:25:12 +00003336 (void) SetImageArtifact(*image,argv[1]+7,value);
3337 }
3338 else
cristyd15e6592011-10-15 00:13:06 +00003339 (void) SetImageProperty(*image,argv[1],value,exception);
anthony805a2d42011-09-25 08:25:12 +00003340 value=DestroyString(value);
3341 break;
3342 }
3343 if (LocaleCompare("shade",argv[0]+1) == 0)
3344 {
3345 /*
3346 Shade image.
3347 */
3348 (void) SyncImageSettings(image_info,*image);
3349 flags=ParseGeometry(argv[1],&geometry_info);
3350 if ((flags & SigmaValue) == 0)
3351 geometry_info.sigma=1.0;
3352 new_image=ShadeImage(*image,(*argv[0] == '-') ? MagickTrue :
3353 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
3354 break;
3355 }
3356 if (LocaleCompare("shadow",argv[0]+1) == 0)
3357 {
3358 /*
3359 Shadow image.
3360 */
3361 (void) SyncImageSettings(image_info,*image);
3362 flags=ParseGeometry(argv[1],&geometry_info);
3363 if ((flags & SigmaValue) == 0)
3364 geometry_info.sigma=1.0;
3365 if ((flags & XiValue) == 0)
3366 geometry_info.xi=4.0;
3367 if ((flags & PsiValue) == 0)
3368 geometry_info.psi=4.0;
3369 new_image=ShadowImage(*image,geometry_info.rho,
3370 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3371 ceil(geometry_info.psi-0.5),exception);
3372 break;
3373 }
3374 if (LocaleCompare("sharpen",argv[0]+1) == 0)
3375 {
3376 /*
3377 Sharpen image.
3378 */
3379 (void) SyncImageSettings(image_info,*image);
3380 flags=ParseGeometry(argv[1],&geometry_info);
3381 if ((flags & SigmaValue) == 0)
3382 geometry_info.sigma=1.0;
3383 if ((flags & XiValue) == 0)
3384 geometry_info.xi=0.0;
3385 new_image=SharpenImage(*image,geometry_info.rho,
3386 geometry_info.sigma,geometry_info.xi,exception);
3387 break;
3388 }
3389 if (LocaleCompare("shave",argv[0]+1) == 0)
3390 {
3391 /*
3392 Shave the image edges.
3393 */
3394 (void) SyncImageSettings(image_info,*image);
3395 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
3396 new_image=ShaveImage(*image,&geometry,exception);
3397 break;
3398 }
3399 if (LocaleCompare("shear",argv[0]+1) == 0)
3400 {
3401 /*
3402 Shear image.
3403 */
3404 (void) SyncImageSettings(image_info,*image);
3405 flags=ParseGeometry(argv[1],&geometry_info);
3406 if ((flags & SigmaValue) == 0)
3407 geometry_info.sigma=geometry_info.rho;
3408 new_image=ShearImage(*image,geometry_info.rho,
3409 geometry_info.sigma,exception);
3410 break;
3411 }
3412 if (LocaleCompare("sigmoidal-contrast",argv[0]+1) == 0)
3413 {
3414 /*
3415 Sigmoidal non-linearity contrast control.
3416 */
3417 (void) SyncImageSettings(image_info,*image);
3418 flags=ParseGeometry(argv[1],&geometry_info);
3419 if ((flags & SigmaValue) == 0)
3420 geometry_info.sigma=(double) QuantumRange/2.0;
3421 if ((flags & PercentValue) != 0)
3422 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3423 100.0;
3424 (void) SigmoidalContrastImage(*image,(*argv[0] == '-') ?
3425 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
3426 exception);
3427 break;
3428 }
3429 if (LocaleCompare("sketch",argv[0]+1) == 0)
3430 {
3431 /*
3432 Sketch image.
3433 */
3434 (void) SyncImageSettings(image_info,*image);
3435 flags=ParseGeometry(argv[1],&geometry_info);
3436 if ((flags & SigmaValue) == 0)
3437 geometry_info.sigma=1.0;
3438 new_image=SketchImage(*image,geometry_info.rho,
3439 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3440 break;
3441 }
3442 if (LocaleCompare("solarize",argv[0]+1) == 0)
3443 {
3444 double
3445 threshold;
3446
3447 (void) SyncImageSettings(image_info,*image);
3448 threshold=SiPrefixToDouble(argv[1],QuantumRange);
3449 (void) SolarizeImage(*image,threshold,exception);
3450 break;
3451 }
3452 if (LocaleCompare("sparse-color",argv[0]+1) == 0)
3453 {
3454 SparseColorMethod
3455 method;
3456
3457 char
3458 *arguments;
3459
3460 /*
3461 Sparse Color Interpolated Gradient
3462 */
3463 (void) SyncImageSettings(image_info,*image);
3464 method=(SparseColorMethod) ParseCommandOption(
3465 MagickSparseColorOptions,MagickFalse,argv[1]);
3466 arguments=InterpretImageProperties(image_info,*image,argv[2],
3467 exception);
3468 if (arguments == (char *) NULL)
3469 break;
3470 new_image=SparseColorOption(*image,method,arguments,
3471 argv[0][0] == '+' ? MagickTrue : MagickFalse,exception);
3472 arguments=DestroyString(arguments);
3473 break;
3474 }
3475 if (LocaleCompare("splice",argv[0]+1) == 0)
3476 {
3477 /*
3478 Splice a solid color into the image.
3479 */
3480 (void) SyncImageSettings(image_info,*image);
3481 (void) ParseGravityGeometry(*image,argv[1],&geometry,exception);
3482 new_image=SpliceImage(*image,&geometry,exception);
3483 break;
3484 }
3485 if (LocaleCompare("spread",argv[0]+1) == 0)
3486 {
3487 /*
3488 Spread an image.
3489 */
3490 (void) SyncImageSettings(image_info,*image);
3491 (void) ParseGeometry(argv[1],&geometry_info);
3492 new_image=SpreadImage(*image,geometry_info.rho,
3493 interpolate_method,exception);
3494 break;
3495 }
3496 if (LocaleCompare("statistic",argv[0]+1) == 0)
3497 {
3498 StatisticType
3499 type;
3500
3501 (void) SyncImageSettings(image_info,*image);
3502 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
3503 MagickFalse,argv[1]);
3504 (void) ParseGeometry(argv[2],&geometry_info);
3505 new_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
3506 (size_t) geometry_info.sigma,exception);
3507 break;
3508 }
3509 if (LocaleCompare("stretch",argv[0]+1) == 0)
3510 {
3511 if (*argv[0] == '+')
3512 {
3513 draw_info->stretch=UndefinedStretch;
3514 break;
3515 }
3516 draw_info->stretch=(StretchType) ParseCommandOption(
3517 MagickStretchOptions,MagickFalse,argv[1]);
3518 break;
3519 }
3520 if (LocaleCompare("strip",argv[0]+1) == 0)
3521 {
3522 /*
3523 Strip image of profiles and comments.
3524 */
3525 (void) SyncImageSettings(image_info,*image);
anthony6613bf32011-10-15 07:24:44 +00003526 (void) StripImage(*image,exception);
anthony805a2d42011-09-25 08:25:12 +00003527 break;
3528 }
3529 if (LocaleCompare("stroke",argv[0]+1) == 0)
3530 {
3531 ExceptionInfo
3532 *sans;
3533
3534 if (*argv[0] == '+')
3535 {
anthony1afdc7a2011-10-05 11:54:28 +00003536 (void) QueryColorCompliance("none",AllCompliance,&draw_info->stroke,
anthonya89dd172011-10-04 13:29:35 +00003537 exception);
anthony805a2d42011-09-25 08:25:12 +00003538 if (draw_info->stroke_pattern != (Image *) NULL)
3539 draw_info->stroke_pattern=DestroyImage(
3540 draw_info->stroke_pattern);
3541 break;
3542 }
3543 sans=AcquireExceptionInfo();
anthony1afdc7a2011-10-05 11:54:28 +00003544 status=QueryColorCompliance(argv[1],AllCompliance,&draw_info->stroke,sans);
anthony805a2d42011-09-25 08:25:12 +00003545 sans=DestroyExceptionInfo(sans);
3546 if (status == MagickFalse)
3547 draw_info->stroke_pattern=GetImageCache(image_info,argv[1],
3548 exception);
3549 break;
3550 }
3551 if (LocaleCompare("strokewidth",argv[0]+1) == 0)
3552 {
3553 draw_info->stroke_width=InterpretLocaleValue(argv[1],
3554 (char **) NULL);
3555 break;
3556 }
3557 if (LocaleCompare("style",argv[0]+1) == 0)
3558 {
3559 if (*argv[0] == '+')
3560 {
3561 draw_info->style=UndefinedStyle;
3562 break;
3563 }
3564 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3565 MagickFalse,argv[1]);
3566 break;
3567 }
3568 if (LocaleCompare("swirl",argv[0]+1) == 0)
3569 {
3570 /*
3571 Swirl image.
3572 */
3573 (void) SyncImageSettings(image_info,*image);
3574 (void) ParseGeometry(argv[1],&geometry_info);
3575 new_image=SwirlImage(*image,geometry_info.rho,
3576 interpolate_method,exception);
3577 break;
3578 }
3579 break;
3580 }
3581 case 't':
3582 {
3583 if (LocaleCompare("threshold",argv[0]+1) == 0)
3584 {
3585 double
3586 threshold;
3587
3588 /*
3589 Threshold image.
3590 */
3591 (void) SyncImageSettings(image_info,*image);
3592 if (*argv[0] == '+')
3593 threshold=(double) QuantumRange/2;
3594 else
3595 threshold=SiPrefixToDouble(argv[1],QuantumRange);
anthony6613bf32011-10-15 07:24:44 +00003596 (void) BilevelImage(*image,threshold,exception);
anthony805a2d42011-09-25 08:25:12 +00003597 break;
3598 }
3599 if (LocaleCompare("thumbnail",argv[0]+1) == 0)
3600 {
3601 /*
3602 Thumbnail image.
3603 */
3604 (void) SyncImageSettings(image_info,*image);
3605 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3606 new_image=ThumbnailImage(*image,geometry.width,geometry.height,
3607 exception);
3608 break;
3609 }
3610 if (LocaleCompare("tile",argv[0]+1) == 0)
3611 {
3612 if (*argv[0] == '+')
3613 {
3614 if (draw_info->fill_pattern != (Image *) NULL)
3615 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3616 break;
3617 }
3618 draw_info->fill_pattern=GetImageCache(image_info,argv[1],
3619 exception);
3620 break;
3621 }
3622 if (LocaleCompare("tint",argv[0]+1) == 0)
3623 {
3624 /*
3625 Tint the image.
3626 */
3627 (void) SyncImageSettings(image_info,*image);
3628 new_image=TintImage(*image,argv[1],&fill,exception);
3629 break;
3630 }
3631 if (LocaleCompare("transform",argv[0]+1) == 0)
3632 {
3633 /*
3634 Affine transform image.
3635 */
3636 (void) SyncImageSettings(image_info,*image);
3637 new_image=AffineTransformImage(*image,&draw_info->affine,
3638 exception);
3639 break;
3640 }
3641 if (LocaleCompare("transparent",argv[0]+1) == 0)
3642 {
3643 PixelInfo
3644 target;
3645
3646 (void) SyncImageSettings(image_info,*image);
cristy269c9412011-10-13 23:41:15 +00003647 (void) QueryColorCompliance(argv[1],AllCompliance,&target,
anthonya89dd172011-10-04 13:29:35 +00003648 exception);
anthony805a2d42011-09-25 08:25:12 +00003649 (void) TransparentPaintImage(*image,&target,(Quantum)
3650 TransparentAlpha,*argv[0] == '-' ? MagickFalse : MagickTrue,
3651 &(*image)->exception);
3652 break;
3653 }
3654 if (LocaleCompare("transpose",argv[0]+1) == 0)
3655 {
3656 /*
3657 Transpose image scanlines.
3658 */
3659 (void) SyncImageSettings(image_info,*image);
3660 new_image=TransposeImage(*image,exception);
3661 break;
3662 }
3663 if (LocaleCompare("transverse",argv[0]+1) == 0)
3664 {
3665 /*
3666 Transverse image scanlines.
3667 */
3668 (void) SyncImageSettings(image_info,*image);
3669 new_image=TransverseImage(*image,exception);
3670 break;
3671 }
3672 if (LocaleCompare("treedepth",argv[0]+1) == 0)
3673 {
3674 quantize_info->tree_depth=StringToUnsignedLong(argv[1]);
3675 break;
3676 }
3677 if (LocaleCompare("trim",argv[0]+1) == 0)
3678 {
3679 /*
3680 Trim image.
3681 */
3682 (void) SyncImageSettings(image_info,*image);
3683 new_image=TrimImage(*image,exception);
3684 break;
3685 }
3686 if (LocaleCompare("type",argv[0]+1) == 0)
3687 {
3688 ImageType
3689 type;
3690
3691 (void) SyncImageSettings(image_info,*image);
3692 if (*argv[0] == '+')
3693 type=UndefinedType;
3694 else
3695 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3696 argv[1]);
3697 (*image)->type=UndefinedType;
3698 (void) SetImageType(*image,type,exception);
3699 break;
3700 }
3701 break;
3702 }
3703 case 'u':
3704 {
3705 if (LocaleCompare("undercolor",argv[0]+1) == 0)
3706 {
anthony1afdc7a2011-10-05 11:54:28 +00003707 (void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->undercolor,
anthony805a2d42011-09-25 08:25:12 +00003708 exception);
3709 break;
3710 }
3711 if (LocaleCompare("unique",argv[0]+1) == 0)
3712 {
3713 if (*argv[0] == '+')
3714 {
3715 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3716 break;
3717 }
3718 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3719 (void) SetImageArtifact(*image,"verbose","true");
3720 break;
3721 }
3722 if (LocaleCompare("unique-colors",argv[0]+1) == 0)
3723 {
3724 /*
3725 Unique image colors.
3726 */
3727 (void) SyncImageSettings(image_info,*image);
3728 new_image=UniqueImageColors(*image,exception);
3729 break;
3730 }
3731 if (LocaleCompare("unsharp",argv[0]+1) == 0)
3732 {
3733 /*
3734 Unsharp mask image.
3735 */
3736 (void) SyncImageSettings(image_info,*image);
3737 flags=ParseGeometry(argv[1],&geometry_info);
3738 if ((flags & SigmaValue) == 0)
3739 geometry_info.sigma=1.0;
3740 if ((flags & XiValue) == 0)
3741 geometry_info.xi=1.0;
3742 if ((flags & PsiValue) == 0)
3743 geometry_info.psi=0.05;
3744 new_image=UnsharpMaskImage(*image,geometry_info.rho,
3745 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3746 break;
3747 }
3748 break;
3749 }
3750 case 'v':
3751 {
3752 if (LocaleCompare("verbose",argv[0]+1) == 0)
3753 {
3754 (void) SetImageArtifact(*image,argv[0]+1,
3755 *argv[0] == '+' ? "false" : "true");
3756 break;
3757 }
3758 if (LocaleCompare("vignette",argv[0]+1) == 0)
3759 {
3760 /*
3761 Vignette image.
3762 */
3763 (void) SyncImageSettings(image_info,*image);
3764 flags=ParseGeometry(argv[1],&geometry_info);
3765 if ((flags & SigmaValue) == 0)
3766 geometry_info.sigma=1.0;
3767 if ((flags & XiValue) == 0)
3768 geometry_info.xi=0.1*(*image)->columns;
3769 if ((flags & PsiValue) == 0)
3770 geometry_info.psi=0.1*(*image)->rows;
3771 new_image=VignetteImage(*image,geometry_info.rho,
3772 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3773 ceil(geometry_info.psi-0.5),exception);
3774 break;
3775 }
3776 if (LocaleCompare("virtual-pixel",argv[0]+1) == 0)
3777 {
3778 if (*argv[0] == '+')
3779 {
3780 (void) SetImageVirtualPixelMethod(*image,
3781 UndefinedVirtualPixelMethod);
3782 break;
3783 }
3784 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3785 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3786 argv[1]));
3787 break;
3788 }
3789 break;
3790 }
3791 case 'w':
3792 {
3793 if (LocaleCompare("wave",argv[0]+1) == 0)
3794 {
3795 /*
3796 Wave image.
3797 */
3798 (void) SyncImageSettings(image_info,*image);
3799 flags=ParseGeometry(argv[1],&geometry_info);
3800 if ((flags & SigmaValue) == 0)
3801 geometry_info.sigma=1.0;
3802 new_image=WaveImage(*image,geometry_info.rho,
anthonya89dd172011-10-04 13:29:35 +00003803 geometry_info.sigma,interpolate_method,exception);
anthony805a2d42011-09-25 08:25:12 +00003804 break;
3805 }
3806 if (LocaleCompare("weight",argv[0]+1) == 0)
3807 {
3808 draw_info->weight=StringToUnsignedLong(argv[1]);
3809 if (LocaleCompare(argv[1],"all") == 0)
3810 draw_info->weight=0;
3811 if (LocaleCompare(argv[1],"bold") == 0)
3812 draw_info->weight=700;
3813 if (LocaleCompare(argv[1],"bolder") == 0)
3814 if (draw_info->weight <= 800)
3815 draw_info->weight+=100;
3816 if (LocaleCompare(argv[1],"lighter") == 0)
3817 if (draw_info->weight >= 100)
3818 draw_info->weight-=100;
3819 if (LocaleCompare(argv[1],"normal") == 0)
3820 draw_info->weight=400;
3821 break;
3822 }
3823 if (LocaleCompare("white-threshold",argv[0]+1) == 0)
3824 {
3825 /*
3826 White threshold image.
3827 */
3828 (void) SyncImageSettings(image_info,*image);
3829 (void) WhiteThresholdImage(*image,argv[1],exception);
3830 InheritException(exception,&(*image)->exception);
3831 break;
3832 }
3833 break;
3834 }
3835 default:
3836 break;
3837 }
3838 /*
3839 Replace current image with any image that was generated
3840 */
3841 if (new_image != (Image *) NULL)
3842 ReplaceImageInListReturnLast(image,new_image);
3843
3844 /*
3845 Free resources.
3846 */
3847 quantize_info=DestroyQuantizeInfo(quantize_info);
3848 draw_info=DestroyDrawInfo(draw_info);
anthonya89dd172011-10-04 13:29:35 +00003849 status=(MagickStatusType) ((*image)->exception.severity ==
3850 UndefinedException ? 1 : 0);
3851 return(status == 0 ? MagickFalse : MagickTrue);
anthony805a2d42011-09-25 08:25:12 +00003852}
3853
3854/*
3855%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3856% %
3857% %
3858% %
3859+ S e q u e n c e O p e r a t i o n I m a g e s %
3860% %
3861% %
3862% %
3863%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3864%
3865% SequenceOperationImages() applies a single operation that apply to the
3866% entire image list (e.g. -append, -layers, -coalesce, etc.).
3867%
3868% The format of the MogrifyImage method is:
3869%
3870% MagickBooleanType SequenceOperationImages(ImageInfo *image_info,
3871% const int argc, const char **argv,Image **images,
3872% ExceptionInfo *exception)
3873%
3874% A description of each parameter follows:
3875%
3876% o image_info: the image info..
3877%
3878% o argc: Specifies a pointer to an integer describing the number of
3879% elements in the argument vector.
3880%
3881% o argv: Specifies a pointer to a text array containing the command line
3882% arguments.
3883%
3884% o images: pointer to pointer of the first image in image list.
3885%
3886% o exception: return any errors or warnings in this structure.
3887%
3888*/
3889WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info,
3890 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
3891{
3892
3893 MagickStatusType
3894 status;
3895
3896 QuantizeInfo
3897 *quantize_info;
3898
3899 assert(image_info != (ImageInfo *) NULL);
3900 assert(image_info->signature == MagickSignature);
3901 assert(images != (Image **) NULL);
3902 assert((*images)->previous == (Image *) NULL);
3903 assert((*images)->signature == MagickSignature);
3904 if ((*images)->debug != MagickFalse)
3905 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3906 (*images)->filename);
anthonya89dd172011-10-04 13:29:35 +00003907 if ((argc <= 0) || (*argv == (char *) NULL))
3908 return(MagickTrue);
anthony805a2d42011-09-25 08:25:12 +00003909 status=MagickTrue;
3910
3911 switch (*(argv[0]+1))
3912 {
3913 case 'a':
3914 {
3915 if (LocaleCompare("affinity",argv[0]+1) == 0)
3916 {
3917 (void) SyncImagesSettings(image_info,*images);
3918 if (*argv[0] == '+')
3919 {
3920 (void) RemapImages(quantize_info,*images,(Image *) NULL,
3921 exception);
3922 break;
3923 }
3924 break;
3925 }
3926 if (LocaleCompare("append",argv[0]+1) == 0)
3927 {
3928 Image
3929 *append_image;
3930
3931 (void) SyncImagesSettings(image_info,*images);
3932 append_image=AppendImages(*images,*argv[0] == '-' ? MagickTrue :
3933 MagickFalse,exception);
3934 if (append_image == (Image *) NULL)
3935 {
3936 status=MagickFalse;
3937 break;
3938 }
3939 *images=DestroyImageList(*images);
3940 *images=append_image;
3941 break;
3942 }
3943 if (LocaleCompare("average",argv[0]+1) == 0)
3944 {
3945 Image
3946 *average_image;
3947
3948 /*
3949 Average an image sequence (deprecated).
3950 */
3951 (void) SyncImagesSettings(image_info,*images);
3952 average_image=EvaluateImages(*images,MeanEvaluateOperator,
3953 exception);
3954 if (average_image == (Image *) NULL)
3955 {
3956 status=MagickFalse;
3957 break;
3958 }
3959 *images=DestroyImageList(*images);
3960 *images=average_image;
3961 break;
3962 }
3963 break;
3964 }
3965 case 'c':
3966 {
3967 if (LocaleCompare("channel",argv[0]+1) == 0)
3968 {
3969 ChannelType
3970 channel;
3971
3972 if (*argv[0] == '+')
3973 {
3974 channel=DefaultChannels;
3975 break;
3976 }
3977 channel=(ChannelType) ParseChannelOption(argv[1]);
3978 SetPixelChannelMap(*images,channel);
3979 break;
3980 }
3981 if (LocaleCompare("clut",argv[0]+1) == 0)
3982 {
3983 Image
3984 *clut_image,
3985 *image;
3986
3987 (void) SyncImagesSettings(image_info,*images);
3988 image=RemoveFirstImageFromList(images);
3989 clut_image=RemoveFirstImageFromList(images);
3990 if (clut_image == (Image *) NULL)
3991 {
3992 status=MagickFalse;
3993 break;
3994 }
anthonya89dd172011-10-04 13:29:35 +00003995 (void) ClutImage(image,clut_image,interpolate_method,exception);
anthony805a2d42011-09-25 08:25:12 +00003996 clut_image=DestroyImage(clut_image);
3997 *images=DestroyImageList(*images);
3998 *images=image;
3999 break;
4000 }
4001 if (LocaleCompare("coalesce",argv[0]+1) == 0)
4002 {
4003 Image
4004 *coalesce_image;
4005
4006 (void) SyncImagesSettings(image_info,*images);
4007 coalesce_image=CoalesceImages(*images,exception);
4008 if (coalesce_image == (Image *) NULL)
4009 {
4010 status=MagickFalse;
4011 break;
4012 }
4013 *images=DestroyImageList(*images);
4014 *images=coalesce_image;
4015 break;
4016 }
4017 if (LocaleCompare("combine",argv[0]+1) == 0)
4018 {
4019 Image
4020 *combine_image;
4021
4022 (void) SyncImagesSettings(image_info,*images);
4023 combine_image=CombineImages(*images,exception);
4024 if (combine_image == (Image *) NULL)
4025 {
4026 status=MagickFalse;
4027 break;
4028 }
4029 *images=DestroyImageList(*images);
4030 *images=combine_image;
4031 break;
4032 }
4033 if (LocaleCompare("composite",argv[0]+1) == 0)
4034 {
4035 Image
4036 *mask_image,
4037 *composite_image,
4038 *image;
4039
4040 RectangleInfo
4041 geometry;
4042
anthony5f867ae2011-10-09 10:28:34 +00004043 ComposeOperator
4044 compose;
4045
4046 const char*
4047 value;
4048
4049 value=GetImageOption(image_info,"compose");
4050 if (value != (const char *) NULL)
4051 compose=(CompositeOperator) ParseCommandOption(
4052 MagickComposeOptions,MagickFalse,value);
4053 else
4054 compose=OverCompositeOp; /* use Over not image->compose */
4055
4056 const char*
4057 value=GetImageOption(image_info,"compose");
4058
4059 if (value != (const char *) NULL)
4060 compose=(CompositeOperator) ParseCommandOption(
4061 MagickComposeOptions,MagickFalse,value);
4062 else
4063 compose=OverCompositeOp; /* use Over not image->compose */
4064
4065
anthony805a2d42011-09-25 08:25:12 +00004066 (void) SyncImagesSettings(image_info,*images);
4067 image=RemoveFirstImageFromList(images);
4068 composite_image=RemoveFirstImageFromList(images);
4069 if (composite_image == (Image *) NULL)
4070 {
4071 status=MagickFalse;
4072 break;
4073 }
4074 (void) TransformImage(&composite_image,(char *) NULL,
anthony6613bf32011-10-15 07:24:44 +00004075 composite_image->geometry,exception);
anthony805a2d42011-09-25 08:25:12 +00004076 SetGeometry(composite_image,&geometry);
4077 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
4078 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
4079 &geometry);
4080 mask_image=RemoveFirstImageFromList(images);
4081 if (mask_image != (Image *) NULL)
4082 {
anthony5f867ae2011-10-09 10:28:34 +00004083 if ((compose == DisplaceCompositeOp) ||
4084 (compose == DistortCompositeOp))
anthony805a2d42011-09-25 08:25:12 +00004085 {
4086 /*
4087 Merge Y displacement into X displacement image.
4088 */
4089 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
anthony6613bf32011-10-15 07:24:44 +00004090 mask_image,0,0,exception);
anthony805a2d42011-09-25 08:25:12 +00004091 mask_image=DestroyImage(mask_image);
4092 }
4093 else
4094 {
4095 /*
4096 Set a blending mask for the composition.
4097 Posible error, what if image->mask already set.
4098 */
4099 image->mask=mask_image;
4100 (void) NegateImage(image->mask,MagickFalse,exception);
4101 }
4102 }
anthony5f867ae2011-10-09 10:28:34 +00004103 (void) CompositeImage(image,compose,composite_image,
anthony6613bf32011-10-15 07:24:44 +00004104 geometry.x,geometry.y,exception);
anthony805a2d42011-09-25 08:25:12 +00004105 if (mask_image != (Image *) NULL)
4106 mask_image=image->mask=DestroyImage(image->mask);
4107 composite_image=DestroyImage(composite_image);
anthony805a2d42011-09-25 08:25:12 +00004108 *images=DestroyImageList(*images);
4109 *images=image;
4110 break;
4111 }
4112 break;
4113 }
4114 case 'd':
4115 {
4116 if (LocaleCompare("deconstruct",argv[0]+1) == 0)
4117 {
4118 Image
4119 *deconstruct_image;
4120
4121 (void) SyncImagesSettings(image_info,*images);
4122 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
4123 exception);
4124 if (deconstruct_image == (Image *) NULL)
4125 {
4126 status=MagickFalse;
4127 break;
4128 }
4129 *images=DestroyImageList(*images);
4130 *images=deconstruct_image;
4131 break;
4132 }
4133 if (LocaleCompare("delete",argv[0]+1) == 0)
4134 {
4135 if (*argv[0] == '+')
4136 DeleteImages(images,"-1",exception);
4137 else
4138 DeleteImages(images,argv[1],exception);
4139 break;
4140 }
4141 if (LocaleCompare("dither",argv[0]+1) == 0)
4142 {
4143 if (*argv[0] == '+')
4144 {
4145 quantize_info->dither=MagickFalse;
4146 break;
4147 }
4148 quantize_info->dither=MagickTrue;
4149 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
4150 MagickDitherOptions,MagickFalse,argv[1]);
4151 break;
4152 }
4153 if (LocaleCompare("duplicate",argv[0]+1) == 0)
4154 {
4155 Image
4156 *duplicate_images;
4157
4158 if (*argv[0] == '+')
4159 duplicate_images=DuplicateImages(*images,1,"-1",exception);
4160 else
4161 {
4162 const char
4163 *p;
4164
4165 size_t
4166 number_duplicates;
4167
4168 number_duplicates=(size_t) StringToLong(argv[1]);
4169 p=strchr(argv[1],',');
4170 if (p == (const char *) NULL)
4171 duplicate_images=DuplicateImages(*images,number_duplicates,
4172 "-1",exception);
4173 else
4174 duplicate_images=DuplicateImages(*images,number_duplicates,p,
4175 exception);
4176 }
4177 AppendImageToList(images, duplicate_images);
4178 (void) SyncImagesSettings(image_info,*images);
4179 break;
4180 }
4181 break;
4182 }
4183 case 'e':
4184 {
4185 if (LocaleCompare("evaluate-sequence",argv[0]+1) == 0)
4186 {
4187 Image
4188 *evaluate_image;
4189
4190 MagickEvaluateOperator
4191 op;
4192
4193 (void) SyncImageSettings(image_info,*images);
4194 op=(MagickEvaluateOperator) ParseCommandOption(
4195 MagickEvaluateOptions,MagickFalse,argv[1]);
4196 evaluate_image=EvaluateImages(*images,op,exception);
4197 if (evaluate_image == (Image *) NULL)
4198 {
4199 status=MagickFalse;
4200 break;
4201 }
4202 *images=DestroyImageList(*images);
4203 *images=evaluate_image;
4204 break;
4205 }
4206 break;
4207 }
4208 case 'f':
4209 {
4210 if (LocaleCompare("fft",argv[0]+1) == 0)
4211 {
4212 Image
4213 *fourier_image;
4214
4215 /*
4216 Implements the discrete Fourier transform (DFT).
4217 */
4218 (void) SyncImageSettings(image_info,*images);
4219 fourier_image=ForwardFourierTransformImage(*images,*argv[0] == '-' ?
4220 MagickTrue : MagickFalse,exception);
4221 if (fourier_image == (Image *) NULL)
4222 break;
4223 *images=DestroyImage(*images);
4224 *images=fourier_image;
4225 break;
4226 }
4227 if (LocaleCompare("flatten",argv[0]+1) == 0)
4228 {
4229 Image
4230 *flatten_image;
4231
4232 (void) SyncImagesSettings(image_info,*images);
4233 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
4234 if (flatten_image == (Image *) NULL)
4235 break;
4236 *images=DestroyImageList(*images);
4237 *images=flatten_image;
4238 break;
4239 }
4240 if (LocaleCompare("fx",argv[0]+1) == 0)
4241 {
4242 Image
4243 *fx_image;
4244
4245 (void) SyncImagesSettings(image_info,*images);
4246 fx_image=FxImage(*images,argv[1],exception);
4247 if (fx_image == (Image *) NULL)
4248 {
4249 status=MagickFalse;
4250 break;
4251 }
4252 *images=DestroyImageList(*images);
4253 *images=fx_image;
4254 break;
4255 }
4256 break;
4257 }
4258 case 'h':
4259 {
4260 if (LocaleCompare("hald-clut",argv[0]+1) == 0)
4261 {
4262 Image
4263 *hald_image,
4264 *image;
4265
4266 (void) SyncImagesSettings(image_info,*images);
4267 image=RemoveFirstImageFromList(images);
4268 hald_image=RemoveFirstImageFromList(images);
4269 if (hald_image == (Image *) NULL)
4270 {
4271 status=MagickFalse;
4272 break;
4273 }
4274 (void) HaldClutImage(image,hald_image,exception);
4275 hald_image=DestroyImage(hald_image);
4276 if (*images != (Image *) NULL)
4277 *images=DestroyImageList(*images);
4278 *images=image;
4279 break;
4280 }
4281 break;
4282 }
4283 case 'i':
4284 {
4285 if (LocaleCompare("ift",argv[0]+1) == 0)
4286 {
4287 Image
4288 *fourier_image,
4289 *magnitude_image,
4290 *phase_image;
4291
4292 /*
4293 Implements the inverse fourier discrete Fourier transform (DFT).
4294 */
4295 (void) SyncImagesSettings(image_info,*images);
4296 magnitude_image=RemoveFirstImageFromList(images);
4297 phase_image=RemoveFirstImageFromList(images);
4298 if (phase_image == (Image *) NULL)
4299 {
4300 status=MagickFalse;
4301 break;
4302 }
4303 fourier_image=InverseFourierTransformImage(magnitude_image,
4304 phase_image,*argv[0] == '-' ? MagickTrue : MagickFalse,exception);
4305 if (fourier_image == (Image *) NULL)
4306 break;
4307 if (*images != (Image *) NULL)
4308 *images=DestroyImage(*images);
4309 *images=fourier_image;
4310 break;
4311 }
4312 if (LocaleCompare("insert",argv[0]+1) == 0)
4313 {
4314 Image
4315 *p,
4316 *q;
4317
4318 index=0;
4319 if (*argv[0] != '+')
4320 index=(ssize_t) StringToLong(argv[1]);
4321 p=RemoveLastImageFromList(images);
4322 if (p == (Image *) NULL)
4323 {
4324 (void) ThrowMagickException(exception,GetMagickModule(),
4325 OptionError,"NoSuchImage","`%s'",argv[1]);
4326 status=MagickFalse;
4327 break;
4328 }
4329 q=p;
4330 if (index == 0)
4331 PrependImageToList(images,q);
4332 else
4333 if (index == (ssize_t) GetImageListLength(*images))
4334 AppendImageToList(images,q);
4335 else
4336 {
4337 q=GetImageFromList(*images,index-1);
4338 if (q == (Image *) NULL)
4339 {
4340 (void) ThrowMagickException(exception,GetMagickModule(),
4341 OptionError,"NoSuchImage","`%s'",argv[1]);
4342 status=MagickFalse;
4343 break;
4344 }
4345 InsertImageInList(&q,p);
4346 }
4347 *images=GetFirstImageInList(q);
4348 break;
4349 }
4350 if (LocaleCompare("interpolate",argv[0]+1) == 0)
4351 {
4352 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
4353 MagickInterpolateOptions,MagickFalse,argv[1]);
4354 break;
4355 }
4356 break;
4357 }
4358 case 'l':
4359 {
4360 if (LocaleCompare("layers",argv[0]+1) == 0)
4361 {
4362 Image
4363 *layers;
4364
4365 ImageLayerMethod
4366 method;
4367
4368 (void) SyncImagesSettings(image_info,*images);
4369 layers=(Image *) NULL;
4370 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
4371 MagickFalse,argv[1]);
4372 switch (method)
4373 {
4374 case CoalesceLayer:
4375 {
4376 layers=CoalesceImages(*images,exception);
4377 break;
4378 }
4379 case CompareAnyLayer:
4380 case CompareClearLayer:
4381 case CompareOverlayLayer:
4382 default:
4383 {
4384 layers=CompareImagesLayers(*images,method,exception);
4385 break;
4386 }
4387 case MergeLayer:
4388 case FlattenLayer:
4389 case MosaicLayer:
4390 case TrimBoundsLayer:
4391 {
4392 layers=MergeImageLayers(*images,method,exception);
4393 break;
4394 }
4395 case DisposeLayer:
4396 {
4397 layers=DisposeImages(*images,exception);
4398 break;
4399 }
4400 case OptimizeImageLayer:
4401 {
4402 layers=OptimizeImageLayers(*images,exception);
4403 break;
4404 }
4405 case OptimizePlusLayer:
4406 {
4407 layers=OptimizePlusImageLayers(*images,exception);
4408 break;
4409 }
4410 case OptimizeTransLayer:
4411 {
4412 OptimizeImageTransparency(*images,exception);
4413 break;
4414 }
4415 case RemoveDupsLayer:
4416 {
4417 RemoveDuplicateLayers(images,exception);
4418 break;
4419 }
4420 case RemoveZeroLayer:
4421 {
4422 RemoveZeroDelayLayers(images,exception);
4423 break;
4424 }
4425 case OptimizeLayer:
4426 {
4427 /*
4428 General Purpose, GIF Animation Optimizer.
4429 */
4430 layers=CoalesceImages(*images,exception);
4431 if (layers == (Image *) NULL)
4432 {
4433 status=MagickFalse;
4434 break;
4435 }
4436 *images=DestroyImageList(*images);
4437 *images=layers;
4438 layers=OptimizeImageLayers(*images,exception);
4439 if (layers == (Image *) NULL)
4440 {
4441 status=MagickFalse;
4442 break;
4443 }
4444 *images=DestroyImageList(*images);
4445 *images=layers;
4446 layers=(Image *) NULL;
4447 OptimizeImageTransparency(*images,exception);
4448 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4449 exception);
4450 break;
4451 }
4452 case CompositeLayer:
4453 {
anthony805a2d42011-09-25 08:25:12 +00004454 Image
4455 *source;
4456
4457 RectangleInfo
4458 geometry;
4459
anthony5f867ae2011-10-09 10:28:34 +00004460 ComposeOperator
4461 compose;
4462
4463 const char*
4464 value;
4465
4466 value=GetImageOption(image_info,"compose");
4467 if (value != (const char *) NULL)
4468 compose=(CompositeOperator) ParseCommandOption(
4469 MagickComposeOptions,MagickFalse,value);
4470 else
4471 compose=OverCompositeOp; /* use Over not image->compose */
4472
anthony805a2d42011-09-25 08:25:12 +00004473 /*
4474 Split image sequence at the first 'NULL:' image.
4475 */
4476 source=(*images);
4477 while (source != (Image *) NULL)
4478 {
4479 source=GetNextImageInList(source);
4480 if ((source != (Image *) NULL) &&
4481 (LocaleCompare(source->magick,"NULL") == 0))
4482 break;
4483 }
4484 if (source != (Image *) NULL)
4485 {
4486 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
4487 (GetNextImageInList(source) == (Image *) NULL))
4488 source=(Image *) NULL;
4489 else
4490 {
4491 /*
4492 Separate the two lists, junk the null: image.
4493 */
4494 source=SplitImageList(source->previous);
4495 DeleteImageFromList(&source);
4496 }
4497 }
4498 if (source == (Image *) NULL)
4499 {
4500 (void) ThrowMagickException(exception,GetMagickModule(),
4501 OptionError,"MissingNullSeparator","layers Composite");
4502 status=MagickFalse;
4503 break;
4504 }
4505 /*
4506 Adjust offset with gravity and virtual canvas.
4507 */
4508 SetGeometry(*images,&geometry);
4509 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
4510 geometry.width=source->page.width != 0 ?
4511 source->page.width : source->columns;
4512 geometry.height=source->page.height != 0 ?
4513 source->page.height : source->rows;
4514 GravityAdjustGeometry((*images)->page.width != 0 ?
4515 (*images)->page.width : (*images)->columns,
4516 (*images)->page.height != 0 ? (*images)->page.height :
4517 (*images)->rows,(*images)->gravity,&geometry);
anthony5f867ae2011-10-09 10:28:34 +00004518
4519 /*
4520 Compose the two image sequences together
4521 */
anthony805a2d42011-09-25 08:25:12 +00004522 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
4523 exception);
4524 source=DestroyImageList(source);
4525 break;
4526 }
4527 }
4528 if (layers == (Image *) NULL)
4529 break;
4530 InheritException(exception,&layers->exception);
4531 *images=DestroyImageList(*images);
4532 *images=layers;
4533 break;
4534 }
4535 break;
4536 }
4537 case 'm':
4538 {
4539 if (LocaleCompare("map",argv[0]+1) == 0)
4540 {
4541 (void) SyncImagesSettings(image_info,*images);
4542 if (*argv[0] == '+')
4543 {
4544 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4545 exception);
4546 break;
4547 }
4548 break;
4549 }
4550 if (LocaleCompare("maximum",argv[0]+1) == 0)
4551 {
4552 Image
4553 *maximum_image;
4554
4555 /*
4556 Maximum image sequence (deprecated).
4557 */
4558 (void) SyncImagesSettings(image_info,*images);
4559 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
4560 if (maximum_image == (Image *) NULL)
4561 {
4562 status=MagickFalse;
4563 break;
4564 }
4565 *images=DestroyImageList(*images);
4566 *images=maximum_image;
4567 break;
4568 }
4569 if (LocaleCompare("minimum",argv[0]+1) == 0)
4570 {
4571 Image
4572 *minimum_image;
4573
4574 /*
4575 Minimum image sequence (deprecated).
4576 */
4577 (void) SyncImagesSettings(image_info,*images);
4578 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
4579 if (minimum_image == (Image *) NULL)
4580 {
4581 status=MagickFalse;
4582 break;
4583 }
4584 *images=DestroyImageList(*images);
4585 *images=minimum_image;
4586 break;
4587 }
4588 if (LocaleCompare("morph",argv[0]+1) == 0)
4589 {
4590 Image
4591 *morph_image;
4592
4593 (void) SyncImagesSettings(image_info,*images);
4594 morph_image=MorphImages(*images,StringToUnsignedLong(argv[1]),
4595 exception);
4596 if (morph_image == (Image *) NULL)
4597 {
4598 status=MagickFalse;
4599 break;
4600 }
4601 *images=DestroyImageList(*images);
4602 *images=morph_image;
4603 break;
4604 }
4605 if (LocaleCompare("mosaic",argv[0]+1) == 0)
4606 {
4607 Image
4608 *mosaic_image;
4609
4610 (void) SyncImagesSettings(image_info,*images);
4611 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
4612 if (mosaic_image == (Image *) NULL)
4613 {
4614 status=MagickFalse;
4615 break;
4616 }
4617 *images=DestroyImageList(*images);
4618 *images=mosaic_image;
4619 break;
4620 }
4621 break;
4622 }
4623 case 'p':
4624 {
4625 if (LocaleCompare("print",argv[0]+1) == 0)
4626 {
4627 char
4628 *string;
4629
4630 (void) SyncImagesSettings(image_info,*images);
4631 string=InterpretImageProperties(image_info,*images,argv[1],
4632 exception);
4633 if (string == (char *) NULL)
4634 break;
4635 (void) FormatLocaleFile(stdout,"%s",string);
4636 string=DestroyString(string);
4637 }
4638 if (LocaleCompare("process",argv[0]+1) == 0)
4639 {
4640 char
4641 **arguments;
4642
4643 int
4644 j,
4645 number_arguments;
4646
4647 (void) SyncImagesSettings(image_info,*images);
4648 arguments=StringToArgv(argv[1],&number_arguments);
4649 if (arguments == (char **) NULL)
4650 break;
4651 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
4652 {
4653 char
4654 breaker,
4655 quote,
4656 *token;
4657
4658 const char
4659 *arguments;
4660
4661 int
4662 next,
4663 status;
4664
4665 size_t
4666 length;
4667
4668 TokenInfo
4669 *token_info;
4670
4671 /*
4672 Support old style syntax, filter="-option arg".
4673 */
4674 length=strlen(argv[1]);
4675 token=(char *) NULL;
4676 if (~length >= (MaxTextExtent-1))
4677 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
4678 sizeof(*token));
4679 if (token == (char *) NULL)
4680 break;
4681 next=0;
4682 arguments=argv[1];
4683 token_info=AcquireTokenInfo();
4684 status=Tokenizer(token_info,0,token,length,arguments,"","=",
4685 "\"",'\0',&breaker,&next,&quote);
4686 token_info=DestroyTokenInfo(token_info);
4687 if (status == 0)
4688 {
4689 const char
4690 *argv;
4691
4692 argv=(&(arguments[next]));
4693 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
4694 exception);
4695 }
4696 token=DestroyString(token);
4697 break;
4698 }
4699 (void) SubstituteString(&arguments[1],"-","");
4700 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
4701 number_arguments-2,(const char **) arguments+2,exception);
4702 for (j=0; j < number_arguments; j++)
4703 arguments[j]=DestroyString(arguments[j]);
4704 arguments=(char **) RelinquishMagickMemory(arguments);
4705 break;
4706 }
4707 break;
4708 }
4709 case 'r':
4710 {
4711 if (LocaleCompare("reverse",argv[0]+1) == 0)
4712 {
4713 ReverseImageList(images);
4714 InheritException(exception,&(*images)->exception);
4715 break;
4716 }
4717 break;
4718 }
4719 case 's':
4720 {
4721 if (LocaleCompare("smush",argv[0]+1) == 0)
4722 {
4723 Image
4724 *smush_image;
4725
4726 ssize_t
4727 offset;
4728
4729 (void) SyncImagesSettings(image_info,*images);
4730 offset=(ssize_t) StringToLong(argv[1]);
4731 smush_image=SmushImages(*images,*argv[0] == '-' ? MagickTrue :
4732 MagickFalse,offset,exception);
4733 if (smush_image == (Image *) NULL)
4734 {
4735 status=MagickFalse;
4736 break;
4737 }
4738 *images=DestroyImageList(*images);
4739 *images=smush_image;
4740 break;
4741 }
4742 if (LocaleCompare("swap",argv[0]+1) == 0)
4743 {
4744 Image
4745 *p,
4746 *q,
4747 *swap;
4748
4749 ssize_t
4750 swap_index;
4751
4752 index=(-1);
4753 swap_index=(-2);
4754 if (*argv[0] != '+')
4755 {
4756 GeometryInfo
4757 geometry_info;
4758
4759 MagickStatusType
4760 flags;
4761
4762 swap_index=(-1);
4763 flags=ParseGeometry(argv[1],&geometry_info);
4764 index=(ssize_t) geometry_info.rho;
4765 if ((flags & SigmaValue) != 0)
4766 swap_index=(ssize_t) geometry_info.sigma;
4767 }
4768 p=GetImageFromList(*images,index);
4769 q=GetImageFromList(*images,swap_index);
4770 if ((p == (Image *) NULL) || (q == (Image *) NULL))
4771 {
4772 (void) ThrowMagickException(exception,GetMagickModule(),
4773 OptionError,"NoSuchImage","`%s'",(*images)->filename);
4774 status=MagickFalse;
4775 break;
4776 }
4777 if (p == q)
4778 break;
4779 swap=CloneImage(p,0,0,MagickTrue,exception);
4780 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
4781 ReplaceImageInList(&q,swap);
4782 *images=GetFirstImageInList(q);
4783 break;
4784 }
4785 break;
4786 }
4787 case 'w':
4788 {
4789 if (LocaleCompare("write",argv[0]+1) == 0)
4790 {
4791 char
4792 key[MaxTextExtent];
4793
4794 Image
4795 *write_images;
4796
4797 ImageInfo
4798 *write_info;
4799
4800 (void) SyncImagesSettings(image_info,*images);
4801 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[1]);
4802 (void) DeleteImageRegistry(key);
4803 write_images=(*images);
4804 if (*argv[0] == '+')
4805 write_images=CloneImageList(*images,exception);
4806 write_info=CloneImageInfo(image_info);
4807 status&=WriteImages(write_info,write_images,argv[1],exception);
4808 write_info=DestroyImageInfo(write_info);
4809 if (*argv[0] == '+')
4810 write_images=DestroyImageList(write_images);
4811 break;
4812 }
4813 break;
4814 }
4815 default:
4816 break;
4817 }
4818 quantize_info=DestroyQuantizeInfo(quantize_info);
4819
anthonya89dd172011-10-04 13:29:35 +00004820 status=(MagickStatusType) ((*image)->exception.severity ==
4821 UndefinedException ? 1 : 0);
anthony805a2d42011-09-25 08:25:12 +00004822 return(status != 0 ? MagickTrue : MagickFalse);
4823}
cristy0a0ca4f2011-09-28 01:15:28 +00004824#endif