52#include "MagickWand/studio.h"
53#include "MagickWand/MagickWand.h"
54#include "MagickWand/magick-wand-private.h"
55#include "MagickWand/mogrify-private.h"
56#include "MagickCore/blob-private.h"
57#include "MagickCore/color-private.h"
58#include "MagickCore/composite-private.h"
59#include "MagickCore/geometry-private.h"
60#include "MagickCore/image-private.h"
61#include "MagickCore/monitor-private.h"
62#include "MagickCore/profile-private.h"
63#include "MagickCore/string-private.h"
64#include "MagickCore/thread-private.h"
65#include "MagickCore/timer-private.h"
66#include "MagickCore/utility-private.h"
72 MogrifyAlphaColor[] =
"#bdbdbd",
73 MogrifyBackgroundColor[] =
"#ffffff",
74 MogrifyBorderColor[] =
"#dfdfdf";
79#define UndefinedCompressionQuality 0UL
140static inline Image *GetImageCache(
const ImageInfo *image_info,
const char *path,
141 ExceptionInfo *exception)
144 key[MagickPathExtent];
159 (void) FormatLocaleString(key,MagickPathExtent,
"cache:%s",path);
160 sans_exception=AcquireExceptionInfo();
161 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
162 sans_exception=DestroyExceptionInfo(sans_exception);
163 if (image != (Image *) NULL)
165 read_info=CloneImageInfo(image_info);
166 (void) CopyMagickString(read_info->filename,path,MagickPathExtent);
167 image=ReadImage(read_info,exception);
168 read_info=DestroyImageInfo(read_info);
169 if (image != (Image *) NULL)
170 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
174static inline MagickBooleanType IsPathWritable(
const char *path)
176 if (IsPathAccessible(path) == MagickFalse)
178 if (access_utf8(path,W_OK) != 0)
183static MagickBooleanType MonitorProgress(
const char *text,
184 const MagickOffsetType offset,
const MagickSizeType extent,
185 void *wand_unused(client_data))
188 message[MagickPathExtent],
189 tag[MagickPathExtent];
197 magick_unreferenced(client_data);
199 if ((extent <= 1) || (offset < 0) || (offset >= (MagickOffsetType) extent))
201 if ((offset != (MagickOffsetType) (extent-1)) && ((offset % 50) != 0))
203 (void) CopyMagickString(tag,text == (
const char *) NULL ?
"null" : text,
206 if (p != (
char *) NULL)
208 (void) FormatLocaleString(message,MagickPathExtent,
"Monitor/%s",tag);
209 locale_message=GetLocaleMessage(message);
210 if (locale_message == message)
212 if (p == (
char *) NULL)
213 (void) FormatLocaleFile(stderr,
"%s: %ld of %lu, %02ld%% complete\r",
214 locale_message,(
long) offset,(
unsigned long) extent,(
long)
215 (100.0*offset*MagickSafeReciprocal((
double) extent-1.0)));
217 (
void) FormatLocaleFile(stderr,
"%s[%s]: %ld of %lu, %02ld%% complete\r",
218 locale_message,p+1,(
long) offset,(
unsigned long) extent,(
long)
219 (100.0*offset*MagickSafeReciprocal((
double) extent-1.0)));
220 if (offset == (MagickOffsetType) (extent-1))
221 (void) FormatLocaleFile(stderr,
"\n");
222 (void) fflush(stderr);
226static Image *SparseColorOption(
const Image *image,
227 const SparseColorMethod method,
const char *arguments,
228 const MagickBooleanType color_from_image,ExceptionInfo *exception)
231 token[MagickPathExtent];
262 assert(image != (Image *) NULL);
263 assert(image->signature == MagickCoreSignature);
264 assert(exception != (ExceptionInfo *) NULL);
265 assert(exception->signature == MagickCoreSignature);
266 if (IsEventLogging() != MagickFalse)
267 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
272 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
274 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
276 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
278 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
279 (image->colorspace == CMYKColorspace))
281 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
282 (image->alpha_trait != UndefinedPixelTrait))
292 (void) GetNextToken(p,&p,MagickPathExtent,token);
293 if (*token ==
',')
continue;
294 if ( isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#')) {
295 if ( color_from_image ) {
296 (void) ThrowMagickException(exception,GetMagickModule(),
297 OptionError,
"InvalidArgument",
"'%s': %s",
"sparse-color",
298 "Color arg given, when colors are coming from image");
299 return( (Image *) NULL);
308 if ( color_from_image ) {
310 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
311 number_arguments=(x/2)*(2+number_colors);
315 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
319 (void) ThrowMagickException(exception,GetMagickModule(),
320 OptionError,
"InvalidArgument",
"'%s': %s",
"sparse-color",
321 "Invalid number of Arguments");
322 return( (Image *) NULL);
326 sparse_arguments=(
double *) AcquireQuantumMemory(number_arguments,
327 sizeof(*sparse_arguments));
328 if (sparse_arguments == (
double *) NULL) {
329 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
330 " MemoryAllocationFailed\n""%s",
"SparseColorOption");
331 return( (Image *) NULL);
333 (void) memset(sparse_arguments,0,number_arguments*
334 sizeof(*sparse_arguments));
337 while ((*p !=
'\0') && (x < number_arguments))
341 while (*token ==
',')
342 (void) GetNextToken(p,&p,MagickPathExtent,token);
343 if (*token ==
'\0')
break;
344 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
346 (void) ThrowMagickException(exception,GetMagickModule(),
347 OptionError,
"InvalidArgument",
"'%s': %s",
"sparse-color",
348 "Color found, instead of X-coord");
352 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
355 while (*token ==
',')
356 (void) GetNextToken(p,&p,MagickPathExtent,token);
359 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
361 (void) ThrowMagickException(exception,GetMagickModule(),
362 OptionError,
"InvalidArgument",
"'%s': %s",
"sparse-color",
363 "Color found, instead of Y-coord");
367 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
370 if ( (color_from_image ) {
379 while (*token ==
',')
380 (void) GetNextToken(p,&p,MagickPathExtent,token);
383 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
386 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
387 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
388 sparse_arguments[x++] = QuantumScale*color.red;
389 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
390 sparse_arguments[x++] = QuantumScale*color.green;
391 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
392 sparse_arguments[x++] = QuantumScale*color.blue;
393 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
394 (image->colorspace == CMYKColorspace))
395 sparse_arguments[x++] = QuantumScale*color.black;
396 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
397 (image->alpha_trait != UndefinedPixelTrait))
398 sparse_arguments[x++] = QuantumScale*color.alpha;
403 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
405 while (*token ==
',')
406 (void) GetNextToken(p,&p,MagickPathExtent,token);
407 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) ||
410 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
413 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
415 while (*token ==
',')
416 (void) GetNextToken(p,&p,MagickPathExtent,token);
417 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) ||
420 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
423 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
425 while (*token ==
',')
426 (void) GetNextToken(p,&p,MagickPathExtent,token);
427 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) ||
430 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
433 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
434 (image->colorspace == CMYKColorspace))
436 while (*token ==
',')
437 (void) GetNextToken(p,&p,MagickPathExtent,token);
438 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) ||
441 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
444 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
445 (image->alpha_trait != UndefinedPixelTrait))
447 while (*token ==
',')
448 (void) GetNextToken(p,&p,MagickPathExtent,token);
449 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) ||
452 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
458 if ((number_arguments != x) && (!error))
460 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
461 " InvalidArgument",
"'%s': %s",
"sparse-color",
"Argument Parsing Error");
462 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
463 return((Image *) NULL);
466 return((Image *) NULL);
470 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
472 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
473 return( sparse_image );
476WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,
const int argc,
477 const char **argv,Image **image,ExceptionInfo *exception)
507 PixelInterpolateMethod
523 assert(image_info != (
const ImageInfo *) NULL);
524 assert(image_info->signature == MagickCoreSignature);
525 assert(image != (Image **) NULL);
526 assert((*image)->signature == MagickCoreSignature);
527 if (IsEventLogging() != MagickFalse)
528 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
531 mogrify_info=CloneImageInfo(image_info);
532 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
533 quantize_info=AcquireQuantizeInfo(mogrify_info);
534 SetGeometryInfo(&geometry_info);
535 GetPixelInfo(*image,&fill);
536 fill=(*image)->background_color;
538 compose=(*image)->compose;
539 interpolate_method=UndefinedInterpolatePixel;
540 format=GetImageOption(mogrify_info,
"format");
541 SetGeometry(*image,®ion_geometry);
545 for (i=0; i < (ssize_t) argc; i++)
554 if (IsCommandOption(option) == MagickFalse)
556 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
558 if ((i+count) >= (ssize_t) argc)
560 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
561 mogrify_image=(Image *) NULL;
566 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
571 (void) SyncImageSettings(mogrify_info,*image,exception);
572 flags=ParseGeometry(argv[i+1],&geometry_info);
573 if ((flags & SigmaValue) == 0)
574 geometry_info.sigma=1.0;
575 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
576 geometry_info.sigma,exception);
579 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
584 (void) SyncImageSettings(mogrify_info,*image,exception);
585 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
586 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
587 geometry.height,exception);
590 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
595 (void) SyncImageSettings(mogrify_info,*image,exception);
596 flags=ParseGeometry(argv[i+1],&geometry_info);
597 if ((flags & SigmaValue) == 0)
598 geometry_info.sigma=1.0;
599 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
600 geometry_info.sigma,exception);
603 if (LocaleCompare(
"affine",option+1) == 0)
610 GetAffineMatrix(&draw_info->affine);
613 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
616 if (LocaleCompare(
"alpha",option+1) == 0)
621 (void) SyncImageSettings(mogrify_info,*image,exception);
622 alpha_type=(AlphaChannelOption) ParseCommandOption(
623 MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
624 (void) SetImageAlphaChannel(*image,alpha_type,exception);
627 if (LocaleCompare(
"annotate",option+1) == 0)
631 geometry_str[MagickPathExtent];
636 (void) SyncImageSettings(mogrify_info,*image,exception);
637 SetGeometryInfo(&geometry_info);
638 flags=ParseGeometry(argv[i+1],&geometry_info);
639 if ((flags & SigmaValue) == 0)
640 geometry_info.sigma=geometry_info.rho;
641 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
643 if (text == (
char *) NULL)
645 (void) CloneString(&draw_info->text,text);
646 text=DestroyString(text);
647 (void) FormatLocaleString(geometry_str,MagickPathExtent,
"%+f%+f",
648 geometry_info.xi,geometry_info.psi);
649 (void) CloneString(&draw_info->geometry,geometry_str);
650 draw_info->affine.sx=cos(DegreesToRadians(
651 fmod(geometry_info.rho,360.0)));
652 draw_info->affine.rx=sin(DegreesToRadians(
653 fmod(geometry_info.rho,360.0)));
654 draw_info->affine.ry=(-sin(DegreesToRadians(
655 fmod(geometry_info.sigma,360.0))));
656 draw_info->affine.sy=cos(DegreesToRadians(
657 fmod(geometry_info.sigma,360.0)));
658 (void) AnnotateImage(*image,draw_info,exception);
661 if (LocaleCompare(
"antialias",option+1) == 0)
663 draw_info->stroke_antialias=(*option ==
'-') ? MagickTrue :
665 draw_info->text_antialias=(*option ==
'-') ? MagickTrue :
669 if (LocaleCompare(
"attenuate",option+1) == 0)
676 attenuate=StringToDouble(argv[i+1],(
char **) NULL);
679 if (LocaleCompare(
"auto-gamma",option+1) == 0)
684 (void) SyncImageSettings(mogrify_info,*image,exception);
685 (void) AutoGammaImage(*image,exception);
688 if (LocaleCompare(
"auto-level",option+1) == 0)
693 (void) SyncImageSettings(mogrify_info,*image,exception);
694 (void) AutoLevelImage(*image,exception);
697 if (LocaleCompare(
"auto-orient",option+1) == 0)
699 (void) SyncImageSettings(mogrify_info,*image,exception);
700 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
704 if (LocaleCompare(
"auto-threshold",option+1) == 0)
709 (void) SyncImageSettings(mogrify_info,*image,exception);
710 method=(AutoThresholdMethod) ParseCommandOption(
711 MagickAutoThresholdOptions,MagickFalse,argv[i+1]);
712 (void) AutoThresholdImage(*image,method,exception);
719 if (LocaleCompare(
"bilateral-blur",option+1) == 0)
724 (void) SyncImageSettings(mogrify_info,*image,exception);
725 flags=ParseGeometry(argv[i+1],&geometry_info);
726 if ((flags & SigmaValue) == 0)
727 geometry_info.sigma=geometry_info.rho;
728 if ((flags & XiValue) == 0)
729 geometry_info.xi=1.0*sqrt(geometry_info.rho*geometry_info.rho+
730 geometry_info.sigma*geometry_info.sigma);
731 if ((flags & PsiValue) == 0)
732 geometry_info.psi=0.25*sqrt(geometry_info.rho*geometry_info.rho+
733 geometry_info.sigma*geometry_info.sigma);
734 mogrify_image=BilateralBlurImage(*image,(
size_t) geometry_info.rho,
735 (
size_t) geometry_info.sigma,geometry_info.xi,geometry_info.psi,
739 if (LocaleCompare(
"black-threshold",option+1) == 0)
744 (void) SyncImageSettings(mogrify_info,*image,exception);
745 (void) BlackThresholdImage(*image,argv[i+1],exception);
748 if (LocaleCompare(
"blue-shift",option+1) == 0)
753 (void) SyncImageSettings(mogrify_info,*image,exception);
754 geometry_info.rho=1.5;
756 flags=ParseGeometry(argv[i+1],&geometry_info);
757 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
760 if (LocaleCompare(
"blur",option+1) == 0)
765 (void) SyncImageSettings(mogrify_info,*image,exception);
766 flags=ParseGeometry(argv[i+1],&geometry_info);
767 if ((flags & SigmaValue) == 0)
768 geometry_info.sigma=1.0;
769 if ((flags & XiValue) == 0)
770 geometry_info.xi=0.0;
771 mogrify_image=BlurImage(*image,geometry_info.rho,
772 geometry_info.sigma,exception);
775 if (LocaleCompare(
"border",option+1) == 0)
780 (void) SyncImageSettings(mogrify_info,*image,exception);
781 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
782 mogrify_image=BorderImage(*image,&geometry,compose,exception);
785 if (LocaleCompare(
"bordercolor",option+1) == 0)
789 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
790 &draw_info->border_color,exception);
793 (void) QueryColorCompliance(argv[i+1],AllCompliance,
794 &draw_info->border_color,exception);
797 if (LocaleCompare(
"box",option+1) == 0)
799 (void) QueryColorCompliance(argv[i+1],AllCompliance,
800 &draw_info->undercolor,exception);
803 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
812 (void) SyncImageSettings(mogrify_info,*image,exception);
813 flags=ParseGeometry(argv[i+1],&geometry_info);
814 brightness=geometry_info.rho;
816 if ((flags & SigmaValue) != 0)
817 contrast=geometry_info.sigma;
818 (void) BrightnessContrastImage(*image,brightness,contrast,
826 if (LocaleCompare(
"canny",option+1) == 0)
831 (void) SyncImageSettings(mogrify_info,*image,exception);
832 flags=ParseGeometry(argv[i+1],&geometry_info);
833 if ((flags & SigmaValue) == 0)
834 geometry_info.sigma=1.0;
835 if ((flags & XiValue) == 0)
836 geometry_info.xi=0.10;
837 if ((flags & PsiValue) == 0)
838 geometry_info.psi=0.30;
839 if ((flags & PercentValue) != 0)
841 geometry_info.xi/=100.0;
842 geometry_info.psi/=100.0;
844 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
845 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
848 if (LocaleCompare(
"cdl",option+1) == 0)
851 *color_correction_collection;
856 (void) SyncImageSettings(mogrify_info,*image,exception);
857 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
858 if (color_correction_collection == (
char *) NULL)
860 (void) ColorDecisionListImage(*image,color_correction_collection,
862 color_correction_collection=DestroyString(color_correction_collection);
865 if (LocaleCompare(
"channel",option+1) == 0)
870 (void) SyncImageSettings(mogrify_info,*image,exception);
873 (void) SetPixelChannelMask(*image,DefaultChannels);
876 channel=(ChannelType) ParseChannelOption(argv[i+1]);
877 (void) SetPixelChannelMask(*image,channel);
880 if (LocaleCompare(
"charcoal",option+1) == 0)
885 (void) SyncImageSettings(mogrify_info,*image,exception);
886 flags=ParseGeometry(argv[i+1],&geometry_info);
887 if ((flags & SigmaValue) == 0)
888 geometry_info.sigma=1.0;
889 if ((flags & XiValue) == 0)
890 geometry_info.xi=1.0;
891 mogrify_image=CharcoalImage(*image,geometry_info.rho,
892 geometry_info.sigma,exception);
895 if (LocaleCompare(
"chop",option+1) == 0)
900 (void) SyncImageSettings(mogrify_info,*image,exception);
901 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
902 mogrify_image=ChopImage(*image,&geometry,exception);
905 if (LocaleCompare(
"clahe",option+1) == 0)
910 (void) SyncImageSettings(mogrify_info,*image,exception);
911 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
912 flags=ParseGeometry(argv[i+1],&geometry_info);
913 (void) CLAHEImage(*image,geometry.width,geometry.height,
914 (
size_t) geometry.x,geometry_info.psi,exception);
917 if (LocaleCompare(
"clip",option+1) == 0)
919 (void) SyncImageSettings(mogrify_info,*image,exception);
922 (void) SetImageMask(*image,WritePixelMask,(
const Image *) NULL,
926 (void) ClipImage(*image,exception);
929 if (LocaleCompare(
"clip-mask",option+1) == 0)
934 (void) SyncImageSettings(mogrify_info,*image,exception);
940 (void) SetImageMask(*image,WritePixelMask,(
const Image *) NULL,
947 clip_mask=GetImageCache(mogrify_info,argv[i+1],exception);
948 if (clip_mask == (Image *) NULL)
950 (void) SetImageMask(*image,WritePixelMask,clip_mask,exception);
951 clip_mask=DestroyImage(clip_mask);
954 if (LocaleCompare(
"clip-path",option+1) == 0)
956 (void) SyncImageSettings(mogrify_info,*image,exception);
957 (void) ClipImagePath(*image,argv[i+1],*option ==
'-' ? MagickTrue :
958 MagickFalse,exception);
961 if (LocaleCompare(
"colorize",option+1) == 0)
966 (void) SyncImageSettings(mogrify_info,*image,exception);
967 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
970 if (LocaleCompare(
"color-matrix",option+1) == 0)
975 (void) SyncImageSettings(mogrify_info,*image,exception);
976 kernel=AcquireKernelInfo(argv[i+1],exception);
977 if (kernel == (KernelInfo *) NULL)
980 mogrify_image=ColorMatrixImage(*image,kernel,exception);
981 kernel=DestroyKernelInfo(kernel);
984 if (LocaleCompare(
"colors",option+1) == 0)
989 (void) SyncImageSettings(mogrify_info,*image,exception);
990 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
991 if (quantize_info->number_colors == 0)
993 if (((*image)->storage_class == DirectClass) ||
994 (*image)->colors > quantize_info->number_colors)
995 (void) QuantizeImage(quantize_info,*image,exception);
997 (
void) CompressImageColormap(*image,exception);
1000 if (LocaleCompare(
"colorspace",option+1) == 0)
1005 (void) SyncImageSettings(mogrify_info,*image,exception);
1008 (void) TransformImageColorspace(*image,sRGBColorspace,
1012 colorspace=(ColorspaceType) ParseCommandOption(
1013 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1014 (void) TransformImageColorspace(*image,colorspace,exception);
1017 if (LocaleCompare(
"color-threshold",option+1) == 0)
1026 (void) SyncImageSettings(mogrify_info,*image,exception);
1028 (void) GetColorRange(
"white-black",&start,&stop,exception);
1030 (
void) GetColorRange(argv[i+1],&start,&stop,exception);
1031 (void) ColorThresholdImage(*image,&start,&stop,exception);
1034 if (LocaleCompare(
"compose",option+1) == 0)
1036 (void) SyncImageSettings(mogrify_info,*image,exception);
1037 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1038 MagickFalse,argv[i+1]);
1041 if (LocaleCompare(
"connected-components",option+1) == 0)
1043 (void) SyncImageSettings(mogrify_info,*image,exception);
1044 mogrify_image=ConnectedComponentsImage(*image,(
size_t)
1045 StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);
1048 if (LocaleCompare(
"contrast",option+1) == 0)
1050 (void) SyncImageSettings(mogrify_info,*image,exception);
1051 (void) ContrastImage(*image,(*option ==
'-') ? MagickTrue :
1052 MagickFalse,exception);
1055 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
1064 (void) SyncImageSettings(mogrify_info,*image,exception);
1065 flags=ParseGeometry(argv[i+1],&geometry_info);
1066 black_point=geometry_info.rho;
1067 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1069 if ((flags & PercentValue) != 0)
1071 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1072 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1074 white_point=(double) (*image)->columns*(*image)->rows-
1076 (void) ContrastStretchImage(*image,black_point,white_point,
1080 if (LocaleCompare(
"convolve",option+1) == 0)
1094 (void) SyncImageSettings(mogrify_info,*image,exception);
1095 kernel_info=AcquireKernelInfo(argv[i+1],exception);
1096 if (kernel_info == (KernelInfo *) NULL)
1098 extent=kernel_info->width*kernel_info->height;
1100 for (j=0; j < (ssize_t) extent; j++)
1101 gamma+=kernel_info->values[j];
1102 gamma=1.0/(fabs((
double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1103 for (j=0; j < (ssize_t) extent; j++)
1104 kernel_info->values[j]*=gamma;
1105 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1106 kernel_info,exception);
1107 kernel_info=DestroyKernelInfo(kernel_info);
1110 if (LocaleCompare(
"crop",option+1) == 0)
1115 (void) SyncImageSettings(mogrify_info,*image,exception);
1116 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1119 if (LocaleCompare(
"cycle",option+1) == 0)
1124 (void) SyncImageSettings(mogrify_info,*image,exception);
1125 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1133 if (LocaleCompare(
"decipher",option+1) == 0)
1141 (void) SyncImageSettings(mogrify_info,*image,exception);
1142 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1143 if (passkey != (StringInfo *) NULL)
1145 (void) PasskeyDecipherImage(*image,passkey,exception);
1146 passkey=DestroyStringInfo(passkey);
1150 if (LocaleCompare(
"density",option+1) == 0)
1155 (void) CloneString(&draw_info->density,argv[i+1]);
1158 if (LocaleCompare(
"depth",option+1) == 0)
1160 (void) SyncImageSettings(mogrify_info,*image,exception);
1163 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1166 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1170 if (LocaleCompare(
"deskew",option+1) == 0)
1178 (void) SyncImageSettings(mogrify_info,*image,exception);
1180 threshold=40.0*(double) QuantumRange/100.0;
1182 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
1184 mogrify_image=DeskewImage(*image,threshold,exception);
1187 if (LocaleCompare(
"despeckle",option+1) == 0)
1192 (void) SyncImageSettings(mogrify_info,*image,exception);
1193 mogrify_image=DespeckleImage(*image,exception);
1196 if (LocaleCompare(
"display",option+1) == 0)
1198 (void) CloneString(&draw_info->server_name,argv[i+1]);
1201 if (LocaleCompare(
"distort",option+1) == 0)
1205 token[MagickPathExtent];
1225 (void) SyncImageSettings(mogrify_info,*image,exception);
1226 method=(DistortMethod) ParseCommandOption(MagickDistortOptions,
1227 MagickFalse,argv[i+1]);
1228 if (method == ResizeDistortion)
1237 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1239 resize_args[0]=(double) geometry.width;
1240 resize_args[1]=(double) geometry.height;
1241 mogrify_image=DistortImage(*image,method,(
size_t)2,
1242 resize_args,MagickTrue,exception);
1245 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1247 if (args == (
char *) NULL)
1250 for (x=0; *p !=
'\0'; x++)
1252 (void) GetNextToken(p,&p,MagickPathExtent,token);
1254 (void) GetNextToken(p,&p,MagickPathExtent,token);
1256 number_arguments=(size_t) x;
1257 arguments=(
double *) AcquireQuantumMemory(number_arguments,
1258 sizeof(*arguments));
1259 if (arguments == (
double *) NULL)
1260 ThrowWandFatalException(ResourceLimitFatalError,
1261 "MemoryAllocationFailed",(*image)->filename);
1262 (void) memset(arguments,0,number_arguments*
1263 sizeof(*arguments));
1265 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
1267 (void) GetNextToken(p,&p,MagickPathExtent,token);
1269 (void) GetNextToken(p,&p,MagickPathExtent,token);
1270 arguments[x]=StringToDouble(token,(
char **) NULL);
1272 args=DestroyString(args);
1273 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1274 (*option ==
'+') ? MagickTrue : MagickFalse,exception);
1275 arguments=(
double *) RelinquishMagickMemory(arguments);
1278 if (LocaleCompare(
"dither",option+1) == 0)
1282 quantize_info->dither_method=NoDitherMethod;
1285 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1286 MagickDitherOptions,MagickFalse,argv[i+1]);
1289 if (LocaleCompare(
"draw",option+1) == 0)
1294 (void) SyncImageSettings(mogrify_info,*image,exception);
1295 (void) CloneString(&draw_info->primitive,argv[i+1]);
1296 (void) DrawImage(*image,draw_info,exception);
1303 if (LocaleCompare(
"edge",option+1) == 0)
1308 (void) SyncImageSettings(mogrify_info,*image,exception);
1309 flags=ParseGeometry(argv[i+1],&geometry_info);
1310 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1313 if (LocaleCompare(
"emboss",option+1) == 0)
1318 (void) SyncImageSettings(mogrify_info,*image,exception);
1319 flags=ParseGeometry(argv[i+1],&geometry_info);
1320 if ((flags & SigmaValue) == 0)
1321 geometry_info.sigma=1.0;
1322 mogrify_image=EmbossImage(*image,geometry_info.rho,
1323 geometry_info.sigma,exception);
1326 if (LocaleCompare(
"encipher",option+1) == 0)
1334 (void) SyncImageSettings(mogrify_info,*image,exception);
1335 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1336 if (passkey != (StringInfo *) NULL)
1338 (void) PasskeyEncipherImage(*image,passkey,exception);
1339 passkey=DestroyStringInfo(passkey);
1343 if (LocaleCompare(
"encoding",option+1) == 0)
1345 (void) CloneString(&draw_info->encoding,argv[i+1]);
1348 if (LocaleCompare(
"enhance",option+1) == 0)
1353 (void) SyncImageSettings(mogrify_info,*image,exception);
1354 mogrify_image=EnhanceImage(*image,exception);
1357 if (LocaleCompare(
"equalize",option+1) == 0)
1362 (void) SyncImageSettings(mogrify_info,*image,exception);
1363 (void) EqualizeImage(*image,exception);
1366 if (LocaleCompare(
"evaluate",option+1) == 0)
1371 MagickEvaluateOperator
1374 (void) SyncImageSettings(mogrify_info,*image,exception);
1375 op=(MagickEvaluateOperator) ParseCommandOption(
1376 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1377 constant=StringToDoubleInterval(argv[i+2],(
double) QuantumRange+
1379 (void) EvaluateImage(*image,op,constant,exception);
1382 if (LocaleCompare(
"extent",option+1) == 0)
1387 (void) SyncImageSettings(mogrify_info,*image,exception);
1388 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1389 if (geometry.width == 0)
1390 geometry.width=(*image)->columns;
1391 if (geometry.height == 0)
1392 geometry.height=(*image)->rows;
1393 mogrify_image=ExtentImage(*image,&geometry,exception);
1400 if (LocaleCompare(
"family",option+1) == 0)
1404 if (draw_info->family != (
char *) NULL)
1405 draw_info->family=DestroyString(draw_info->family);
1408 (void) SetImageOption(image_info,option+1,argv[i+1]);
1409 (void) CloneString(&draw_info->family,argv[i+1]);
1412 if (LocaleCompare(
"features",option+1) == 0)
1416 (void) DeleteImageArtifact(*image,
"identify:features");
1419 (void) SetImageArtifact(*image,
"identify:features",argv[i+1]);
1420 (void) SetImageArtifact(*image,
"verbose",
"true");
1423 if (LocaleCompare(
"fill",option+1) == 0)
1431 GetPixelInfo(*image,&fill);
1434 (void) QueryColorCompliance(
"none",AllCompliance,&fill,
1436 draw_info->fill=fill;
1437 if (draw_info->fill_pattern != (Image *) NULL)
1438 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1441 sans=AcquireExceptionInfo();
1442 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1443 sans=DestroyExceptionInfo(sans);
1444 if (status == MagickFalse)
1445 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1448 draw_info->fill=fill=color;
1451 if (LocaleCompare(
"flip",option+1) == 0)
1456 (void) SyncImageSettings(mogrify_info,*image,exception);
1457 mogrify_image=FlipImage(*image,exception);
1460 if (LocaleCompare(
"floodfill",option+1) == 0)
1468 (void) SyncImageSettings(mogrify_info,*image,exception);
1469 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1470 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1472 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1473 geometry.y,*option ==
'-' ? MagickFalse : MagickTrue,exception);
1476 if (LocaleCompare(
"flop",option+1) == 0)
1481 (void) SyncImageSettings(mogrify_info,*image,exception);
1482 mogrify_image=FlopImage(*image,exception);
1485 if (LocaleCompare(
"font",option+1) == 0)
1489 if (draw_info->font != (
char *) NULL)
1490 draw_info->font=DestroyString(draw_info->font);
1493 (void) CloneString(&draw_info->font,argv[i+1]);
1496 if (LocaleCompare(
"format",option+1) == 0)
1501 if (LocaleCompare(
"frame",option+1) == 0)
1509 (void) SyncImageSettings(mogrify_info,*image,exception);
1510 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1511 frame_info.width=geometry.width;
1512 frame_info.height=geometry.height;
1513 frame_info.outer_bevel=geometry.x;
1514 frame_info.inner_bevel=geometry.y;
1515 frame_info.x=(ssize_t) frame_info.width;
1516 frame_info.y=(ssize_t) frame_info.height;
1517 frame_info.width=(*image)->columns+2*frame_info.width;
1518 frame_info.height=(*image)->rows+2*frame_info.height;
1519 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1522 if (LocaleCompare(
"function",option+1) == 0)
1526 token[MagickPathExtent];
1546 (void) SyncImageSettings(mogrify_info,*image,exception);
1547 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1548 MagickFalse,argv[i+1]);
1549 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1551 if (arguments == (
char *) NULL)
1553 p=(
char *) arguments;
1554 for (x=0; *p !=
'\0'; x++)
1556 (void) GetNextToken(p,&p,MagickPathExtent,token);
1558 (void) GetNextToken(p,&p,MagickPathExtent,token);
1560 number_parameters=(size_t) x;
1561 parameters=(
double *) AcquireQuantumMemory(number_parameters,
1562 sizeof(*parameters));
1563 if (parameters == (
double *) NULL)
1564 ThrowWandFatalException(ResourceLimitFatalError,
1565 "MemoryAllocationFailed",(*image)->filename);
1566 (void) memset(parameters,0,number_parameters*
1567 sizeof(*parameters));
1568 p=(
char *) arguments;
1569 for (x=0; (x < (ssize_t) number_parameters) && (*p !=
'\0'); x++)
1571 (void) GetNextToken(p,&p,MagickPathExtent,token);
1573 (void) GetNextToken(p,&p,MagickPathExtent,token);
1574 parameters[x]=StringToDouble(token,(
char **) NULL);
1576 arguments=DestroyString(arguments);
1577 (void) FunctionImage(*image,function,number_parameters,parameters,
1579 parameters=(
double *) RelinquishMagickMemory(parameters);
1586 if (LocaleCompare(
"gamma",option+1) == 0)
1591 (void) SyncImageSettings(mogrify_info,*image,exception);
1593 (*image)->gamma=StringToDouble(argv[i+1],(
char **) NULL);
1595 (
void) GammaImage(*image,StringToDouble(argv[i+1],(
char **) NULL),
1599 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
1600 (LocaleCompare(
"gaussian",option+1) == 0))
1605 (void) SyncImageSettings(mogrify_info,*image,exception);
1606 flags=ParseGeometry(argv[i+1],&geometry_info);
1607 if ((flags & SigmaValue) == 0)
1608 geometry_info.sigma=1.0;
1609 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1610 geometry_info.sigma,exception);
1613 if (LocaleCompare(
"geometry",option+1) == 0)
1618 (void) SyncImageSettings(mogrify_info,*image,exception);
1621 if ((*image)->geometry != (
char *) NULL)
1622 (*image)->geometry=DestroyString((*image)->geometry);
1625 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1626 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1627 (void) CloneString(&(*image)->geometry,argv[i+1]);
1629 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1630 (*image)->filter,exception);
1633 if (LocaleCompare(
"gravity",option+1) == 0)
1637 draw_info->gravity=UndefinedGravity;
1640 draw_info->gravity=(GravityType) ParseCommandOption(
1641 MagickGravityOptions,MagickFalse,argv[i+1]);
1644 if (LocaleCompare(
"grayscale",option+1) == 0)
1646 PixelIntensityMethod
1649 (void) SyncImageSettings(mogrify_info,*image,exception);
1650 method=(PixelIntensityMethod) ParseCommandOption(
1651 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1652 (void) GrayscaleImage(*image,method,exception);
1659 if (LocaleCompare(
"highlight-color",option+1) == 0)
1661 (void) SetImageArtifact(*image,
"compare:highlight-color",argv[i+1]);
1664 if (LocaleCompare(
"hough-lines",option+1) == 0)
1669 (void) SyncImageSettings(mogrify_info,*image,exception);
1670 flags=ParseGeometry(argv[i+1],&geometry_info);
1671 if ((flags & SigmaValue) == 0)
1672 geometry_info.sigma=geometry_info.rho;
1673 if ((flags & XiValue) == 0)
1674 geometry_info.xi=40;
1675 mogrify_image=HoughLineImage(*image,(
size_t) geometry_info.rho,
1676 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,exception);
1683 if (LocaleCompare(
"identify",option+1) == 0)
1688 (void) SyncImageSettings(mogrify_info,*image,exception);
1689 if (format == (
char *) NULL)
1691 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1695 text=InterpretImageProperties(mogrify_info,*image,format,exception);
1696 if (text == (
char *) NULL)
1698 (void) fputs(text,stdout);
1699 text=DestroyString(text);
1702 if (LocaleCompare(
"illuminant",option+1) == 0)
1704 (void) SetImageArtifact(*image,
"color:illuminant",argv[i+1]);
1707 if (LocaleCompare(
"implode",option+1) == 0)
1712 (void) SyncImageSettings(mogrify_info,*image,exception);
1713 (void) ParseGeometry(argv[i+1],&geometry_info);
1714 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1715 interpolate_method,exception);
1718 if (LocaleCompare(
"integral",option+1) == 0)
1720 (void) SyncImageSettings(mogrify_info,*image,exception);
1721 mogrify_image=IntegralImage(*image,exception);
1724 if (LocaleCompare(
"interline-spacing",option+1) == 0)
1727 (void) ParseGeometry(
"0",&geometry_info);
1729 (
void) ParseGeometry(argv[i+1],&geometry_info);
1730 draw_info->interline_spacing=geometry_info.rho;
1733 if (LocaleCompare(
"interpolate",option+1) == 0)
1735 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1736 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1739 if (LocaleCompare(
"interword-spacing",option+1) == 0)
1742 (void) ParseGeometry(
"0",&geometry_info);
1744 (
void) ParseGeometry(argv[i+1],&geometry_info);
1745 draw_info->interword_spacing=geometry_info.rho;
1748 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
1753 (void) SyncImageSettings(mogrify_info,*image,exception);
1754 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1755 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1756 geometry.height,interpolate_method,exception);
1763 if (LocaleCompare(
"kerning",option+1) == 0)
1766 (void) ParseGeometry(
"0",&geometry_info);
1768 (
void) ParseGeometry(argv[i+1],&geometry_info);
1769 draw_info->kerning=geometry_info.rho;
1772 if (LocaleCompare(
"kmeans",option+1) == 0)
1777 (void) SyncImageSettings(mogrify_info,*image,exception);
1778 flags=ParseGeometry(argv[i+1],&geometry_info);
1779 if ((flags & SigmaValue) == 0)
1780 geometry_info.sigma=300.0;
1781 if ((flags & XiValue) == 0)
1782 geometry_info.xi=0.0001;
1783 (void) KmeansImage(*image,(
size_t) geometry_info.rho,
1784 (
size_t) geometry_info.sigma,geometry_info.xi,exception);
1787 if (LocaleCompare(
"kuwahara",option+1) == 0)
1792 (void) SyncImageSettings(mogrify_info,*image,exception);
1793 flags=ParseGeometry(argv[i+1],&geometry_info);
1794 if ((flags & SigmaValue) == 0)
1795 geometry_info.sigma=geometry_info.rho-0.5;
1796 mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1797 geometry_info.sigma,exception);
1804 if (LocaleCompare(
"lat",option+1) == 0)
1809 (void) SyncImageSettings(mogrify_info,*image,exception);
1810 flags=ParseGeometry(argv[i+1],&geometry_info);
1811 if ((flags & PercentValue) != 0)
1812 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1813 mogrify_image=AdaptiveThresholdImage(*image,(
size_t)
1814 geometry_info.rho,(
size_t) geometry_info.sigma,(
double)
1815 geometry_info.xi,exception);
1818 if (LocaleCompare(
"level",option+1) == 0)
1828 (void) SyncImageSettings(mogrify_info,*image,exception);
1829 flags=ParseGeometry(argv[i+1],&geometry_info);
1830 black_point=geometry_info.rho;
1831 white_point=(double) QuantumRange;
1832 if ((flags & SigmaValue) != 0)
1833 white_point=geometry_info.sigma;
1835 if ((flags & XiValue) != 0)
1836 gamma=geometry_info.xi;
1837 if ((flags & PercentValue) != 0)
1839 black_point*=(double) QuantumRange/100.0;
1840 white_point*=(double) QuantumRange/100.0;
1842 if ((flags & SigmaValue) == 0)
1843 white_point=(double) QuantumRange-black_point;
1844 if ((*option ==
'+') || ((flags & AspectValue) != 0))
1845 (void) LevelizeImage(*image,black_point,white_point,gamma,
1848 (
void) LevelImage(*image,black_point,white_point,gamma,exception);
1851 if (LocaleCompare(
"level-colors",option+1) == 0)
1854 token[MagickPathExtent];
1863 p=(
const char *) argv[i+1];
1864 (void) GetNextToken(p,&p,MagickPathExtent,token);
1865 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
1866 (void) QueryColorCompliance(token,AllCompliance,&black_point,
1869 (
void) QueryColorCompliance(
"#000000",AllCompliance,&black_point,
1871 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
1872 (void) GetNextToken(p,&p,MagickPathExtent,token);
1874 white_point=black_point;
1877 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
1878 (void) GetNextToken(p,&p,MagickPathExtent,token);
1879 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
1880 (void) QueryColorCompliance(token,AllCompliance,&white_point,
1883 (
void) QueryColorCompliance(
"#ffffff",AllCompliance,
1884 &white_point,exception);
1886 (void) LevelImageColors(*image,&black_point,&white_point,
1887 *option ==
'+' ? MagickTrue : MagickFalse,exception);
1890 if (LocaleCompare(
"linear-stretch",option+1) == 0)
1896 (void) SyncImageSettings(mogrify_info,*image,exception);
1897 flags=ParseGeometry(argv[i+1],&geometry_info);
1898 black_point=geometry_info.rho;
1899 white_point=(double) (*image)->columns*(*image)->rows;
1900 if ((flags & SigmaValue) != 0)
1901 white_point=geometry_info.sigma;
1902 if ((flags & PercentValue) != 0)
1904 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1905 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1907 if ((flags & SigmaValue) == 0)
1908 white_point=(double) (*image)->columns*(*image)->rows-
1910 (void) LinearStretchImage(*image,black_point,white_point,exception);
1913 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
1918 (void) SyncImageSettings(mogrify_info,*image,exception);
1919 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1920 if ((flags & XValue) == 0)
1922 if ((flags & YValue) == 0)
1924 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1925 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1928 if (LocaleCompare(
"local-contrast",option+1) == 0)
1930 (void) SyncImageSettings(mogrify_info,*image,exception);
1931 flags=ParseGeometry(argv[i+1],&geometry_info);
1932 if ((flags & RhoValue) == 0)
1933 geometry_info.rho=10;
1934 if ((flags & SigmaValue) == 0)
1935 geometry_info.sigma=12.5;
1936 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
1937 geometry_info.sigma,exception);
1940 if (LocaleCompare(
"lowlight-color",option+1) == 0)
1942 (void) SetImageArtifact(*image,
"compare:lowlight-color",argv[i+1]);
1949 if (LocaleCompare(
"magnify",option+1) == 0)
1954 (void) SyncImageSettings(mogrify_info,*image,exception);
1955 mogrify_image=MagnifyImage(*image,exception);
1958 if (LocaleCompare(
"map",option+1) == 0)
1966 (void) SyncImageSettings(mogrify_info,*image,exception);
1969 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
1970 if (remap_image == (Image *) NULL)
1972 (void) RemapImage(quantize_info,*image,remap_image,exception);
1973 remap_image=DestroyImage(remap_image);
1976 if (LocaleCompare(
"mask",option+1) == 0)
1981 (void) SyncImageSettings(mogrify_info,*image,exception);
1987 (void) SetImageMask(*image,WritePixelMask,(
const Image *) NULL,
1994 mask=GetImageCache(mogrify_info,argv[i+1],exception);
1995 if (mask == (Image *) NULL)
1997 (void) SetImageMask(*image,WritePixelMask,mask,exception);
1998 mask=DestroyImage(mask);
2001 if (LocaleCompare(
"matte",option+1) == 0)
2003 (void) SetImageAlphaChannel(*image,(*option ==
'-') ?
2004 SetAlphaChannel : DeactivateAlphaChannel,exception);
2007 if (LocaleCompare(
"mean-shift",option+1) == 0)
2012 (void) SyncImageSettings(mogrify_info,*image,exception);
2013 flags=ParseGeometry(argv[i+1],&geometry_info);
2014 if ((flags & SigmaValue) == 0)
2015 geometry_info.sigma=geometry_info.rho;
2016 if ((flags & XiValue) == 0)
2017 geometry_info.xi=0.10*(double) QuantumRange;
2018 if ((flags & PercentValue) != 0)
2019 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2020 mogrify_image=MeanShiftImage(*image,(
size_t) geometry_info.rho,
2021 (
size_t) geometry_info.sigma,geometry_info.xi,exception);
2024 if (LocaleCompare(
"median",option+1) == 0)
2029 (void) SyncImageSettings(mogrify_info,*image,exception);
2030 flags=ParseGeometry(argv[i+1],&geometry_info);
2031 if ((flags & SigmaValue) == 0)
2032 geometry_info.sigma=geometry_info.rho;
2033 mogrify_image=StatisticImage(*image,MedianStatistic,(
size_t)
2034 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
2037 if (LocaleCompare(
"mode",option+1) == 0)
2042 (void) SyncImageSettings(mogrify_info,*image,exception);
2043 flags=ParseGeometry(argv[i+1],&geometry_info);
2044 if ((flags & SigmaValue) == 0)
2045 geometry_info.sigma=geometry_info.rho;
2046 mogrify_image=StatisticImage(*image,ModeStatistic,(
size_t)
2047 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
2050 if (LocaleCompare(
"modulate",option+1) == 0)
2052 (void) SyncImageSettings(mogrify_info,*image,exception);
2053 (void) ModulateImage(*image,argv[i+1],exception);
2056 if (LocaleCompare(
"moments",option+1) == 0)
2060 (void) DeleteImageArtifact(*image,
"identify:moments");
2063 (void) SetImageArtifact(*image,
"identify:moments",argv[i+1]);
2064 (void) SetImageArtifact(*image,
"verbose",
"true");
2067 if (LocaleCompare(
"monitor",option+1) == 0)
2071 (void) SetImageProgressMonitor(*image,
2072 (MagickProgressMonitor) NULL,(
void *) NULL);
2075 (void) SetImageProgressMonitor(*image,MonitorProgress,
2079 if (LocaleCompare(
"monochrome",option+1) == 0)
2081 (void) SyncImageSettings(mogrify_info,*image,exception);
2082 (void) SetImageType(*image,BilevelType,exception);
2085 if (LocaleCompare(
"morphology",option+1) == 0)
2088 token[MagickPathExtent];
2105 (void) SyncImageSettings(mogrify_info,*image,exception);
2107 (void) GetNextToken(p,&p,MagickPathExtent,token);
2108 method=(MorphologyMethod) ParseCommandOption(
2109 MagickMorphologyOptions,MagickFalse,token);
2111 (void) GetNextToken(p,&p,MagickPathExtent,token);
2112 if ((*p ==
':') || (*p ==
','))
2113 (void) GetNextToken(p,&p,MagickPathExtent,token);
2115 iterations=(ssize_t) StringToLong(p);
2116 kernel=AcquireKernelInfo(argv[i+2],exception);
2117 if (kernel == (KernelInfo *) NULL)
2119 (void) ThrowMagickException(exception,GetMagickModule(),
2120 OptionError,
"UnabletoParseKernel",
"morphology");
2124 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2126 kernel=DestroyKernelInfo(kernel);
2129 if (LocaleCompare(
"motion-blur",option+1) == 0)
2134 (void) SyncImageSettings(mogrify_info,*image,exception);
2135 flags=ParseGeometry(argv[i+1],&geometry_info);
2136 if ((flags & SigmaValue) == 0)
2137 geometry_info.sigma=1.0;
2138 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2139 geometry_info.sigma,geometry_info.xi,exception);
2146 if (LocaleCompare(
"negate",option+1) == 0)
2148 (void) SyncImageSettings(mogrify_info,*image,exception);
2149 (void) NegateImage(*image,*option ==
'+' ? MagickTrue :
2150 MagickFalse,exception);
2153 if (LocaleCompare(
"noise",option+1) == 0)
2155 (void) SyncImageSettings(mogrify_info,*image,exception);
2158 flags=ParseGeometry(argv[i+1],&geometry_info);
2159 if ((flags & SigmaValue) == 0)
2160 geometry_info.sigma=geometry_info.rho;
2161 mogrify_image=StatisticImage(*image,NonpeakStatistic,(
size_t)
2162 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
2169 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2170 MagickFalse,argv[i+1]);
2171 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2175 if (LocaleCompare(
"normalize",option+1) == 0)
2177 (void) SyncImageSettings(mogrify_info,*image,exception);
2178 (void) NormalizeImage(*image,exception);
2185 if (LocaleCompare(
"opaque",option+1) == 0)
2190 (void) SyncImageSettings(mogrify_info,*image,exception);
2191 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2193 (void) OpaquePaintImage(*image,&target,&fill,*option ==
'-' ?
2194 MagickFalse : MagickTrue,exception);
2197 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2199 (void) SyncImageSettings(mogrify_info,*image,exception);
2200 (void) OrderedDitherImage(*image,argv[i+1],exception);
2207 if (LocaleCompare(
"paint",option+1) == 0)
2209 (void) SyncImageSettings(mogrify_info,*image,exception);
2210 (void) ParseGeometry(argv[i+1],&geometry_info);
2211 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2212 geometry_info.sigma,exception);
2215 if (LocaleCompare(
"perceptible",option+1) == 0)
2220 (void) SyncImageSettings(mogrify_info,*image,exception);
2221 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2222 (
char **) NULL),exception);
2225 if (LocaleCompare(
"pointsize",option+1) == 0)
2228 (void) ParseGeometry(
"12",&geometry_info);
2230 (
void) ParseGeometry(argv[i+1],&geometry_info);
2231 draw_info->pointsize=geometry_info.rho;
2234 if (LocaleCompare(
"polaroid",option+1) == 0)
2248 (void) SyncImageSettings(mogrify_info,*image,exception);
2249 random_info=AcquireRandomInfo();
2250 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2251 random_info=DestroyRandomInfo(random_info);
2254 SetGeometryInfo(&geometry_info);
2255 flags=ParseGeometry(argv[i+1],&geometry_info);
2256 angle=geometry_info.rho;
2258 caption=GetImageProperty(*image,
"caption",exception);
2259 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2260 interpolate_method,exception);
2263 if (LocaleCompare(
"posterize",option+1) == 0)
2268 (void) SyncImageSettings(mogrify_info,*image,exception);
2269 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2270 quantize_info->dither_method,exception);
2273 if (LocaleCompare(
"preview",option+1) == 0)
2281 (void) SyncImageSettings(mogrify_info,*image,exception);
2283 preview_type=UndefinedPreview;
2285 preview_type=(PreviewType) ParseCommandOption(
2286 MagickPreviewOptions,MagickFalse,argv[i+1]);
2287 mogrify_image=PreviewImage(*image,preview_type,exception);
2290 if (LocaleCompare(
"profile",option+1) == 0)
2307 (void) SyncImageSettings(mogrify_info,*image,exception);
2313 (void) ProfileImage(*image,argv[i+1],(
const unsigned char *)
2320 profile_info=CloneImageInfo(mogrify_info);
2321 profile=GetImageProfile(*image,
"iptc");
2322 if (profile != (StringInfo *) NULL)
2323 profile_info->profile=(
void *) CloneStringInfo(profile);
2324 sans_exception=AcquireExceptionInfo();
2325 profile_image=GetImageCache(profile_info,argv[i+1],sans_exception);
2326 sans_exception=DestroyExceptionInfo(sans_exception);
2327 profile_info=DestroyImageInfo(profile_info);
2328 if (profile_image == (Image *) NULL)
2333 profile_info=CloneImageInfo(mogrify_info);
2334 (void) CopyMagickString(profile_info->filename,argv[i+1],
2336 file_data=FileToStringInfo(profile_info->filename,~0UL,
2338 if (file_data != (StringInfo *) NULL)
2340 (void) SetImageInfo(profile_info,0,exception);
2341 (void) ProfileImage(*image,profile_info->magick,
2342 GetStringInfoDatum(file_data),
2343 GetStringInfoLength(file_data),exception);
2344 file_data=DestroyStringInfo(file_data);
2346 profile_info=DestroyImageInfo(profile_info);
2349 ResetImageProfileIterator(profile_image);
2350 name=GetNextImageProfile(profile_image);
2351 while (name != (
const char *) NULL)
2353 profile=GetImageProfile(profile_image,name);
2354 if (profile != (StringInfo *) NULL)
2355 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2356 (
size_t) GetStringInfoLength(profile),exception);
2357 name=GetNextImageProfile(profile_image);
2359 profile_image=DestroyImage(profile_image);
2366 if (LocaleCompare(
"quantize",option+1) == 0)
2370 quantize_info->colorspace=UndefinedColorspace;
2373 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2374 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2381 if (LocaleCompare(
"rotational-blur",option+1) == 0)
2386 (void) SyncImageSettings(mogrify_info,*image,exception);
2387 flags=ParseGeometry(argv[i+1],&geometry_info);
2388 mogrify_image=RotationalBlurImage(*image,geometry_info.rho,
2392 if (LocaleCompare(
"raise",option+1) == 0)
2397 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2398 (void) RaiseImage(*image,&geometry,*option ==
'-' ? MagickTrue :
2399 MagickFalse,exception);
2402 if (LocaleCompare(
"random-threshold",option+1) == 0)
2411 (void) SyncImageSettings(mogrify_info,*image,exception);
2413 max_threshold=(double) QuantumRange;
2414 flags=ParseGeometry(argv[i+1],&geometry_info);
2415 min_threshold=geometry_info.rho;
2416 max_threshold=geometry_info.sigma;
2417 if ((flags & SigmaValue) == 0)
2418 max_threshold=min_threshold;
2419 if (strchr(argv[i+1],
'%') != (
char *) NULL)
2421 max_threshold*=0.01*(double) QuantumRange;
2422 min_threshold*=0.01*(double) QuantumRange;
2424 (void) RandomThresholdImage(*image,min_threshold,max_threshold,
2428 if (LocaleCompare(
"range-threshold",option+1) == 0)
2433 (void) SyncImageSettings(mogrify_info,*image,exception);
2434 flags=ParseGeometry(argv[i+1],&geometry_info);
2435 if ((flags & SigmaValue) == 0)
2436 geometry_info.sigma=geometry_info.rho;
2437 if ((flags & XiValue) == 0)
2438 geometry_info.xi=geometry_info.sigma;
2439 if ((flags & PsiValue) == 0)
2440 geometry_info.psi=geometry_info.xi;
2441 if (strchr(argv[i+1],
'%') != (
char *) NULL)
2443 geometry_info.rho*=0.01*(double) QuantumRange;
2444 geometry_info.sigma*=0.01*(double) QuantumRange;
2445 geometry_info.xi*=0.01*(double) QuantumRange;
2446 geometry_info.psi*=0.01*(double) QuantumRange;
2448 (void) RangeThresholdImage(*image,geometry_info.rho,
2449 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2452 if (LocaleCompare(
"read-mask",option+1) == 0)
2457 (void) SyncImageSettings(mogrify_info,*image,exception);
2463 (void) SetImageMask(*image,ReadPixelMask,(
const Image *) NULL,
2470 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2471 if (mask == (Image *) NULL)
2473 (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2474 mask=DestroyImage(mask);
2477 if (LocaleCompare(
"region",option+1) == 0)
2482 (void) SyncImageSettings(mogrify_info,*image,exception);
2485 (void) SetImageRegionMask(*image,WritePixelMask,
2486 (
const RectangleInfo *) NULL,exception);
2489 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2490 (void) SetImageRegionMask(*image,WritePixelMask,&geometry,
2494 if (LocaleCompare(
"render",option+1) == 0)
2496 (void) SyncImageSettings(mogrify_info,*image,exception);
2497 draw_info->render=(*option ==
'+') ? MagickTrue : MagickFalse;
2500 if (LocaleCompare(
"remap",option+1) == 0)
2508 (void) SyncImageSettings(mogrify_info,*image,exception);
2511 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2512 if (remap_image == (Image *) NULL)
2514 (void) RemapImage(quantize_info,*image,remap_image,exception);
2515 remap_image=DestroyImage(remap_image);
2518 if (LocaleCompare(
"repage",option+1) == 0)
2522 (void) ParseAbsoluteGeometry(
"0x0+0+0",&(*image)->page);
2525 (void) ResetImagePage(*image,argv[i+1]);
2528 if (LocaleCompare(
"resample",option+1) == 0)
2533 (void) SyncImageSettings(mogrify_info,*image,exception);
2534 flags=ParseGeometry(argv[i+1],&geometry_info);
2535 if ((flags & SigmaValue) == 0)
2536 geometry_info.sigma=geometry_info.rho;
2537 mogrify_image=ResampleImage(*image,geometry_info.rho,
2538 geometry_info.sigma,(*image)->filter,exception);
2541 if (LocaleCompare(
"reshape",option+1) == 0)
2546 (void) SyncImageSettings(mogrify_info,*image,exception);
2547 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2548 (void) ReshapePixelCache(*image,geometry.width,geometry.height,
2552 if (LocaleCompare(
"resize",option+1) == 0)
2557 (void) SyncImageSettings(mogrify_info,*image,exception);
2558 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2559 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2560 (*image)->filter,exception);
2563 if (LocaleCompare(
"roll",option+1) == 0)
2568 (void) SyncImageSettings(mogrify_info,*image,exception);
2569 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2570 if ((flags & PercentValue) != 0)
2572 geometry.x*=(ssize_t) ((*image)->columns/100.0);
2573 geometry.y*=(ssize_t) ((*image)->rows/100.0);
2575 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2578 if (LocaleCompare(
"rotate",option+1) == 0)
2586 (void) SyncImageSettings(mogrify_info,*image,exception);
2587 if (strchr(argv[i+1],
'>') != (
char *) NULL)
2588 if ((*image)->columns <= (*image)->rows)
2590 if (strchr(argv[i+1],
'<') != (
char *) NULL)
2591 if ((*image)->columns >= (*image)->rows)
2596 rotation=ConstantString(argv[i+1]);
2597 (void) SubstituteString(&rotation,
">",
"");
2598 (void) SubstituteString(&rotation,
"<",
"");
2599 (void) ParseGeometry(rotation,&geometry_info);
2600 rotation=DestroyString(rotation);
2601 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2608 if (LocaleCompare(
"sample",option+1) == 0)
2613 (void) SyncImageSettings(mogrify_info,*image,exception);
2614 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2615 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2619 if (LocaleCompare(
"scale",option+1) == 0)
2624 (void) SyncImageSettings(mogrify_info,*image,exception);
2625 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2626 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2630 if (LocaleCompare(
"selective-blur",option+1) == 0)
2635 (void) SyncImageSettings(mogrify_info,*image,exception);
2636 flags=ParseGeometry(argv[i+1],&geometry_info);
2637 if ((flags & PercentValue) != 0)
2638 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2639 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2640 geometry_info.sigma,geometry_info.xi,exception);
2643 if (LocaleCompare(
"separate",option+1) == 0)
2648 (void) SyncImageSettings(mogrify_info,*image,exception);
2649 mogrify_image=SeparateImages(*image,exception);
2652 if (LocaleCompare(
"sepia-tone",option+1) == 0)
2660 (void) SyncImageSettings(mogrify_info,*image,exception);
2661 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2663 mogrify_image=SepiaToneImage(*image,threshold,exception);
2666 if (LocaleCompare(
"segment",option+1) == 0)
2671 (void) SyncImageSettings(mogrify_info,*image,exception);
2672 flags=ParseGeometry(argv[i+1],&geometry_info);
2673 if ((flags & SigmaValue) == 0)
2674 geometry_info.sigma=1.0;
2675 (void) SegmentImage(*image,(*image)->colorspace,
2676 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2680 if (LocaleCompare(
"set",option+1) == 0)
2690 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2691 (void) DeleteImageRegistry(argv[i+1]+9);
2693 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2695 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2696 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2699 (
void) DeleteImageProperty(*image,argv[i+1]);
2702 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2704 if (value == (
char *) NULL)
2706 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2707 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2710 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2712 (void) SetImageOption(image_info,argv[i+1]+7,value);
2713 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2714 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2717 if (LocaleCompare(argv[i+1],
"profile") == 0)
2720 *profile = (StringInfo *) NULL;
2722 (void) CopyMagickString(image_info->filename,value,
2724 (void) SetImageInfo(image_info,1,exception);
2725 if (LocaleCompare(image_info->filename,
"-") != 0)
2726 profile=FileToStringInfo(image_info->filename,~0UL,
2728 if (profile != (StringInfo *) NULL)
2730 SetStringInfoName(profile,image_info->magick);
2731 status=SetImageProfilePrivate(*image,profile,exception);
2735 (
void) SetImageProperty(*image,argv[i+1],value,exception);
2736 value=DestroyString(value);
2739 if (LocaleCompare(
"shade",option+1) == 0)
2744 (void) SyncImageSettings(mogrify_info,*image,exception);
2745 flags=ParseGeometry(argv[i+1],&geometry_info);
2746 if ((flags & SigmaValue) == 0)
2747 geometry_info.sigma=1.0;
2748 mogrify_image=ShadeImage(*image,(*option ==
'-') ? MagickTrue :
2749 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2752 if (LocaleCompare(
"shadow",option+1) == 0)
2757 (void) SyncImageSettings(mogrify_info,*image,exception);
2758 flags=ParseGeometry(argv[i+1],&geometry_info);
2759 if ((flags & SigmaValue) == 0)
2760 geometry_info.sigma=1.0;
2761 if ((flags & XiValue) == 0)
2762 geometry_info.xi=4.0;
2763 if ((flags & PsiValue) == 0)
2764 geometry_info.psi=4.0;
2765 mogrify_image=ShadowImage(*image,geometry_info.rho,
2766 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2767 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2770 if (LocaleCompare(
"sharpen",option+1) == 0)
2775 (void) SyncImageSettings(mogrify_info,*image,exception);
2776 flags=ParseGeometry(argv[i+1],&geometry_info);
2777 if ((flags & SigmaValue) == 0)
2778 geometry_info.sigma=1.0;
2779 if ((flags & XiValue) == 0)
2780 geometry_info.xi=0.0;
2781 mogrify_image=SharpenImage(*image,geometry_info.rho,
2782 geometry_info.sigma,exception);
2785 if (LocaleCompare(
"shave",option+1) == 0)
2790 (void) SyncImageSettings(mogrify_info,*image,exception);
2791 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2792 mogrify_image=ShaveImage(*image,&geometry,exception);
2795 if (LocaleCompare(
"shear",option+1) == 0)
2800 (void) SyncImageSettings(mogrify_info,*image,exception);
2801 flags=ParseGeometry(argv[i+1],&geometry_info);
2802 if ((flags & SigmaValue) == 0)
2803 geometry_info.sigma=geometry_info.rho;
2804 mogrify_image=ShearImage(*image,geometry_info.rho,
2805 geometry_info.sigma,exception);
2808 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
2813 (void) SyncImageSettings(mogrify_info,*image,exception);
2814 flags=ParseGeometry(argv[i+1],&geometry_info);
2815 if ((flags & SigmaValue) == 0)
2816 geometry_info.sigma=(double) QuantumRange/2.0;
2817 if ((flags & PercentValue) != 0)
2818 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2820 (void) SigmoidalContrastImage(*image,(*option ==
'-') ?
2821 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2825 if (LocaleCompare(
"sketch",option+1) == 0)
2830 (void) SyncImageSettings(mogrify_info,*image,exception);
2831 flags=ParseGeometry(argv[i+1],&geometry_info);
2832 if ((flags & SigmaValue) == 0)
2833 geometry_info.sigma=1.0;
2834 mogrify_image=SketchImage(*image,geometry_info.rho,
2835 geometry_info.sigma,geometry_info.xi,exception);
2838 if (LocaleCompare(
"solarize",option+1) == 0)
2843 (void) SyncImageSettings(mogrify_info,*image,exception);
2844 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2846 (void) SolarizeImage(*image,threshold,exception);
2849 if (LocaleCompare(
"sort-pixels",option+1) == 0)
2854 (void) SyncImageSettings(mogrify_info,*image,exception);
2855 (void) SortImagePixels(*image,exception);
2858 if (LocaleCompare(
"sparse-color",option+1) == 0)
2869 (void) SyncImageSettings(mogrify_info,*image,exception);
2870 method=(SparseColorMethod) ParseCommandOption(
2871 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2872 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2874 if (arguments == (
char *) NULL)
2876 mogrify_image=SparseColorOption(*image,method,arguments,
2877 option[0] ==
'+' ? MagickTrue : MagickFalse,exception);
2878 arguments=DestroyString(arguments);
2881 if (LocaleCompare(
"splice",option+1) == 0)
2886 (void) SyncImageSettings(mogrify_info,*image,exception);
2887 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2888 mogrify_image=SpliceImage(*image,&geometry,exception);
2891 if (LocaleCompare(
"spread",option+1) == 0)
2896 (void) SyncImageSettings(mogrify_info,*image,exception);
2897 (void) ParseGeometry(argv[i+1],&geometry_info);
2898 mogrify_image=SpreadImage(*image,interpolate_method,
2899 geometry_info.rho,exception);
2902 if (LocaleCompare(
"statistic",option+1) == 0)
2907 (void) SyncImageSettings(mogrify_info,*image,exception);
2908 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2909 MagickFalse,argv[i+1]);
2910 (void) ParseGeometry(argv[i+2],&geometry_info);
2911 mogrify_image=StatisticImage(*image,type,(
size_t) geometry_info.rho,
2912 (
size_t) geometry_info.sigma,exception);
2915 if (LocaleCompare(
"stretch",option+1) == 0)
2919 draw_info->stretch=UndefinedStretch;
2922 draw_info->stretch=(StretchType) ParseCommandOption(
2923 MagickStretchOptions,MagickFalse,argv[i+1]);
2926 if (LocaleCompare(
"strip",option+1) == 0)
2931 (void) SyncImageSettings(mogrify_info,*image,exception);
2932 (void) StripImage(*image,exception);
2935 if (LocaleCompare(
"stroke",option+1) == 0)
2945 (void) QueryColorCompliance(
"none",AllCompliance,
2946 &draw_info->stroke,exception);
2947 if (draw_info->stroke_pattern != (Image *) NULL)
2948 draw_info->stroke_pattern=DestroyImage(
2949 draw_info->stroke_pattern);
2952 sans=AcquireExceptionInfo();
2953 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2954 sans=DestroyExceptionInfo(sans);
2955 if (status == MagickFalse)
2956 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2959 draw_info->stroke=color;
2962 if (LocaleCompare(
"strokewidth",option+1) == 0)
2964 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
2967 if (LocaleCompare(
"style",option+1) == 0)
2971 draw_info->style=UndefinedStyle;
2974 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2975 MagickFalse,argv[i+1]);
2978 if (LocaleCompare(
"swirl",option+1) == 0)
2983 (void) SyncImageSettings(mogrify_info,*image,exception);
2984 (void) ParseGeometry(argv[i+1],&geometry_info);
2985 mogrify_image=SwirlImage(*image,geometry_info.rho,
2986 interpolate_method,exception);
2993 if (LocaleCompare(
"threshold",option+1) == 0)
3001 (void) SyncImageSettings(mogrify_info,*image,exception);
3003 threshold=(double) QuantumRange/2;
3005 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
3007 (void) BilevelImage(*image,threshold,exception);
3010 if (LocaleCompare(
"thumbnail",option+1) == 0)
3015 (void) SyncImageSettings(mogrify_info,*image,exception);
3016 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3017 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3021 if (LocaleCompare(
"tile",option+1) == 0)
3025 if (draw_info->fill_pattern != (Image *) NULL)
3026 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3029 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3033 if (LocaleCompare(
"tint",option+1) == 0)
3038 (void) SyncImageSettings(mogrify_info,*image,exception);
3039 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3042 if (LocaleCompare(
"transform",option+1) == 0)
3047 (void) SyncImageSettings(mogrify_info,*image,exception);
3048 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3052 if (LocaleCompare(
"transparent",option+1) == 0)
3057 (void) SyncImageSettings(mogrify_info,*image,exception);
3058 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3060 (void) TransparentPaintImage(*image,&target,(Quantum)
3061 TransparentAlpha,*option ==
'-' ? MagickFalse : MagickTrue,
3065 if (LocaleCompare(
"transpose",option+1) == 0)
3070 (void) SyncImageSettings(mogrify_info,*image,exception);
3071 mogrify_image=TransposeImage(*image,exception);
3074 if (LocaleCompare(
"transverse",option+1) == 0)
3079 (void) SyncImageSettings(mogrify_info,*image,exception);
3080 mogrify_image=TransverseImage(*image,exception);
3083 if (LocaleCompare(
"treedepth",option+1) == 0)
3085 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3088 if (LocaleCompare(
"trim",option+1) == 0)
3093 (void) SyncImageSettings(mogrify_info,*image,exception);
3094 mogrify_image=TrimImage(*image,exception);
3097 if (LocaleCompare(
"type",option+1) == 0)
3102 (void) SyncImageSettings(mogrify_info,*image,exception);
3106 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3108 (*image)->type=UndefinedType;
3109 (void) SetImageType(*image,type,exception);
3116 if (LocaleCompare(
"undercolor",option+1) == 0)
3118 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3119 &draw_info->undercolor,exception);
3122 if (LocaleCompare(
"unique",option+1) == 0)
3126 (void) DeleteImageArtifact(*image,
"identify:unique-colors");
3129 (void) SetImageArtifact(*image,
"identify:unique-colors",
"true");
3130 (void) SetImageArtifact(*image,
"verbose",
"true");
3133 if (LocaleCompare(
"unique-colors",option+1) == 0)
3138 (void) SyncImageSettings(mogrify_info,*image,exception);
3139 mogrify_image=UniqueImageColors(*image,exception);
3142 if (LocaleCompare(
"unsharp",option+1) == 0)
3147 (void) SyncImageSettings(mogrify_info,*image,exception);
3148 flags=ParseGeometry(argv[i+1],&geometry_info);
3149 if ((flags & SigmaValue) == 0)
3150 geometry_info.sigma=1.0;
3151 if ((flags & XiValue) == 0)
3152 geometry_info.xi=1.0;
3153 if ((flags & PsiValue) == 0)
3154 geometry_info.psi=0.05;
3155 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3156 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3164 if (LocaleCompare(
"verbose",option+1) == 0)
3166 (void) SetImageArtifact(*image,option+1,
3167 *option ==
'+' ?
"false" :
"true");
3170 if (LocaleCompare(
"vignette",option+1) == 0)
3175 (void) SyncImageSettings(mogrify_info,*image,exception);
3176 flags=ParseGeometry(argv[i+1],&geometry_info);
3177 if ((flags & SigmaValue) == 0)
3178 geometry_info.sigma=1.0;
3179 if ((flags & XiValue) == 0)
3180 geometry_info.xi=0.1*(*image)->columns;
3181 if ((flags & PsiValue) == 0)
3182 geometry_info.psi=0.1*(*image)->rows;
3183 if ((flags & PercentValue) != 0)
3185 geometry_info.xi*=(double) (*image)->columns/100.0;
3186 geometry_info.psi*=(double) (*image)->rows/100.0;
3188 mogrify_image=VignetteImage(*image,geometry_info.rho,
3189 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3190 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3193 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
3197 (void) SetImageVirtualPixelMethod(*image,
3198 UndefinedVirtualPixelMethod,exception);
3201 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3202 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3203 argv[i+1]),exception);
3210 if (LocaleCompare(
"wave",option+1) == 0)
3215 (void) SyncImageSettings(mogrify_info,*image,exception);
3216 flags=ParseGeometry(argv[i+1],&geometry_info);
3217 if ((flags & SigmaValue) == 0)
3218 geometry_info.sigma=1.0;
3219 mogrify_image=WaveImage(*image,geometry_info.rho,
3220 geometry_info.sigma,interpolate_method,exception);
3223 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3228 (void) SyncImageSettings(mogrify_info,*image,exception);
3229 flags=ParseGeometry(argv[i+1],&geometry_info);
3230 if ((flags & PercentValue) != 0)
3232 geometry_info.rho=(double) QuantumRange*geometry_info.rho/100.0;
3233 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3236 if ((flags & SigmaValue) == 0)
3237 geometry_info.sigma=0.0;
3238 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3239 geometry_info.sigma,exception);
3242 if (LocaleCompare(
"weight",option+1) == 0)
3247 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3250 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3251 draw_info->weight=(size_t) weight;
3254 if (LocaleCompare(
"white-balance",option+1) == 0)
3259 (void) SyncImageSettings(mogrify_info,*image,exception);
3260 (void) WhiteBalanceImage(*image,exception);
3263 if (LocaleCompare(
"white-threshold",option+1) == 0)
3268 (void) SyncImageSettings(mogrify_info,*image,exception);
3269 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3272 if (LocaleCompare(
"write-mask",option+1) == 0)
3277 (void) SyncImageSettings(mogrify_info,*image,exception);
3283 (void) SetImageMask(*image,WritePixelMask,(
const Image *) NULL,
3290 mask=GetImageCache(mogrify_info,argv[i+1],exception);
3291 if (mask == (Image *) NULL)
3293 (void) SetImageMask(*image,WritePixelMask,mask,exception);
3294 mask=DestroyImage(mask);
3297 if (LocaleCompare(
"word-break",option+1) == 0)
3299 (void) SetImageOption(image_info,option+1,argv[i+1]);
3310 if (mogrify_image != (Image *) NULL)
3311 ReplaceImageInListReturnLast(image,mogrify_image);
3317 quantize_info=DestroyQuantizeInfo(quantize_info);
3318 draw_info=DestroyDrawInfo(draw_info);
3319 mogrify_info=DestroyImageInfo(mogrify_info);
3320 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3321 return(status == 0 ? MagickFalse : MagickTrue);
3358static MagickBooleanType MogrifyUsage(
void)
3361 channel_operators[] =
3362 " -channel-fx expression\n"
3363 " exchange, extract, or transfer one or more image channels\n"
3364 " -separate separate an image channel into a grayscale image",
3366 " -debug events display copious debugging information\n"
3367 " -distribute-cache port\n"
3368 " distributed pixel cache spanning one or more servers\n"
3369 " -help print program options\n"
3370 " -list type print a list of supported option arguments\n"
3371 " -log format format of debugging information\n"
3372 " -version print version information",
3374 " -adaptive-blur geometry\n"
3375 " adaptively blur pixels; decrease effect near edges\n"
3376 " -adaptive-resize geometry\n"
3377 " adaptively resize image using 'mesh' interpolation\n"
3378 " -adaptive-sharpen geometry\n"
3379 " adaptively sharpen pixels; increase effect near edges\n"
3380 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3381 " transparent, extract, background, or shape\n"
3382 " -annotate geometry text\n"
3383 " annotate the image with text\n"
3384 " -auto-gamma automagically adjust gamma level of image\n"
3385 " -auto-level automagically adjust color levels of image\n"
3386 " -auto-orient automagically orient (rotate) image\n"
3387 " -auto-threshold method\n"
3388 " automatically perform image thresholding\n"
3389 " -bench iterations measure performance\n"
3390 " -bilateral-blur geometry\n"
3391 " non-linear, edge-preserving, and noise-reducing smoothing filter\n"
3392 " -black-threshold value\n"
3393 " force all pixels below the threshold into black\n"
3394 " -blue-shift simulate a scene at nighttime in the moonlight\n"
3395 " -blur geometry reduce image noise and reduce detail levels\n"
3396 " -border geometry surround image with a border of color\n"
3397 " -bordercolor color border color\n"
3398 " -brightness-contrast geometry\n"
3399 " improve brightness / contrast of the image\n"
3400 " -canny geometry detect edges in the image\n"
3401 " -cdl filename color correct with a color decision list\n"
3402 " -channel mask set the image channel mask\n"
3403 " -charcoal geometry simulate a charcoal drawing\n"
3404 " -chop geometry remove pixels from the image interior\n"
3405 " -clahe geometry contrast limited adaptive histogram equalization\n"
3406 " -clamp keep pixel values in range (0-QuantumRange)\n"
3407 " -clip clip along the first path from the 8BIM profile\n"
3408 " -clip-mask filename associate a clip mask with the image\n"
3409 " -clip-path id clip along a named path from the 8BIM profile\n"
3410 " -colorize value colorize the image with the fill color\n"
3411 " -color-matrix matrix apply color correction to the image\n"
3412 " -colors value preferred number of colors in the image\n"
3413 " -color-threshold start_color-stop_color\n"
3414 " force all pixels in the color range to white otherwise black\n"
3415 " -connected-components connectivity\n"
3416 " connected-components uniquely labeled\n"
3417 " -contrast enhance or reduce the image contrast\n"
3418 " -contrast-stretch geometry\n"
3419 " improve contrast by 'stretching' the intensity range\n"
3420 " -convolve coefficients\n"
3421 " apply a convolution kernel to the image\n"
3422 " -cycle amount cycle the image colormap\n"
3423 " -decipher filename convert cipher pixels to plain pixels\n"
3424 " -deskew threshold straighten an image\n"
3425 " -despeckle reduce the speckles within an image\n"
3426 " -distort method args\n"
3427 " distort images according to given method ad args\n"
3428 " -draw string annotate the image with a graphic primitive\n"
3429 " -edge radius apply a filter to detect edges in the image\n"
3430 " -encipher filename convert plain pixels to cipher pixels\n"
3431 " -emboss radius emboss an image\n"
3432 " -enhance apply a digital filter to enhance a noisy image\n"
3433 " -equalize perform histogram equalization to an image\n"
3434 " -evaluate operator value\n"
3435 " evaluate an arithmetic, relational, or logical expression\n"
3436 " -extent geometry set the image size\n"
3437 " -extract geometry extract area from image\n"
3438 " -fft implements the discrete Fourier transform (DFT)\n"
3439 " -flip flip image vertically\n"
3440 " -floodfill geometry color\n"
3441 " floodfill the image with color\n"
3442 " -flop flop image horizontally\n"
3443 " -frame geometry surround image with an ornamental border\n"
3444 " -function name parameters\n"
3445 " apply function over image values\n"
3446 " -gamma value level of gamma correction\n"
3447 " -gaussian-blur geometry\n"
3448 " reduce image noise and reduce detail levels\n"
3449 " -geometry geometry preferred size or location of the image\n"
3450 " -grayscale method convert image to grayscale\n"
3451 " -hough-lines geometry\n"
3452 " identify lines in the image\n"
3453 " -identify identify the format and characteristics of the image\n"
3454 " -ift implements the inverse discrete Fourier transform (DFT)\n"
3455 " -implode amount implode image pixels about the center\n"
3456 " -integral calculate the sum of values (pixel values) in the image\n"
3457 " -interpolative-resize geometry\n"
3458 " resize image using interpolation\n"
3459 " -kmeans geometry K means color reduction\n"
3460 " -kuwahara geometry edge preserving noise reduction filter\n"
3461 " -lat geometry local adaptive thresholding\n"
3462 " -level value adjust the level of image contrast\n"
3463 " -level-colors color,color\n"
3464 " level image with the given colors\n"
3465 " -linear-stretch geometry\n"
3466 " improve contrast by 'stretching with saturation'\n"
3467 " -liquid-rescale geometry\n"
3468 " rescale image with seam-carving\n"
3469 " -local-contrast geometry\n"
3470 " enhance local contrast\n"
3471 " -magnify double the size of the image with pixel art scaling\n"
3472 " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3473 " -median geometry apply a median filter to the image\n"
3474 " -mode geometry make each pixel the 'predominant color' of the\n"
3476 " -modulate value vary the brightness, saturation, and hue\n"
3477 " -monochrome transform image to black and white\n"
3478 " -morphology method kernel\n"
3479 " apply a morphology method to the image\n"
3480 " -motion-blur geometry\n"
3481 " simulate motion blur\n"
3482 " -negate replace every pixel with its complementary color \n"
3483 " -noise geometry add or reduce noise in an image\n"
3484 " -normalize transform image to span the full range of colors\n"
3485 " -opaque color change this color to the fill color\n"
3486 " -ordered-dither NxN\n"
3487 " add a noise pattern to the image with specific\n"
3489 " -paint radius simulate an oil painting\n"
3490 " -perceptible epsilon\n"
3491 " pixel value less than |epsilon| become epsilon or\n"
3493 " -polaroid angle simulate a Polaroid picture\n"
3494 " -posterize levels reduce the image to a limited number of color levels\n"
3495 " -profile filename add, delete, or apply an image profile\n"
3496 " -quantize colorspace reduce colors in this colorspace\n"
3497 " -raise value lighten/darken image edges to create a 3-D effect\n"
3498 " -random-threshold low,high\n"
3499 " random threshold the image\n"
3500 " -range-threshold values\n"
3501 " perform either hard or soft thresholding within some range of values in an image\n"
3502 " -region geometry apply options to a portion of the image\n"
3503 " -render render vector graphics\n"
3504 " -repage geometry size and location of an image canvas\n"
3505 " -resample geometry change the resolution of an image\n"
3506 " -reshape geometry reshape the image\n"
3507 " -resize geometry resize the image\n"
3508 " -roll geometry roll an image vertically or horizontally\n"
3509 " -rotate degrees apply Paeth rotation to the image\n"
3510 " -rotational-blur angle\n"
3511 " rotational blur the image\n"
3512 " -sample geometry scale image with pixel sampling\n"
3513 " -scale geometry scale the image\n"
3514 " -segment values segment an image\n"
3515 " -selective-blur geometry\n"
3516 " selectively blur pixels within a contrast threshold\n"
3517 " -sepia-tone threshold\n"
3518 " simulate a sepia-toned photo\n"
3519 " -set property value set an image property\n"
3520 " -shade degrees shade the image using a distant light source\n"
3521 " -shadow geometry simulate an image shadow\n"
3522 " -sharpen geometry sharpen the image\n"
3523 " -shave geometry shave pixels from the image edges\n"
3524 " -shear geometry slide one edge of the image along the X or Y axis\n"
3525 " -sigmoidal-contrast geometry\n"
3526 " increase the contrast without saturating highlights or\n"
3528 " -sketch geometry simulate a pencil sketch\n"
3529 " -solarize threshold negate all pixels above the threshold level\n"
3530 " -sort-pixels sort each scanline in ascending order of intensity\n"
3531 " -sparse-color method args\n"
3532 " fill in a image based on a few color points\n"
3533 " -splice geometry splice the background color into the image\n"
3534 " -spread radius displace image pixels by a random amount\n"
3535 " -statistic type radius\n"
3536 " replace each pixel with corresponding statistic from the neighborhood\n"
3537 " -strip strip image of all profiles and comments\n"
3538 " -swirl degrees swirl image pixels about the center\n"
3539 " -threshold value threshold the image\n"
3540 " -thumbnail geometry create a thumbnail of the image\n"
3541 " -tile filename tile image when filling a graphic primitive\n"
3542 " -tint value tint the image with the fill color\n"
3543 " -transform affine transform image\n"
3544 " -transparent color make this color transparent within the image\n"
3545 " -transpose flip image vertically and rotate 90 degrees\n"
3546 " -transverse flop image horizontally and rotate 270 degrees\n"
3547 " -trim trim image edges\n"
3548 " -type type image type\n"
3549 " -unique-colors discard all but one of any pixel color\n"
3550 " -unsharp geometry sharpen the image\n"
3551 " -vignette geometry soften the edges of the image in vignette style\n"
3552 " -wave geometry alter an image along a sine wave\n"
3553 " -wavelet-denoise threshold\n"
3554 " removes noise from the image using a wavelet transform\n"
3555 " -white-balance automagically adjust white balance of image\n"
3556 " -white-threshold value\n"
3557 " force all pixels above the threshold into white",
3558 sequence_operators[] =
3559 " -affinity filename transform image colors to match this set of colors\n"
3560 " -append append an image sequence\n"
3561 " -clut apply a color lookup table to the image\n"
3562 " -coalesce merge a sequence of images\n"
3563 " -combine combine a sequence of images\n"
3564 " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3565 " -complex operator perform complex mathematics on an image sequence\n"
3566 " -composite composite image\n"
3567 " -copy geometry offset\n"
3568 " copy pixels from one area of an image to another\n"
3569 " -crop geometry cut out a rectangular region of the image\n"
3570 " -deconstruct break down an image sequence into constituent parts\n"
3571 " -evaluate-sequence operator\n"
3572 " evaluate an arithmetic, relational, or logical expression\n"
3573 " -flatten flatten a sequence of images\n"
3574 " -fx expression apply mathematical expression to an image channel(s)\n"
3575 " -hald-clut apply a Hald color lookup table to the image\n"
3576 " -layers method optimize, merge, or compare image layers\n"
3577 " -morph value morph an image sequence\n"
3578 " -mosaic create a mosaic from an image sequence\n"
3579 " -poly terms build a polynomial from the image sequence and the corresponding\n"
3580 " terms (coefficients and degree pairs).\n"
3581 " -print string interpret string and print to console\n"
3582 " -process arguments process the image with a custom image filter\n"
3583 " -smush geometry smush an image sequence together\n"
3584 " -write filename write images to this file",
3586 " -adjoin join images into a single multi-image file\n"
3587 " -affine matrix affine transform matrix\n"
3588 " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3589 " -antialias remove pixel-aliasing\n"
3590 " -authenticate password\n"
3591 " decipher image with this password\n"
3592 " -attenuate value lessen (or intensify) when adding noise to an image\n"
3593 " -background color background color\n"
3594 " -bias value add bias when convolving an image\n"
3595 " -black-point-compensation\n"
3596 " use black point compensation\n"
3597 " -blue-primary point chromaticity blue primary point\n"
3598 " -bordercolor color border color\n"
3599 " -caption string assign a caption to an image\n"
3600 " -colorspace type alternate image colorspace\n"
3601 " -comment string annotate image with comment\n"
3602 " -compose operator set image composite operator\n"
3603 " -compress type type of pixel compression when writing the image\n"
3604 " -define format:option=value\n"
3605 " define one or more image format options\n"
3606 " -delay value display the next image after pausing\n"
3607 " -density geometry horizontal and vertical density of the image\n"
3608 " -depth value image depth\n"
3609 " -direction type render text right-to-left or left-to-right\n"
3610 " -display server get image or font from this X server\n"
3611 " -dispose method layer disposal method\n"
3612 " -dither method apply error diffusion to image\n"
3613 " -encoding type text encoding type\n"
3614 " -endian type endianness (MSB or LSB) of the image\n"
3615 " -family name render text with this font family\n"
3616 " -features distance analyze image features (e.g. contrast, correlation)\n"
3617 " -fill color color to use when filling a graphic primitive\n"
3618 " -filter type use this filter when resizing an image\n"
3619 " -font name render text with this font\n"
3620 " -format \"string\" output formatted image characteristics\n"
3621 " -fuzz distance colors within this distance are considered equal\n"
3622 " -gravity type horizontal and vertical text placement\n"
3623 " -green-primary point chromaticity green primary point\n"
3624 " -illuminant type reference illuminant\n"
3625 " -intensity method method to generate an intensity value from a pixel\n"
3626 " -intent type type of rendering intent when managing the image color\n"
3627 " -interlace type type of image interlacing scheme\n"
3628 " -interline-spacing value\n"
3629 " set the space between two text lines\n"
3630 " -interpolate method pixel color interpolation method\n"
3631 " -interword-spacing value\n"
3632 " set the space between two words\n"
3633 " -kerning value set the space between two letters\n"
3634 " -label string assign a label to an image\n"
3635 " -limit type value pixel cache resource limit\n"
3636 " -loop iterations add Netscape loop extension to your GIF animation\n"
3637 " -matte store matte channel if the image has one\n"
3638 " -mattecolor color frame color\n"
3639 " -monitor monitor progress\n"
3640 " -orient type image orientation\n"
3641 " -page geometry size and location of an image canvas (setting)\n"
3642 " -path path write images to this path on disk\n"
3643 " -ping efficiently determine image attributes\n"
3644 " -pointsize value font point size\n"
3645 " -precision value maximum number of significant digits to print\n"
3646 " -preview type image preview type\n"
3647 " -quality value JPEG/MIFF/PNG compression level\n"
3648 " -quiet suppress all warning messages\n"
3649 " -read-mask filename associate a read mask with the image\n"
3650 " -red-primary point chromaticity red primary point\n"
3651 " -regard-warnings pay attention to warning messages\n"
3652 " -remap filename transform image colors to match this set of colors\n"
3653 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3654 " -sampling-factor geometry\n"
3655 " horizontal and vertical sampling factor\n"
3656 " -scene value image scene number\n"
3657 " -seed value seed a new sequence of pseudo-random numbers\n"
3658 " -size geometry width and height of image\n"
3659 " -stretch type render text with this font stretch\n"
3660 " -stroke color graphic primitive stroke color\n"
3661 " -strokewidth value graphic primitive stroke width\n"
3662 " -style type render text with this font style\n"
3663 " -synchronize synchronize image to storage device\n"
3664 " -taint declare the image as modified\n"
3665 " -texture filename name of texture to tile onto the image background\n"
3666 " -tile-offset geometry\n"
3668 " -treedepth value color tree depth\n"
3669 " -transparent-color color\n"
3670 " transparent color\n"
3671 " -undercolor color annotation bounding box color\n"
3672 " -units type the units of image resolution\n"
3673 " -verbose print detailed information about the image\n"
3674 " -view FlashPix viewing transforms\n"
3675 " -virtual-pixel method\n"
3676 " virtual pixel access method\n"
3677 " -weight type render text with this font weight\n"
3678 " -white-point point chromaticity white point\n"
3679 " -word-break type sets whether line breaks appear wherever the text would otherwise overflow"
3680 " -write-mask filename associate a write mask with the image",
3682 " -delete indexes delete the image from the image sequence\n"
3683 " -duplicate count,indexes\n"
3684 " duplicate an image one or more times\n"
3685 " -insert index insert last image into the image sequence\n"
3686 " -reverse reverse image sequence\n"
3687 " -swap indexes swap two images in the image sequence";
3689 ListMagickVersion(stdout);
3690 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
3692 (void) fprintf(stdout,
"\nImage Settings:\n");
3693 (void) fputs(settings,stdout);
3694 (void) fprintf(stdout,
"\nImage Operators:\n");
3695 (void) fputs(operators,stdout);
3696 (void) fprintf(stdout,
"\nImage Channel Operators:\n");
3697 (void) fputs(channel_operators,stdout);
3698 (void) fprintf(stdout,
"\nImage Sequence Operators:\n");
3699 (void) fputs(sequence_operators,stdout);
3700 (void) fprintf(stdout,
"\nImage Stack Operators:\n");
3701 (void) fputs(stack_operators,stdout);
3702 (void) fprintf(stdout,
"\nMiscellaneous Options:\n");
3703 (void) fputs(miscellaneous,stdout);
3704 (void) fprintf(stdout,
3705 "\nBy default, the image format of 'file' is determined by its magic\n");
3706 (void) fprintf(stdout,
3707 "number. To specify a particular image format, precede the filename\n");
3708 (void) fprintf(stdout,
3709 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3710 (void) fprintf(stdout,
3711 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3712 (void) fprintf(stdout,
"'-' for standard input or output.\n");
3716WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3717 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
3719#define DestroyMogrify() \
3721 if (format != (char *) NULL) \
3722 format=DestroyString(format); \
3723 if (path != (char *) NULL) \
3724 path=DestroyString(path); \
3725 DestroyImageStack(); \
3726 for (i=0; i < (ssize_t) argc; i++) \
3727 argv[i]=DestroyString(argv[i]); \
3728 argv=(char **) RelinquishMagickMemory(argv); \
3730#define ThrowMogrifyException(asperity,tag,option) \
3732 char *message = GetExceptionMessage(errno); \
3733 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \
3734 "`%s'",option == (char *) NULL ? message : option); \
3735 message=DestroyString(message); \
3737 return(MagickFalse); \
3739#define ThrowMogrifyInvalidArgumentException(option,argument) \
3741 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3742 "InvalidArgument","'%s': %s",argument,option); \
3744 return(MagickFalse); \
3756 image_stack[MaxImageStackDepth+1];
3764 respect_parentheses;
3776 wand_unreferenced(metadata);
3781 assert(image_info != (ImageInfo *) NULL);
3782 assert(image_info->signature == MagickCoreSignature);
3783 if (IsEventLogging() != MagickFalse)
3784 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3785 assert(exception != (ExceptionInfo *) NULL);
3789 if ((LocaleCompare(
"version",option+1) == 0) ||
3790 (LocaleCompare(
"-version",option+1) == 0))
3792 ListMagickVersion(stdout);
3798 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3799 "MissingArgument",
"%s",
"");
3800 (void) MogrifyUsage();
3801 return(MagickFalse);
3803 format=(
char *) NULL;
3805 global_colormap=MagickFalse;
3809 option=(
char *) NULL;
3811 respect_parentheses=MagickFalse;
3816 ReadCommandlLine(argc,&argv);
3817 status=ExpandFilenames(&argc,&argv);
3818 if (status == MagickFalse)
3819 ThrowMogrifyException(ResourceLimitError,
"MemoryAllocationFailed",
3821 for (i=1; i < (ssize_t) argc; i++)
3824 if (LocaleCompare(option,
"(") == 0)
3826 FireImageStack(MagickFalse,MagickTrue,pend);
3827 if (k == MaxImageStackDepth)
3828 ThrowMogrifyException(OptionError,
"ParenthesisNestedTooDeeply",
3833 if (LocaleCompare(option,
")") == 0)
3835 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3837 ThrowMogrifyException(OptionError,
"UnableToParseExpression",option);
3841 if (IsCommandOption(option) == MagickFalse)
3844 backup_filename[MagickPathExtent],
3846 magic[MagickPathExtent];
3857 FireImageStack(MagickFalse,MagickFalse,pend);
3859 if ((LocaleCompare(filename,
"--") == 0) && (i < ((ssize_t) argc-1)))
3861 images=ReadImages(image_info,filename,exception);
3862 status&=(MagickStatusType) (images != (Image *) NULL) &&
3863 (exception->severity < ErrorException);
3864 if (images == (Image *) NULL)
3866 properties=(*GetBlobProperties(images));
3867 if (format != (
char *) NULL)
3868 GetPathComponent(images->magick_filename,
3869 BasePathSansCompressExtension,images->filename);
3870 if (path != (
char *) NULL)
3872 GetPathComponent(option,TailPath,filename);
3873 (void) FormatLocaleString(images->filename,MagickPathExtent,
3874 "%s%c%s",path,*DirectorySeparator,filename);
3876 if (format != (
char *) NULL)
3877 AppendImageFormat(format,images->filename);
3878 AppendImageStack(images);
3879 FinalizeImageSettings(image_info,image,MagickFalse);
3880 if (image == (Image *) NULL)
3882 if (global_colormap != MagickFalse)
3887 quantize_info=AcquireQuantizeInfo(image_info);
3888 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3889 quantize_info=DestroyQuantizeInfo(quantize_info);
3891 *backup_filename=
'\0';
3893 GetPathComponent(filename,MagickPath,magic);
3897 name[MagickPathExtent];
3899 if (format != (
char *) NULL)
3900 (void) CopyMagickString(magic,format,MagickPathExtent);
3901 (void) FormatLocaleString(name,MagickPathExtent,
"%s:%s",magic,
3903 (void) CopyMagickString(image->filename,name,MagickPathExtent);
3905 if ((LocaleCompare(image->filename,
"-") != 0) &&
3906 (IsPathWritable(image->filename) != MagickFalse))
3917 random_info=AcquireRandomInfo();
3918 (void) CopyMagickString(backup_filename,image->filename,
3920 for (j=0; j < TMP_MAX; j++)
3928 key_info=GetRandomKey(random_info,4);
3929 if (key_info == (StringInfo *) NULL)
3931 key_bytes=GetStringInfoDatum(key_info);
3932 (void) FormatLocaleString(backup_filename,MagickPathExtent,
3933 "%s-%02x%02x%02x%02x~",image->filename,key_bytes[0],
3934 key_bytes[1],key_bytes[2],key_bytes[3]);
3935 key_info=DestroyStringInfo(key_info);
3936 file=open_utf8(backup_filename,O_RDWR | O_CLOEXEC | O_CREAT | O_EXCL |
3937 O_BINARY | O_NOFOLLOW,S_MODE);
3938 if ((file >= 0) || (errno != EEXIST))
3941 random_info=DestroyRandomInfo(random_info);
3943 *backup_filename=
'\0';
3945 file=close_utf8(file)-1;
3950 image_info->synchronize=MagickTrue;
3952 Image *clone_image = CloneImageList(image,exception);
3953 if (clone_image != (Image *) NULL)
3956 output_filename[MagickPathExtent];
3961 if (*clone_image->magick ==
'\0')
3962 (void) CopyMagickString(clone_image->magick,image_info->magick,
3964 output_format=(format != (
char *) NULL) ? format :
3965 clone_image->magick;
3966 if ((*magic !=
'\0') || (*output_format ==
'\0'))
3967 (void) CopyMagickString(output_filename,backup_filename,
3970 (
void) FormatLocaleString(output_filename,MagickPathExtent,
3971 "%s:%s",output_format,backup_filename);
3972 status&=(MagickStatusType) WriteImages(image_info,clone_image,
3973 (*backup_filename !=
'\0') ? output_filename :
3974 clone_image->filename,exception);
3975 clone_image=DestroyImageList(clone_image);
3978 if (status != MagickFalse)
3984 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3985 "preserve-timestamp"));
3986 if (preserve_timestamp != MagickFalse)
3987 (void) set_file_timestamp(image->filename,&properties);
3989 if (*backup_filename !=
'\0')
3991 if (rename_utf8(backup_filename,image->filename) != 0)
3996 if (*backup_filename !=
'\0')
3997 (void) remove_utf8(backup_filename);
3998 RemoveAllImageStack();
4001 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4002 switch (*(option+1))
4006 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
4009 if (i == (ssize_t) argc)
4010 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4011 if (IsGeometry(argv[i]) == MagickFalse)
4012 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4015 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
4018 if (i == (ssize_t) argc)
4019 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4020 if (IsGeometry(argv[i]) == MagickFalse)
4021 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4024 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
4027 if (i == (ssize_t) argc)
4028 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4029 if (IsGeometry(argv[i]) == MagickFalse)
4030 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4033 if (LocaleCompare(
"affine",option+1) == 0)
4038 if (i == (ssize_t) argc)
4039 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4042 if (LocaleCompare(
"alpha",option+1) == 0)
4050 if (i == (ssize_t) argc)
4051 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4052 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
4055 ThrowMogrifyException(OptionError,
4056 "UnrecognizedAlphaChannelOption",argv[i]);
4059 if (LocaleCompare(
"annotate",option+1) == 0)
4064 if (i == (ssize_t) argc)
4065 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4066 if (IsGeometry(argv[i]) == MagickFalse)
4067 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4068 if (i == (ssize_t) argc)
4069 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4073 if (LocaleCompare(
"antialias",option+1) == 0)
4075 if (LocaleCompare(
"append",option+1) == 0)
4077 if (LocaleCompare(
"attenuate",option+1) == 0)
4082 if (i == (ssize_t) argc)
4083 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4084 if (IsGeometry(argv[i]) == MagickFalse)
4085 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4088 if (LocaleCompare(
"authenticate",option+1) == 0)
4093 if (i == (ssize_t) argc)
4094 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4097 if (LocaleCompare(
"auto-gamma",option+1) == 0)
4099 if (LocaleCompare(
"auto-level",option+1) == 0)
4101 if (LocaleCompare(
"auto-orient",option+1) == 0)
4103 if (LocaleCompare(
"auto-threshold",option+1) == 0)
4111 if (i == (ssize_t) argc)
4112 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4113 method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
4116 ThrowMogrifyException(OptionError,
"UnrecognizedThresholdMethod",
4120 if (LocaleCompare(
"average",option+1) == 0)
4122 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4126 if (LocaleCompare(
"background",option+1) == 0)
4131 if (i == (ssize_t) argc)
4132 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4135 if (LocaleCompare(
"bias",option+1) == 0)
4140 if (i == (ssize_t) argc)
4141 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4142 if (IsGeometry(argv[i]) == MagickFalse)
4143 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4146 if (LocaleCompare(
"bilateral-blur",option+1) == 0)
4151 if (i == (ssize_t) argc)
4152 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4153 if (IsGeometry(argv[i]) == MagickFalse)
4154 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4157 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
4159 if (LocaleCompare(
"black-threshold",option+1) == 0)
4164 if (i == (ssize_t) argc)
4165 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4166 if (IsGeometry(argv[i]) == MagickFalse)
4167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4170 if (LocaleCompare(
"blue-primary",option+1) == 0)
4175 if (i == (ssize_t) argc)
4176 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4177 if (IsGeometry(argv[i]) == MagickFalse)
4178 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4181 if (LocaleCompare(
"blue-shift",option+1) == 0)
4184 if (i == (ssize_t) argc)
4185 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4186 if (IsGeometry(argv[i]) == MagickFalse)
4187 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4190 if (LocaleCompare(
"blur",option+1) == 0)
4193 if (i == (ssize_t) argc)
4194 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4195 if (IsGeometry(argv[i]) == MagickFalse)
4196 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4199 if (LocaleCompare(
"border",option+1) == 0)
4204 if (i == (ssize_t) argc)
4205 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4206 if (IsGeometry(argv[i]) == MagickFalse)
4207 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4210 if (LocaleCompare(
"bordercolor",option+1) == 0)
4215 if (i == (ssize_t) argc)
4216 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4219 if (LocaleCompare(
"box",option+1) == 0)
4224 if (i == (ssize_t) argc)
4225 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4228 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
4231 if (i == (ssize_t) argc)
4232 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4233 if (IsGeometry(argv[i]) == MagickFalse)
4234 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4237 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4241 if (LocaleCompare(
"cache",option+1) == 0)
4246 if (i == (ssize_t) argc)
4247 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4248 if (IsGeometry(argv[i]) == MagickFalse)
4249 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4252 if (LocaleCompare(
"canny",option+1) == 0)
4257 if (i == (ssize_t) argc)
4258 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4259 if (IsGeometry(argv[i]) == MagickFalse)
4260 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4263 if (LocaleCompare(
"caption",option+1) == 0)
4268 if (i == (ssize_t) argc)
4269 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4272 if (LocaleCompare(
"channel",option+1) == 0)
4280 if (i == (ssize_t) argc)
4281 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4282 channel=ParseChannelOption(argv[i]);
4284 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4288 if (LocaleCompare(
"channel-fx",option+1) == 0)
4296 if (i == (ssize_t) argc)
4297 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4298 channel=ParsePixelChannelOption(argv[i]);
4300 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4304 if (LocaleCompare(
"cdl",option+1) == 0)
4309 if (i == (ssize_t) argc)
4310 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4313 if (LocaleCompare(
"charcoal",option+1) == 0)
4318 if (i == (ssize_t) argc)
4319 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4320 if (IsGeometry(argv[i]) == MagickFalse)
4321 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4324 if (LocaleCompare(
"chop",option+1) == 0)
4329 if (i == (ssize_t) argc)
4330 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4331 if (IsGeometry(argv[i]) == MagickFalse)
4332 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4335 if (LocaleCompare(
"clahe",option+1) == 0)
4340 if (i == (ssize_t) argc)
4341 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4342 if (IsGeometry(argv[i]) == MagickFalse)
4343 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4346 if (LocaleCompare(
"clamp",option+1) == 0)
4348 if (LocaleCompare(
"clip",option+1) == 0)
4350 if (LocaleCompare(
"clip-mask",option+1) == 0)
4355 if (i == (ssize_t) argc)
4356 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4359 if (LocaleCompare(
"clut",option+1) == 0)
4361 if (LocaleCompare(
"coalesce",option+1) == 0)
4363 if (LocaleCompare(
"colorize",option+1) == 0)
4368 if (i == (ssize_t) argc)
4369 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4370 if (IsGeometry(argv[i]) == MagickFalse)
4371 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4374 if (LocaleCompare(
"color-matrix",option+1) == 0)
4382 if (i == (ssize_t) argc)
4383 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4384 kernel_info=AcquireKernelInfo(argv[i],exception);
4385 if (kernel_info == (KernelInfo *) NULL)
4386 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4387 kernel_info=DestroyKernelInfo(kernel_info);
4390 if (LocaleCompare(
"colors",option+1) == 0)
4395 if (i == (ssize_t) argc)
4396 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4397 if (IsGeometry(argv[i]) == MagickFalse)
4398 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4401 if (LocaleCompare(
"colorspace",option+1) == 0)
4409 if (i == (ssize_t) argc)
4410 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4411 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4414 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4418 if (LocaleCompare(
"color-threshold",option+1) == 0)
4423 if (i == (ssize_t) argc)
4424 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4427 if (LocaleCompare(
"combine",option+1) == 0)
4435 if (i == (ssize_t) argc)
4436 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4437 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4440 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4444 if (LocaleCompare(
"comment",option+1) == 0)
4449 if (i == (ssize_t) argc)
4450 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4453 if (LocaleCompare(
"compare",option+1) == 0)
4455 if (LocaleCompare(
"compose",option+1) == 0)
4463 if (i == (ssize_t) argc)
4464 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4465 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4468 ThrowMogrifyException(OptionError,
"UnrecognizedComposeOperator",
4472 if (LocaleCompare(
"composite",option+1) == 0)
4474 if (LocaleCompare(
"compress",option+1) == 0)
4482 if (i == (ssize_t) argc)
4483 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4484 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4487 ThrowMogrifyException(OptionError,
"UnrecognizedImageCompression",
4491 if (LocaleCompare(
"concurrent",option+1) == 0)
4493 if (LocaleCompare(
"connected-components",option+1) == 0)
4496 if (i == (ssize_t) argc)
4497 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4498 if (IsGeometry(argv[i]) == MagickFalse)
4499 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4502 if (LocaleCompare(
"contrast",option+1) == 0)
4504 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
4507 if (i == (ssize_t) argc)
4508 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4509 if (IsGeometry(argv[i]) == MagickFalse)
4510 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4513 if (LocaleCompare(
"convolve",option+1) == 0)
4521 if (i == (ssize_t) argc)
4522 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4523 kernel_info=AcquireKernelInfo(argv[i],exception);
4524 if (kernel_info == (KernelInfo *) NULL)
4525 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4526 kernel_info=DestroyKernelInfo(kernel_info);
4529 if (LocaleCompare(
"copy",option+1) == 0)
4534 if (i == (ssize_t) argc)
4535 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4536 if (IsGeometry(argv[i]) == MagickFalse)
4537 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4539 if (i == (ssize_t) argc)
4540 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4541 if (IsGeometry(argv[i]) == MagickFalse)
4542 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4545 if (LocaleCompare(
"crop",option+1) == 0)
4550 if (i == (ssize_t) argc)
4551 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4552 if (IsGeometry(argv[i]) == MagickFalse)
4553 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4556 if (LocaleCompare(
"cycle",option+1) == 0)
4561 if (i == (ssize_t) argc)
4562 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4563 if (IsGeometry(argv[i]) == MagickFalse)
4564 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4567 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4571 if (LocaleCompare(
"decipher",option+1) == 0)
4576 if (i == (ssize_t) argc)
4577 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4580 if (LocaleCompare(
"deconstruct",option+1) == 0)
4582 if (LocaleCompare(
"debug",option+1) == 0)
4590 if (i == (ssize_t) argc)
4591 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4592 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4594 ThrowMogrifyException(OptionError,
"UnrecognizedEventType",
4596 (void) SetLogEventMask(argv[i]);
4599 if (LocaleCompare(
"define",option+1) == 0)
4602 if (i == (ssize_t) argc)
4603 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4609 define=GetImageOption(image_info,argv[i]);
4610 if (define == (
const char *) NULL)
4611 ThrowMogrifyException(OptionError,
"NoSuchOption",argv[i]);
4616 if (LocaleCompare(
"delay",option+1) == 0)
4621 if (i == (ssize_t) argc)
4622 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4623 if (IsGeometry(argv[i]) == MagickFalse)
4624 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4627 if (LocaleCompare(
"delete",option+1) == 0)
4632 if (i == (ssize_t) argc)
4633 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4634 if (LocaleNCompare(argv[i],
"registry:",9) == 0)
4636 (void) DeleteImageRegistry(argv[i]+9);
4639 if (IsGeometry(argv[i]) == MagickFalse)
4640 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4643 if (LocaleCompare(
"density",option+1) == 0)
4648 if (i == (ssize_t) argc)
4649 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4650 if (IsGeometry(argv[i]) == MagickFalse)
4651 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4654 if (LocaleCompare(
"depth",option+1) == 0)
4659 if (i == (ssize_t) argc)
4660 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4661 if (IsGeometry(argv[i]) == MagickFalse)
4662 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4665 if (LocaleCompare(
"deskew",option+1) == 0)
4670 if (i == (ssize_t) argc)
4671 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4672 if (IsGeometry(argv[i]) == MagickFalse)
4673 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4676 if (LocaleCompare(
"despeckle",option+1) == 0)
4678 if (LocaleCompare(
"dft",option+1) == 0)
4680 if (LocaleCompare(
"direction",option+1) == 0)
4688 if (i == (ssize_t) argc)
4689 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4690 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4693 ThrowMogrifyException(OptionError,
"UnrecognizedDirectionType",
4697 if (LocaleCompare(
"display",option+1) == 0)
4702 if (i == (ssize_t) argc)
4703 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4706 if (LocaleCompare(
"dispose",option+1) == 0)
4714 if (i == (ssize_t) argc)
4715 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4716 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4719 ThrowMogrifyException(OptionError,
"UnrecognizedDisposeMethod",
4723 if (LocaleCompare(
"distort",option+1) == 0)
4729 if (i == (ssize_t) argc)
4730 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4731 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4733 ThrowMogrifyException(OptionError,
"UnrecognizedDistortMethod",
4736 if (i == (ssize_t) argc)
4737 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4740 if (LocaleCompare(
"dither",option+1) == 0)
4748 if (i == (ssize_t) argc)
4749 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4750 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4752 ThrowMogrifyException(OptionError,
"UnrecognizedDitherMethod",
4756 if (LocaleCompare(
"draw",option+1) == 0)
4761 if (i == (ssize_t) argc)
4762 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4765 if (LocaleCompare(
"duplicate",option+1) == 0)
4770 if (i == (ssize_t) argc)
4771 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4772 if (IsGeometry(argv[i]) == MagickFalse)
4773 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4776 if (LocaleCompare(
"duration",option+1) == 0)
4781 if (i == (ssize_t) argc)
4782 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4783 if (IsGeometry(argv[i]) == MagickFalse)
4784 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4787 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4791 if (LocaleCompare(
"edge",option+1) == 0)
4796 if (i == (ssize_t) argc)
4797 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4798 if (IsGeometry(argv[i]) == MagickFalse)
4799 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4802 if (LocaleCompare(
"emboss",option+1) == 0)
4807 if (i == (ssize_t) argc)
4808 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4809 if (IsGeometry(argv[i]) == MagickFalse)
4810 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4813 if (LocaleCompare(
"encipher",option+1) == 0)
4818 if (i == (ssize_t) argc)
4819 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4822 if (LocaleCompare(
"encoding",option+1) == 0)
4827 if (i == (ssize_t) argc)
4828 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4831 if (LocaleCompare(
"endian",option+1) == 0)
4839 if (i == (ssize_t) argc)
4840 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4841 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4843 ThrowMogrifyException(OptionError,
"UnrecognizedEndianType",
4847 if (LocaleCompare(
"enhance",option+1) == 0)
4849 if (LocaleCompare(
"equalize",option+1) == 0)
4851 if (LocaleCompare(
"evaluate",option+1) == 0)
4859 if (i == (ssize_t) argc)
4860 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4861 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4863 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4866 if (i == (ssize_t) argc)
4867 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4868 if (IsGeometry(argv[i]) == MagickFalse)
4869 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4872 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4880 if (i == (ssize_t) argc)
4881 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4882 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4884 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4888 if (LocaleCompare(
"extent",option+1) == 0)
4893 if (i == (ssize_t) argc)
4894 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4895 if (IsGeometry(argv[i]) == MagickFalse)
4896 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4899 if (LocaleCompare(
"extract",option+1) == 0)
4904 if (i == (ssize_t) argc)
4905 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4906 if (IsGeometry(argv[i]) == MagickFalse)
4907 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4910 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4914 if (LocaleCompare(
"family",option+1) == 0)
4919 if (i == (ssize_t) argc)
4920 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4923 if (LocaleCompare(
"features",option+1) == 0)
4928 if (i == (ssize_t) argc)
4929 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4930 if (IsGeometry(argv[i]) == MagickFalse)
4931 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4934 if (LocaleCompare(
"fill",option+1) == 0)
4939 if (i == (ssize_t) argc)
4940 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4943 if (LocaleCompare(
"filter",option+1) == 0)
4951 if (i == (ssize_t) argc)
4952 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4953 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4955 ThrowMogrifyException(OptionError,
"UnrecognizedImageFilter",
4959 if (LocaleCompare(
"flatten",option+1) == 0)
4961 if (LocaleCompare(
"flip",option+1) == 0)
4963 if (LocaleCompare(
"flop",option+1) == 0)
4965 if (LocaleCompare(
"floodfill",option+1) == 0)
4970 if (i == (ssize_t) argc)
4971 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4972 if (IsGeometry(argv[i]) == MagickFalse)
4973 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4975 if (i == (ssize_t) argc)
4976 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4979 if (LocaleCompare(
"font",option+1) == 0)
4984 if (i == (ssize_t) argc)
4985 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4988 if (LocaleCompare(
"format",option+1) == 0)
4990 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
4991 (void) CloneString(&format,(
char *) NULL);
4995 if (i == (ssize_t) argc)
4996 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4997 (void) CloneString(&format,argv[i]);
4998 (void) CopyMagickString(image_info->filename,format,
5000 (void) ConcatenateMagickString(image_info->filename,
":",
5002 (void) SetImageInfo(image_info,0,exception);
5003 if (*image_info->magick ==
'\0')
5004 ThrowMogrifyException(OptionError,
"UnrecognizedImageFormat",
5008 if (LocaleCompare(
"frame",option+1) == 0)
5013 if (i == (ssize_t) argc)
5014 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5015 if (IsGeometry(argv[i]) == MagickFalse)
5016 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5019 if (LocaleCompare(
"function",option+1) == 0)
5027 if (i == (ssize_t) argc)
5028 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5029 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
5031 ThrowMogrifyException(OptionError,
"UnrecognizedFunction",argv[i]);
5033 if (i == (ssize_t) argc)
5034 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5037 if (LocaleCompare(
"fuzz",option+1) == 0)
5042 if (i == (ssize_t) argc)
5043 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5044 if (IsGeometry(argv[i]) == MagickFalse)
5045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5048 if (LocaleCompare(
"fx",option+1) == 0)
5051 if (i == (ssize_t) argc)
5052 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5055 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5059 if (LocaleCompare(
"gamma",option+1) == 0)
5062 if (i == (ssize_t) argc)
5063 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5064 if (IsGeometry(argv[i]) == MagickFalse)
5065 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5068 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
5069 (LocaleCompare(
"gaussian",option+1) == 0))
5072 if (i == (ssize_t) argc)
5073 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5074 if (IsGeometry(argv[i]) == MagickFalse)
5075 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5078 if (LocaleCompare(
"geometry",option+1) == 0)
5083 if (i == (ssize_t) argc)
5084 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5085 if (IsGeometry(argv[i]) == MagickFalse)
5086 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5089 if (LocaleCompare(
"gravity",option+1) == 0)
5097 if (i == (ssize_t) argc)
5098 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5099 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5102 ThrowMogrifyException(OptionError,
"UnrecognizedGravityType",
5106 if (LocaleCompare(
"grayscale",option+1) == 0)
5114 if (i == (ssize_t) argc)
5115 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5116 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5119 ThrowMogrifyException(OptionError,
"UnrecognizedIntensityMethod",
5123 if (LocaleCompare(
"green-primary",option+1) == 0)
5128 if (i == (ssize_t) argc)
5129 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5130 if (IsGeometry(argv[i]) == MagickFalse)
5131 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5134 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5138 if (LocaleCompare(
"hald-clut",option+1) == 0)
5140 if ((LocaleCompare(
"help",option+1) == 0) ||
5141 (LocaleCompare(
"-help",option+1) == 0))
5144 return(MogrifyUsage());
5146 if (LocaleCompare(
"hough-lines",option+1) == 0)
5151 if (i == (ssize_t) argc)
5152 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5153 if (IsGeometry(argv[i]) == MagickFalse)
5154 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5157 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5161 if (LocaleCompare(
"identify",option+1) == 0)
5163 if (LocaleCompare(
"idft",option+1) == 0)
5165 if (LocaleCompare(
"illuminant",option+1) == 0)
5173 if (i == (ssize_t) argc)
5174 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5175 type=ParseCommandOption(MagickIlluminantOptions,MagickFalse,
5178 ThrowMogrifyException(OptionError,
"UnrecognizedIlluminantMethod",
5182 if (LocaleCompare(
"implode",option+1) == 0)
5187 if (i == (ssize_t) argc)
5188 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5189 if (IsGeometry(argv[i]) == MagickFalse)
5190 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5193 if (LocaleCompare(
"intensity",option+1) == 0)
5201 if (i == (ssize_t) argc)
5202 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5203 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5204 MagickFalse,argv[i]);
5206 ThrowMogrifyException(OptionError,
5207 "UnrecognizedPixelIntensityMethod",argv[i]);
5210 if (LocaleCompare(
"integral",option+1) == 0)
5212 if (LocaleCompare(
"intent",option+1) == 0)
5220 if (i == (ssize_t) argc)
5221 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5222 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5224 ThrowMogrifyException(OptionError,
"UnrecognizedIntentType",
5228 if (LocaleCompare(
"interlace",option+1) == 0)
5236 if (i == (ssize_t) argc)
5237 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5238 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5241 ThrowMogrifyException(OptionError,
"UnrecognizedInterlaceType",
5245 if (LocaleCompare(
"interline-spacing",option+1) == 0)
5250 if (i == (ssize_t) argc)
5251 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5252 if (IsGeometry(argv[i]) == MagickFalse)
5253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5256 if (LocaleCompare(
"interpolate",option+1) == 0)
5264 if (i == (ssize_t) argc)
5265 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5266 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5268 if (interpolate < 0)
5269 ThrowMogrifyException(OptionError,
"UnrecognizedInterpolateMethod",
5273 if (LocaleCompare(
"interword-spacing",option+1) == 0)
5278 if (i == (ssize_t) argc)
5279 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5280 if (IsGeometry(argv[i]) == MagickFalse)
5281 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5284 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5288 if (LocaleCompare(
"kerning",option+1) == 0)
5293 if (i == (ssize_t) argc)
5294 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5295 if (IsGeometry(argv[i]) == MagickFalse)
5296 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5299 if (LocaleCompare(
"kmeans",option+1) == 0)
5302 if (i == (ssize_t) argc)
5303 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5304 if (IsGeometry(argv[i]) == MagickFalse)
5305 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5308 if (LocaleCompare(
"kuwahara",option+1) == 0)
5311 if (i == (ssize_t) argc)
5312 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5313 if (IsGeometry(argv[i]) == MagickFalse)
5314 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5317 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5321 if (LocaleCompare(
"label",option+1) == 0)
5326 if (i == (ssize_t) argc)
5327 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5330 if (LocaleCompare(
"lat",option+1) == 0)
5335 if (i == (ssize_t) argc)
5336 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5337 if (IsGeometry(argv[i]) == MagickFalse)
5338 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5341 if (LocaleCompare(
"layers",option+1) == 0)
5349 if (i == (ssize_t) argc)
5350 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5351 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5353 ThrowMogrifyException(OptionError,
"UnrecognizedLayerMethod",
5357 if (LocaleCompare(
"level",option+1) == 0)
5360 if (i == (ssize_t) argc)
5361 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5362 if (IsGeometry(argv[i]) == MagickFalse)
5363 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5366 if (LocaleCompare(
"level-colors",option+1) == 0)
5369 if (i == (ssize_t) argc)
5370 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5373 if (LocaleCompare(
"limit",option+1) == 0)
5387 if (i == (ssize_t) argc)
5388 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5389 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5392 ThrowMogrifyException(OptionError,
"UnrecognizedResourceType",
5395 if (i == (ssize_t) argc)
5396 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5397 value=StringToDouble(argv[i],&p);
5399 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
5400 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5403 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
5406 if (i == (ssize_t) argc)
5407 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5408 if (IsGeometry(argv[i]) == MagickFalse)
5409 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5412 if (LocaleCompare(
"list",option+1) == 0)
5420 if (i == (ssize_t) argc)
5421 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5422 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5424 ThrowMogrifyException(OptionError,
"UnrecognizedListType",argv[i]);
5425 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
5427 return(status == 0 ? MagickFalse : MagickTrue);
5429 if (LocaleCompare(
"log",option+1) == 0)
5434 if ((i == (ssize_t) argc) ||
5435 (strchr(argv[i],
'%') == (
char *) NULL))
5436 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5439 if (LocaleCompare(
"loop",option+1) == 0)
5444 if (i == (ssize_t) argc)
5445 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5446 if (IsGeometry(argv[i]) == MagickFalse)
5447 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5450 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5454 if (LocaleCompare(
"magnify",option+1) == 0)
5456 if (LocaleCompare(
"map",option+1) == 0)
5458 global_colormap=(*option ==
'+') ? MagickTrue : MagickFalse;
5462 if (i == (ssize_t) argc)
5463 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5466 if (LocaleCompare(
"mask",option+1) == 0)
5471 if (i == (ssize_t) argc)
5472 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5475 if (LocaleCompare(
"matte",option+1) == 0)
5477 if (LocaleCompare(
"mattecolor",option+1) == 0)
5482 if (i == (ssize_t) argc)
5483 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5486 if (LocaleCompare(
"maximum",option+1) == 0)
5488 if (LocaleCompare(
"mean-shift",option+1) == 0)
5493 if (i == (ssize_t) argc)
5494 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5495 if (IsGeometry(argv[i]) == MagickFalse)
5496 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5499 if (LocaleCompare(
"median",option+1) == 0)
5504 if (i == (ssize_t) argc)
5505 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5506 if (IsGeometry(argv[i]) == MagickFalse)
5507 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5510 if (LocaleCompare(
"metric",option+1) == 0)
5518 if (i == (ssize_t) argc)
5519 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5520 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5522 ThrowMogrifyException(OptionError,
"UnrecognizedMetricType",
5526 if (LocaleCompare(
"minimum",option+1) == 0)
5528 if (LocaleCompare(
"modulate",option+1) == 0)
5533 if (i == (ssize_t) argc)
5534 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5535 if (IsGeometry(argv[i]) == MagickFalse)
5536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5539 if (LocaleCompare(
"mode",option+1) == 0)
5544 if (i == (ssize_t) argc)
5545 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5546 if (IsGeometry(argv[i]) == MagickFalse)
5547 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5550 if (LocaleCompare(
"monitor",option+1) == 0)
5552 if (LocaleCompare(
"monochrome",option+1) == 0)
5554 if (LocaleCompare(
"morph",option+1) == 0)
5559 if (i == (ssize_t) argc)
5560 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5561 if (IsGeometry(argv[i]) == MagickFalse)
5562 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5565 if (LocaleCompare(
"morphology",option+1) == 0)
5568 token[MagickPathExtent];
5577 if (i == (ssize_t) argc)
5578 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5579 (void) GetNextToken(argv[i],(
const char **) NULL,MagickPathExtent,
5581 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5583 ThrowMogrifyException(OptionError,
"UnrecognizedMorphologyMethod",
5586 if (i == (ssize_t) argc)
5587 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5588 kernel_info=AcquireKernelInfo(argv[i],exception);
5589 if (kernel_info == (KernelInfo *) NULL)
5590 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5591 kernel_info=DestroyKernelInfo(kernel_info);
5594 if (LocaleCompare(
"mosaic",option+1) == 0)
5596 if (LocaleCompare(
"motion-blur",option+1) == 0)
5601 if (i == (ssize_t) argc)
5602 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5603 if (IsGeometry(argv[i]) == MagickFalse)
5604 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5607 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5611 if (LocaleCompare(
"negate",option+1) == 0)
5613 if (LocaleCompare(
"noise",option+1) == 0)
5616 if (i == (ssize_t) argc)
5617 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5623 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
5626 ThrowMogrifyException(OptionError,
"UnrecognizedNoiseType",
5630 if (IsGeometry(argv[i]) == MagickFalse)
5631 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5634 if (LocaleCompare(
"noop",option+1) == 0)
5636 if (LocaleCompare(
"normalize",option+1) == 0)
5638 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5642 if (LocaleCompare(
"opaque",option+1) == 0)
5645 if (i == (ssize_t) argc)
5646 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5649 if (LocaleCompare(
"ordered-dither",option+1) == 0)
5654 if (i == (ssize_t) argc)
5655 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5658 if (LocaleCompare(
"orient",option+1) == 0)
5663 orientation=UndefinedOrientation;
5667 if (i == (ssize_t) argc)
5668 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5669 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5671 if (orientation < 0)
5672 ThrowMogrifyException(OptionError,
"UnrecognizedImageOrientation",
5676 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5680 if (LocaleCompare(
"page",option+1) == 0)
5685 if (i == (ssize_t) argc)
5686 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5689 if (LocaleCompare(
"paint",option+1) == 0)
5694 if (i == (ssize_t) argc)
5695 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5696 if (IsGeometry(argv[i]) == MagickFalse)
5697 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5700 if (LocaleCompare(
"path",option+1) == 0)
5702 (void) CloneString(&path,(
char *) NULL);
5706 if (i == (ssize_t) argc)
5707 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5708 (void) CloneString(&path,argv[i]);
5711 if (LocaleCompare(
"perceptible",option+1) == 0)
5716 if (i == (ssize_t) argc)
5717 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5718 if (IsGeometry(argv[i]) == MagickFalse)
5719 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5722 if (LocaleCompare(
"pointsize",option+1) == 0)
5727 if (i == (ssize_t) argc)
5728 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5729 if (IsGeometry(argv[i]) == MagickFalse)
5730 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5733 if (LocaleCompare(
"polaroid",option+1) == 0)
5738 if (i == (ssize_t) argc)
5739 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5740 if (IsGeometry(argv[i]) == MagickFalse)
5741 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5744 if (LocaleCompare(
"poly",option+1) == 0)
5749 if (i == (ssize_t) argc)
5750 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5751 if (IsGeometry(argv[i]) == MagickFalse)
5752 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5755 if (LocaleCompare(
"posterize",option+1) == 0)
5760 if (i == (ssize_t) argc)
5761 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5762 if (IsGeometry(argv[i]) == MagickFalse)
5763 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5766 if (LocaleCompare(
"precision",option+1) == 0)
5771 if (i == (ssize_t) argc)
5772 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5773 if (IsGeometry(argv[i]) == MagickFalse)
5774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5777 if (LocaleCompare(
"print",option+1) == 0)
5782 if (i == (ssize_t) argc)
5783 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5786 if (LocaleCompare(
"process",option+1) == 0)
5791 if (i == (ssize_t) argc)
5792 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5795 if (LocaleCompare(
"profile",option+1) == 0)
5798 if (i == (ssize_t) argc)
5799 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5802 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5806 if (LocaleCompare(
"quality",option+1) == 0)
5811 if (i == (ssize_t) argc)
5812 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5813 if (IsGeometry(argv[i]) == MagickFalse)
5814 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5817 if (LocaleCompare(
"quantize",option+1) == 0)
5825 if (i == (ssize_t) argc)
5826 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5827 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5830 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
5834 if (LocaleCompare(
"quiet",option+1) == 0)
5836 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5840 if (LocaleCompare(
"rotational-blur",option+1) == 0)
5843 if (i == (ssize_t) argc)
5844 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5845 if (IsGeometry(argv[i]) == MagickFalse)
5846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5849 if (LocaleCompare(
"raise",option+1) == 0)
5852 if (i == (ssize_t) argc)
5853 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5854 if (IsGeometry(argv[i]) == MagickFalse)
5855 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5858 if (LocaleCompare(
"random-threshold",option+1) == 0)
5863 if (i == (ssize_t) argc)
5864 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5865 if (IsGeometry(argv[i]) == MagickFalse)
5866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5869 if (LocaleCompare(
"range-threshold",option+1) == 0)
5874 if (i == (ssize_t) argc)
5875 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5876 if (IsGeometry(argv[i]) == MagickFalse)
5877 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5880 if (LocaleCompare(
"read-mask",option+1) == 0)
5885 if (i == (ssize_t) argc)
5886 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5889 if (LocaleCompare(
"red-primary",option+1) == 0)
5894 if (i == (ssize_t) argc)
5895 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5896 if (IsGeometry(argv[i]) == MagickFalse)
5897 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5899 if (LocaleCompare(
"regard-warnings",option+1) == 0)
5901 if (LocaleCompare(
"region",option+1) == 0)
5906 if (i == (ssize_t) argc)
5907 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5908 if (IsGeometry(argv[i]) == MagickFalse)
5909 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5912 if (LocaleCompare(
"remap",option+1) == 0)
5917 if (i == (ssize_t) argc)
5918 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5921 if (LocaleCompare(
"render",option+1) == 0)
5923 if (LocaleCompare(
"repage",option+1) == 0)
5928 if (i == (ssize_t) argc)
5929 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5930 if (IsGeometry(argv[i]) == MagickFalse)
5931 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5934 if (LocaleCompare(
"resample",option+1) == 0)
5939 if (i == (ssize_t) argc)
5940 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5941 if (IsGeometry(argv[i]) == MagickFalse)
5942 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5945 if (LocaleCompare(
"reshape",option+1) == 0)
5950 if (i == (ssize_t) argc)
5951 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5952 if (IsGeometry(argv[i]) == MagickFalse)
5953 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5956 if (LocaleCompare(
"resize",option+1) == 0)
5961 if (i == (ssize_t) argc)
5962 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5963 if (IsGeometry(argv[i]) == MagickFalse)
5964 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5967 if ((LocaleNCompare(
"respect-parentheses",option+1,17) == 0) ||
5968 (LocaleNCompare(
"respect-parenthesis",option+1,17) == 0))
5970 respect_parentheses=(*option ==
'-') ? MagickTrue : MagickFalse;
5973 if (LocaleCompare(
"reverse",option+1) == 0)
5975 if (LocaleCompare(
"roll",option+1) == 0)
5980 if (i == (ssize_t) argc)
5981 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5982 if (IsGeometry(argv[i]) == MagickFalse)
5983 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5986 if (LocaleCompare(
"rotate",option+1) == 0)
5989 if (i == (ssize_t) argc)
5990 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5991 if (IsGeometry(argv[i]) == MagickFalse)
5992 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5995 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5999 if (LocaleCompare(
"sample",option+1) == 0)
6004 if (i == (ssize_t) argc)
6005 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6006 if (IsGeometry(argv[i]) == MagickFalse)
6007 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6010 if (LocaleCompare(
"sampling-factor",option+1) == 0)
6015 if (i == (ssize_t) argc)
6016 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6017 if (IsGeometry(argv[i]) == MagickFalse)
6018 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6021 if (LocaleCompare(
"scale",option+1) == 0)
6026 if (i == (ssize_t) argc)
6027 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6028 if (IsGeometry(argv[i]) == MagickFalse)
6029 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6032 if (LocaleCompare(
"scene",option+1) == 0)
6037 if (i == (ssize_t) argc)
6038 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6039 if (IsGeometry(argv[i]) == MagickFalse)
6040 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6043 if (LocaleCompare(
"seed",option+1) == 0)
6048 if (i == (ssize_t) argc)
6049 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6050 if (IsGeometry(argv[i]) == MagickFalse)
6051 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6054 if (LocaleCompare(
"segment",option+1) == 0)
6059 if (i == (ssize_t) argc)
6060 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6061 if (IsGeometry(argv[i]) == MagickFalse)
6062 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6065 if (LocaleCompare(
"selective-blur",option+1) == 0)
6068 if (i == (ssize_t) argc)
6069 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6070 if (IsGeometry(argv[i]) == MagickFalse)
6071 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6074 if (LocaleCompare(
"separate",option+1) == 0)
6076 if (LocaleCompare(
"sepia-tone",option+1) == 0)
6081 if (i == (ssize_t) argc)
6082 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6083 if (IsGeometry(argv[i]) == MagickFalse)
6084 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6087 if (LocaleCompare(
"set",option+1) == 0)
6090 if (i == (ssize_t) argc)
6091 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6095 if (i == (ssize_t) argc)
6096 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6099 if (LocaleCompare(
"shade",option+1) == 0)
6102 if (i == (ssize_t) argc)
6103 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6104 if (IsGeometry(argv[i]) == MagickFalse)
6105 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6108 if (LocaleCompare(
"shadow",option+1) == 0)
6113 if (i == (ssize_t) argc)
6114 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6115 if (IsGeometry(argv[i]) == MagickFalse)
6116 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6119 if (LocaleCompare(
"sharpen",option+1) == 0)
6122 if (i == (ssize_t) argc)
6123 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6124 if (IsGeometry(argv[i]) == MagickFalse)
6125 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6128 if (LocaleCompare(
"shave",option+1) == 0)
6133 if (i == (ssize_t) argc)
6134 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6135 if (IsGeometry(argv[i]) == MagickFalse)
6136 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6139 if (LocaleCompare(
"shear",option+1) == 0)
6142 if (i == (ssize_t) argc)
6143 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6144 if (IsGeometry(argv[i]) == MagickFalse)
6145 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6148 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
6151 if (i == (ssize_t) argc)
6152 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6153 if (IsGeometry(argv[i]) == MagickFalse)
6154 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6157 if (LocaleCompare(
"size",option+1) == 0)
6162 if (i == (ssize_t) argc)
6163 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6164 if (IsGeometry(argv[i]) == MagickFalse)
6165 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6168 if (LocaleCompare(
"sketch",option+1) == 0)
6173 if (i == (ssize_t) argc)
6174 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6175 if (IsGeometry(argv[i]) == MagickFalse)
6176 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6179 if (LocaleCompare(
"smush",option+1) == 0)
6182 if (i == (ssize_t) argc)
6183 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6184 if (IsGeometry(argv[i]) == MagickFalse)
6185 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6189 if (LocaleCompare(
"solarize",option+1) == 0)
6194 if (i == (ssize_t) argc)
6195 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6196 if (IsGeometry(argv[i]) == MagickFalse)
6197 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6200 if (LocaleCompare(
"sort",option+1) == 0)
6202 if (LocaleCompare(
"sparse-color",option+1) == 0)
6208 if (i == (ssize_t) argc)
6209 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6210 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6212 ThrowMogrifyException(OptionError,
"UnrecognizedSparseColorMethod",
6215 if (i == (ssize_t) argc)
6216 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6219 if (LocaleCompare(
"splice",option+1) == 0)
6224 if (i == (ssize_t) argc)
6225 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6226 if (IsGeometry(argv[i]) == MagickFalse)
6227 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6230 if (LocaleCompare(
"spread",option+1) == 0)
6235 if (i == (ssize_t) argc)
6236 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6237 if (IsGeometry(argv[i]) == MagickFalse)
6238 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6241 if (LocaleCompare(
"statistic",option+1) == 0)
6249 if (i == (ssize_t) argc)
6250 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6251 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6253 ThrowMogrifyException(OptionError,
"UnrecognizedStatisticType",
6256 if (i == (ssize_t) argc)
6257 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6258 if (IsGeometry(argv[i]) == MagickFalse)
6259 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6262 if (LocaleCompare(
"stretch",option+1) == 0)
6270 if (i == (ssize_t) argc)
6271 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6272 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
6275 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6279 if (LocaleCompare(
"strip",option+1) == 0)
6281 if (LocaleCompare(
"stroke",option+1) == 0)
6286 if (i == (ssize_t) argc)
6287 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6290 if (LocaleCompare(
"strokewidth",option+1) == 0)
6295 if (i == (ssize_t) argc)
6296 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6297 if (IsGeometry(argv[i]) == MagickFalse)
6298 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6301 if (LocaleCompare(
"style",option+1) == 0)
6309 if (i == (ssize_t) argc)
6310 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6311 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6313 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6317 if (LocaleCompare(
"swap",option+1) == 0)
6322 if (i == (ssize_t) argc)
6323 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6324 if (IsGeometry(argv[i]) == MagickFalse)
6325 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6328 if (LocaleCompare(
"swirl",option+1) == 0)
6333 if (i == (ssize_t) argc)
6334 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6335 if (IsGeometry(argv[i]) == MagickFalse)
6336 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6339 if (LocaleCompare(
"synchronize",option+1) == 0)
6341 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6345 if (LocaleCompare(
"taint",option+1) == 0)
6347 if (LocaleCompare(
"texture",option+1) == 0)
6352 if (i == (ssize_t) argc)
6353 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6356 if (LocaleCompare(
"tile",option+1) == 0)
6361 if (i == (ssize_t) argc)
6362 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6365 if (LocaleCompare(
"tile-offset",option+1) == 0)
6370 if (i == (ssize_t) argc)
6371 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6372 if (IsGeometry(argv[i]) == MagickFalse)
6373 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6376 if (LocaleCompare(
"tint",option+1) == 0)
6381 if (i == (ssize_t) argc)
6382 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6383 if (IsGeometry(argv[i]) == MagickFalse)
6384 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6387 if (LocaleCompare(
"transform",option+1) == 0)
6389 if (LocaleCompare(
"transpose",option+1) == 0)
6391 if (LocaleCompare(
"transverse",option+1) == 0)
6393 if (LocaleCompare(
"threshold",option+1) == 0)
6398 if (i == (ssize_t) argc)
6399 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6400 if (IsGeometry(argv[i]) == MagickFalse)
6401 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6404 if (LocaleCompare(
"thumbnail",option+1) == 0)
6409 if (i == (ssize_t) argc)
6410 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6411 if (IsGeometry(argv[i]) == MagickFalse)
6412 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6415 if (LocaleCompare(
"transparent",option+1) == 0)
6418 if (i == (ssize_t) argc)
6419 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6422 if (LocaleCompare(
"transparent-color",option+1) == 0)
6427 if (i == (ssize_t) argc)
6428 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6431 if (LocaleCompare(
"treedepth",option+1) == 0)
6436 if (i == (ssize_t) argc)
6437 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6438 if (IsGeometry(argv[i]) == MagickFalse)
6439 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6442 if (LocaleCompare(
"trim",option+1) == 0)
6444 if (LocaleCompare(
"type",option+1) == 0)
6452 if (i == (ssize_t) argc)
6453 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6454 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6456 ThrowMogrifyException(OptionError,
"UnrecognizedImageType",
6460 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6464 if (LocaleCompare(
"undercolor",option+1) == 0)
6469 if (i == (ssize_t) argc)
6470 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6473 if (LocaleCompare(
"unique-colors",option+1) == 0)
6475 if (LocaleCompare(
"units",option+1) == 0)
6483 if (i == (ssize_t) argc)
6484 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6485 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6488 ThrowMogrifyException(OptionError,
"UnrecognizedUnitsType",
6492 if (LocaleCompare(
"unsharp",option+1) == 0)
6495 if (i == (ssize_t) argc)
6496 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6497 if (IsGeometry(argv[i]) == MagickFalse)
6498 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6501 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6505 if (LocaleCompare(
"verbose",option+1) == 0)
6507 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
6510 if ((LocaleCompare(
"version",option+1) == 0) ||
6511 (LocaleCompare(
"-version",option+1) == 0))
6513 ListMagickVersion(stdout);
6516 if (LocaleCompare(
"vignette",option+1) == 0)
6521 if (i == (ssize_t) argc)
6522 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6523 if (IsGeometry(argv[i]) == MagickFalse)
6524 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6527 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
6535 if (i == (ssize_t) argc)
6536 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6537 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6540 ThrowMogrifyException(OptionError,
6541 "UnrecognizedVirtualPixelMethod",argv[i]);
6544 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6548 if (LocaleCompare(
"wave",option+1) == 0)
6551 if (i == (ssize_t) argc)
6552 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6553 if (IsGeometry(argv[i]) == MagickFalse)
6554 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6557 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
6560 if (i == (ssize_t) argc)
6561 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6562 if (IsGeometry(argv[i]) == MagickFalse)
6563 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6566 if (LocaleCompare(
"weight",option+1) == 0)
6571 if (i == (ssize_t) argc)
6572 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6575 if (LocaleCompare(
"word-break",option+1) == 0)
6583 if (i == (ssize_t) argc)
6584 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6585 word_break=ParseCommandOption(MagickWordBreakOptions,MagickFalse,
6588 ThrowMogrifyException(OptionError,
"UnrecognizedArgument",argv[i]);
6591 if (LocaleCompare(
"white-balance",option+1) == 0)
6593 if (LocaleCompare(
"white-point",option+1) == 0)
6598 if (i == (ssize_t) argc)
6599 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6600 if (IsGeometry(argv[i]) == MagickFalse)
6601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6604 if (LocaleCompare(
"white-threshold",option+1) == 0)
6609 if (i == (ssize_t) argc)
6610 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6611 if (IsGeometry(argv[i]) == MagickFalse)
6612 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6615 if (LocaleCompare(
"write",option+1) == 0)
6618 if (i == (ssize_t) argc)
6619 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6622 if (LocaleCompare(
"write-mask",option+1) == 0)
6627 if (i == (ssize_t) argc)
6628 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6631 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6636 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6638 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6639 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6640 if (fire != MagickFalse)
6641 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6644 ThrowMogrifyException(OptionError,
"UnbalancedParenthesis",argv[i]);
6645 if (i != (ssize_t) argc)
6646 ThrowMogrifyException(OptionError,
"MissingAnImageFilename",argv[i]);
6648 return(status != 0 ? MagickTrue : MagickFalse);
6683WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6684 const int argc,
const char **argv,ExceptionInfo *exception)
6701 assert(image_info != (ImageInfo *) NULL);
6702 assert(image_info->signature == MagickCoreSignature);
6703 if (IsEventLogging() != MagickFalse)
6704 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
6705 image_info->filename);
6711 for (i=0; i < (ssize_t) argc; i++)
6714 if (IsCommandOption(option) == MagickFalse)
6716 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6717 count=MagickMax(count,0L);
6718 if ((i+count) >= (ssize_t) argc)
6720 switch (*(option+1))
6724 if (LocaleCompare(
"adjoin",option+1) == 0)
6726 image_info->adjoin=(*option ==
'-') ? MagickTrue : MagickFalse;
6729 if (LocaleCompare(
"antialias",option+1) == 0)
6731 image_info->antialias=(*option ==
'-') ? MagickTrue : MagickFalse;
6734 if (LocaleCompare(
"authenticate",option+1) == 0)
6737 (void) DeleteImageOption(image_info,option+1);
6739 (
void) SetImageOption(image_info,option+1,argv[i+1]);
6746 if (LocaleCompare(
"background",option+1) == 0)
6750 (void) DeleteImageOption(image_info,option+1);
6751 (void) QueryColorCompliance(MogrifyBackgroundColor,
6752 AllCompliance,&image_info->background_color,exception);
6755 (void) SetImageOption(image_info,option+1,argv[i+1]);
6756 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6757 &image_info->background_color,exception);
6760 if (LocaleCompare(
"bias",option+1) == 0)
6764 (void) SetImageOption(image_info,
"convolve:bias",
"0.0");
6767 (void) SetImageOption(image_info,
"convolve:bias",argv[i+1]);
6770 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
6774 (void) SetImageOption(image_info,option+1,
"false");
6777 (void) SetImageOption(image_info,option+1,
"true");
6780 if (LocaleCompare(
"blue-primary",option+1) == 0)
6784 (void) SetImageOption(image_info,option+1,
"0.0");
6787 (void) SetImageOption(image_info,option+1,argv[i+1]);
6790 if (LocaleCompare(
"bordercolor",option+1) == 0)
6794 (void) DeleteImageOption(image_info,option+1);
6795 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6796 &image_info->border_color,exception);
6799 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6800 &image_info->border_color,exception);
6801 (void) SetImageOption(image_info,option+1,argv[i+1]);
6804 if (LocaleCompare(
"box",option+1) == 0)
6808 (void) SetImageOption(image_info,
"undercolor",
"none");
6811 (void) SetImageOption(image_info,
"undercolor",argv[i+1]);
6818 if (LocaleCompare(
"cache",option+1) == 0)
6823 limit=MagickResourceInfinity;
6824 if (LocaleCompare(
"unlimited",argv[i+1]) != 0)
6825 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6827 (void) SetMagickResourceLimit(MemoryResource,limit);
6828 (void) SetMagickResourceLimit(MapResource,2*limit);
6831 if (LocaleCompare(
"caption",option+1) == 0)
6835 (void) DeleteImageOption(image_info,option+1);
6838 (void) SetImageOption(image_info,option+1,argv[i+1]);
6841 if (LocaleCompare(
"colorspace",option+1) == 0)
6845 image_info->colorspace=UndefinedColorspace;
6846 (void) SetImageOption(image_info,option+1,
"undefined");
6849 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6850 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6851 (void) SetImageOption(image_info,option+1,argv[i+1]);
6854 if (LocaleCompare(
"comment",option+1) == 0)
6858 (void) DeleteImageOption(image_info,option+1);
6861 (void) SetImageOption(image_info,option+1,argv[i+1]);
6864 if (LocaleCompare(
"compose",option+1) == 0)
6868 (void) SetImageOption(image_info,option+1,
"undefined");
6871 (void) SetImageOption(image_info,option+1,argv[i+1]);
6874 if (LocaleCompare(
"compress",option+1) == 0)
6878 image_info->compression=UndefinedCompression;
6879 (void) SetImageOption(image_info,option+1,
"undefined");
6882 image_info->compression=(CompressionType) ParseCommandOption(
6883 MagickCompressOptions,MagickFalse,argv[i+1]);
6884 (void) SetImageOption(image_info,option+1,argv[i+1]);
6891 if (LocaleCompare(
"debug",option+1) == 0)
6894 (void) SetLogEventMask(
"none");
6896 (
void) SetLogEventMask(argv[i+1]);
6897 image_info->debug=IsEventLogging();
6900 if (LocaleCompare(
"define",option+1) == 0)
6904 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6905 (void) DeleteImageRegistry(argv[i+1]+9);
6907 (
void) DeleteImageOption(image_info,argv[i+1]);
6910 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6912 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6916 (void) DefineImageOption(image_info,argv[i+1]);
6919 if (LocaleCompare(
"delay",option+1) == 0)
6923 (void) SetImageOption(image_info,option+1,
"0");
6926 (void) SetImageOption(image_info,option+1,argv[i+1]);
6929 if (LocaleCompare(
"density",option+1) == 0)
6936 if (image_info->density != (
char *) NULL)
6937 image_info->density=DestroyString(image_info->density);
6938 (void) SetImageOption(image_info,option+1,
"72");
6941 (void) CloneString(&image_info->density,argv[i+1]);
6942 (void) SetImageOption(image_info,option+1,argv[i+1]);
6945 if (LocaleCompare(
"depth",option+1) == 0)
6949 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6952 image_info->depth=StringToUnsignedLong(argv[i+1]);
6955 if (LocaleCompare(
"direction",option+1) == 0)
6959 (void) SetImageOption(image_info,option+1,
"undefined");
6962 (void) SetImageOption(image_info,option+1,argv[i+1]);
6965 if (LocaleCompare(
"display",option+1) == 0)
6969 if (image_info->server_name != (
char *) NULL)
6970 image_info->server_name=DestroyString(
6971 image_info->server_name);
6974 (void) CloneString(&image_info->server_name,argv[i+1]);
6977 if (LocaleCompare(
"dispose",option+1) == 0)
6981 (void) SetImageOption(image_info,option+1,
"undefined");
6984 (void) SetImageOption(image_info,option+1,argv[i+1]);
6987 if (LocaleCompare(
"dither",option+1) == 0)
6991 image_info->dither=MagickFalse;
6992 (void) SetImageOption(image_info,option+1,
"none");
6995 (void) SetImageOption(image_info,option+1,argv[i+1]);
6996 image_info->dither=MagickTrue;
7003 if (LocaleCompare(
"encoding",option+1) == 0)
7007 (void) SetImageOption(image_info,option+1,
"undefined");
7010 (void) SetImageOption(image_info,option+1,argv[i+1]);
7013 if (LocaleCompare(
"endian",option+1) == 0)
7017 image_info->endian=UndefinedEndian;
7018 (void) SetImageOption(image_info,option+1,
"undefined");
7021 image_info->endian=(EndianType) ParseCommandOption(
7022 MagickEndianOptions,MagickFalse,argv[i+1]);
7023 (void) SetImageOption(image_info,option+1,argv[i+1]);
7026 if (LocaleCompare(
"extract",option+1) == 0)
7033 if (image_info->extract != (
char *) NULL)
7034 image_info->extract=DestroyString(image_info->extract);
7037 (void) CloneString(&image_info->extract,argv[i+1]);
7044 if (LocaleCompare(
"family",option+1) == 0)
7047 (void) SetImageOption(image_info,option+1,argv[i+1]);
7050 if (LocaleCompare(
"fill",option+1) == 0)
7054 (void) SetImageOption(image_info,option+1,
"none");
7057 (void) SetImageOption(image_info,option+1,argv[i+1]);
7060 if (LocaleCompare(
"filter",option+1) == 0)
7064 (void) SetImageOption(image_info,option+1,
"undefined");
7067 (void) SetImageOption(image_info,option+1,argv[i+1]);
7070 if (LocaleCompare(
"font",option+1) == 0)
7074 if (image_info->font != (
char *) NULL)
7075 image_info->font=DestroyString(image_info->font);
7078 (void) CloneString(&image_info->font,argv[i+1]);
7081 if (LocaleCompare(
"format",option+1) == 0)
7083 (void) SetImageOption(image_info,option+1,argv[i+1]);
7086 if (LocaleCompare(
"fuzz",option+1) == 0)
7090 image_info->fuzz=0.0;
7091 (void) SetImageOption(image_info,option+1,
"0");
7094 image_info->fuzz=StringToDoubleInterval(argv[i+1],(
double)
7096 (void) SetImageOption(image_info,option+1,argv[i+1]);
7103 if (LocaleCompare(
"gravity",option+1) == 0)
7107 (void) SetImageOption(image_info,option+1,
"undefined");
7110 (void) SetImageOption(image_info,option+1,argv[i+1]);
7113 if (LocaleCompare(
"green-primary",option+1) == 0)
7117 (void) SetImageOption(image_info,option+1,
"0.0");
7120 (void) SetImageOption(image_info,option+1,argv[i+1]);
7127 if (LocaleCompare(
"intensity",option+1) == 0)
7131 (void) SetImageOption(image_info,option+1,
"undefined");
7134 (void) SetImageOption(image_info,option+1,argv[i+1]);
7137 if (LocaleCompare(
"intent",option+1) == 0)
7141 (void) SetImageOption(image_info,option+1,
"undefined");
7144 (void) SetImageOption(image_info,option+1,argv[i+1]);
7147 if (LocaleCompare(
"interlace",option+1) == 0)
7151 image_info->interlace=UndefinedInterlace;
7152 (void) SetImageOption(image_info,option+1,
"undefined");
7155 image_info->interlace=(InterlaceType) ParseCommandOption(
7156 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7157 (void) SetImageOption(image_info,option+1,argv[i+1]);
7160 if (LocaleCompare(
"interline-spacing",option+1) == 0)
7164 (void) SetImageOption(image_info,option+1,
"undefined");
7167 (void) SetImageOption(image_info,option+1,argv[i+1]);
7170 if (LocaleCompare(
"interpolate",option+1) == 0)
7174 (void) SetImageOption(image_info,option+1,
"undefined");
7177 (void) SetImageOption(image_info,option+1,argv[i+1]);
7180 if (LocaleCompare(
"interword-spacing",option+1) == 0)
7184 (void) SetImageOption(image_info,option+1,
"undefined");
7187 (void) SetImageOption(image_info,option+1,argv[i+1]);
7194 if (LocaleCompare(
"kerning",option+1) == 0)
7198 (void) SetImageOption(image_info,option+1,
"undefined");
7201 (void) SetImageOption(image_info,option+1,argv[i+1]);
7208 if (LocaleCompare(
"label",option+1) == 0)
7212 (void) DeleteImageOption(image_info,option+1);
7215 (void) SetImageOption(image_info,option+1,argv[i+1]);
7218 if (LocaleCompare(
"limit",option+1) == 0)
7228 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7229 MagickFalse,argv[i+1]);
7230 limit=MagickResourceInfinity;
7231 if (LocaleCompare(
"unlimited",argv[i+2]) != 0)
7232 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7233 if (type == TimeResource)
7234 limit=(MagickSizeType) ParseMagickTimeToLive(argv[i+2]);
7235 (void) SetMagickResourceLimit(type,limit);
7238 if (LocaleCompare(
"list",option+1) == 0)
7246 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7249 case MagickCoderOptions:
7251 (void) ListCoderInfo((FILE *) NULL,exception);
7254 case MagickColorOptions:
7256 (void) ListColorInfo((FILE *) NULL,exception);
7259 case MagickConfigureOptions:
7261 (void) ListConfigureInfo((FILE *) NULL,exception);
7264 case MagickDelegateOptions:
7266 (void) ListDelegateInfo((FILE *) NULL,exception);
7269 case MagickFontOptions:
7271 (void) ListTypeInfo((FILE *) NULL,exception);
7274 case MagickFormatOptions:
7276 (void) ListMagickInfo((FILE *) NULL,exception);
7279 case MagickLocaleOptions:
7281 (void) ListLocaleInfo((FILE *) NULL,exception);
7284 case MagickLogOptions:
7286 (void) ListLogInfo((FILE *) NULL,exception);
7289 case MagickMagicOptions:
7291 (void) ListMagicInfo((FILE *) NULL,exception);
7294 case MagickMimeOptions:
7296 (void) ListMimeInfo((FILE *) NULL,exception);
7299 case MagickModuleOptions:
7301 (void) ListModuleInfo((FILE *) NULL,exception);
7304 case MagickPagesizeOptions:
7306 (void) ListPagesizes((FILE *) NULL,exception);
7309 case MagickPolicyOptions:
7311 (void) ListPolicyInfo((FILE *) NULL,exception);
7314 case MagickResourceOptions:
7316 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7319 case MagickThresholdOptions:
7321 (void) ListThresholdMaps((FILE *) NULL,exception);
7326 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7333 if (LocaleCompare(
"log",option+1) == 0)
7337 (void) SetLogFormat(argv[i+1]);
7340 if (LocaleCompare(
"loop",option+1) == 0)
7344 (void) SetImageOption(image_info,option+1,
"0");
7347 (void) SetImageOption(image_info,option+1,argv[i+1]);
7354 if (LocaleCompare(
"matte",option+1) == 0)
7358 (void) SetImageOption(image_info,option+1,
"false");
7361 (void) SetImageOption(image_info,option+1,
"true");
7364 if (LocaleCompare(
"mattecolor",option+1) == 0)
7368 (void) SetImageOption(image_info,option+1,argv[i+1]);
7369 (void) QueryColorCompliance(MogrifyAlphaColor,AllCompliance,
7370 &image_info->matte_color,exception);
7373 (void) SetImageOption(image_info,option+1,argv[i+1]);
7374 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7375 &image_info->matte_color,exception);
7378 if (LocaleCompare(
"metric",option+1) == 0)
7381 (void) DeleteImageOption(image_info,option+1);
7383 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7386 if (LocaleCompare(
"monitor",option+1) == 0)
7388 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7392 if (LocaleCompare(
"monochrome",option+1) == 0)
7394 image_info->monochrome=(*option ==
'-') ? MagickTrue : MagickFalse;
7401 if (LocaleCompare(
"orient",option+1) == 0)
7405 image_info->orientation=UndefinedOrientation;
7406 (void) SetImageOption(image_info,option+1,
"undefined");
7409 image_info->orientation=(OrientationType) ParseCommandOption(
7410 MagickOrientationOptions,MagickFalse,argv[i+1]);
7411 (void) SetImageOption(image_info,option+1,argv[i+1]);
7418 if (LocaleCompare(
"page",option+1) == 0)
7422 page[MagickPathExtent];
7435 (void) DeleteImageOption(image_info,option+1);
7436 (void) CloneString(&image_info->page,(
char *) NULL);
7439 (void) memset(&geometry,0,
sizeof(geometry));
7440 image_option=GetImageOption(image_info,
"page");
7441 if (image_option != (
const char *) NULL)
7442 flags=ParseAbsoluteGeometry(image_option,&geometry);
7443 canonical_page=GetPageGeometry(argv[i+1]);
7444 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7445 canonical_page=DestroyString(canonical_page);
7446 (void) FormatLocaleString(page,MagickPathExtent,
"%lux%lu",
7447 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
7448 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7449 (void) FormatLocaleString(page,MagickPathExtent,
"%lux%lu%+ld%+ld",
7450 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
7451 (
long) geometry.x,(
long) geometry.y);
7452 (void) SetImageOption(image_info,option+1,page);
7453 (void) CloneString(&image_info->page,page);
7456 if (LocaleCompare(
"ping",option+1) == 0)
7458 image_info->ping=(*option ==
'-') ? MagickTrue : MagickFalse;
7461 if (LocaleCompare(
"pointsize",option+1) == 0)
7464 geometry_info.rho=0.0;
7466 (
void) ParseGeometry(argv[i+1],&geometry_info);
7467 image_info->pointsize=geometry_info.rho;
7470 if (LocaleCompare(
"precision",option+1) == 0)
7472 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7479 if (LocaleCompare(
"quality",option+1) == 0)
7486 image_info->quality=UndefinedCompressionQuality;
7487 (void) SetImageOption(image_info,option+1,
"0");
7490 image_info->quality=StringToUnsignedLong(argv[i+1]);
7491 (void) SetImageOption(image_info,option+1,argv[i+1]);
7494 if (LocaleCompare(
"quiet",option+1) == 0)
7496 static WarningHandler
7497 warning_handler = (WarningHandler) NULL;
7504 warning_handler=SetWarningHandler(warning_handler);
7510 warning_handler=SetWarningHandler((WarningHandler) NULL);
7517 if (LocaleCompare(
"red-primary",option+1) == 0)
7521 (void) SetImageOption(image_info,option+1,
"0.0");
7524 (void) SetImageOption(image_info,option+1,argv[i+1]);
7531 if (LocaleCompare(
"sampling-factor",option+1) == 0)
7538 if (image_info->sampling_factor != (
char *) NULL)
7539 image_info->sampling_factor=DestroyString(
7540 image_info->sampling_factor);
7543 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7546 if (LocaleCompare(
"scene",option+1) == 0)
7553 image_info->scene=0;
7554 (void) SetImageOption(image_info,option+1,
"0");
7557 image_info->scene=StringToUnsignedLong(argv[i+1]);
7558 (void) SetImageOption(image_info,option+1,argv[i+1]);
7561 if (LocaleCompare(
"seed",option+1) == 0)
7568 seed=(
unsigned long) time((time_t *) NULL);
7569 SetRandomSecretKey(seed);
7572 seed=StringToUnsignedLong(argv[i+1]);
7573 SetRandomSecretKey(seed);
7576 if (LocaleCompare(
"size",option+1) == 0)
7580 if (image_info->size != (
char *) NULL)
7581 image_info->size=DestroyString(image_info->size);
7584 (void) CloneString(&image_info->size,argv[i+1]);
7587 if (LocaleCompare(
"stroke",option+1) == 0)
7591 (void) SetImageOption(image_info,option+1,
"none");
7594 (void) SetImageOption(image_info,option+1,argv[i+1]);
7597 if (LocaleCompare(
"strokewidth",option+1) == 0)
7600 (void) SetImageOption(image_info,option+1,
"0");
7602 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7605 if (LocaleCompare(
"style",option+1) == 0)
7609 (void) SetImageOption(image_info,option+1,
"none");
7612 (void) SetImageOption(image_info,option+1,argv[i+1]);
7615 if (LocaleCompare(
"synchronize",option+1) == 0)
7619 image_info->synchronize=MagickFalse;
7622 image_info->synchronize=MagickTrue;
7629 if (LocaleCompare(
"taint",option+1) == 0)
7633 (void) SetImageOption(image_info,option+1,
"false");
7636 (void) SetImageOption(image_info,option+1,
"true");
7639 if (LocaleCompare(
"texture",option+1) == 0)
7643 if (image_info->texture != (
char *) NULL)
7644 image_info->texture=DestroyString(image_info->texture);
7647 (void) CloneString(&image_info->texture,argv[i+1]);
7650 if (LocaleCompare(
"tile-offset",option+1) == 0)
7653 (void) SetImageOption(image_info,option+1,
"0");
7655 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7658 if (LocaleCompare(
"transparent-color",option+1) == 0)
7662 (void) QueryColorCompliance(
"none",AllCompliance,
7663 &image_info->transparent_color,exception);
7664 (void) SetImageOption(image_info,option+1,
"none");
7667 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7668 &image_info->transparent_color,exception);
7669 (void) SetImageOption(image_info,option+1,argv[i+1]);
7672 if (LocaleCompare(
"type",option+1) == 0)
7676 image_info->type=UndefinedType;
7677 (void) SetImageOption(image_info,option+1,
"undefined");
7680 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7681 MagickFalse,argv[i+1]);
7682 (void) SetImageOption(image_info,option+1,argv[i+1]);
7689 if (LocaleCompare(
"undercolor",option+1) == 0)
7692 (void) DeleteImageOption(image_info,option+1);
7694 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7697 if (LocaleCompare(
"units",option+1) == 0)
7701 image_info->units=UndefinedResolution;
7702 (void) SetImageOption(image_info,option+1,
"undefined");
7705 image_info->units=(ResolutionType) ParseCommandOption(
7706 MagickResolutionOptions,MagickFalse,argv[i+1]);
7707 (void) SetImageOption(image_info,option+1,argv[i+1]);
7714 if (LocaleCompare(
"verbose",option+1) == 0)
7718 image_info->verbose=MagickFalse;
7721 image_info->verbose=MagickTrue;
7722 image_info->ping=MagickFalse;
7725 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
7728 (void) SetImageOption(image_info,option+1,
"undefined");
7730 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7737 if (LocaleCompare(
"weight",option+1) == 0)
7740 (void) SetImageOption(image_info,option+1,
"0");
7742 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7745 if (LocaleCompare(
"white-point",option+1) == 0)
7748 (void) SetImageOption(image_info,option+1,
"0.0");
7750 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7753 if (LocaleCompare(
"word-break",option+1) == 0)
7757 (void) SetImageOption(image_info,option+1,
"undefined");
7760 (void) SetImageOption(image_info,option+1,argv[i+1]);
7807WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7808 const int argc,
const char **argv,Image **images,ExceptionInfo *exception)
7819 PixelInterpolateMethod
7835 assert(image_info != (ImageInfo *) NULL);
7836 assert(image_info->signature == MagickCoreSignature);
7837 assert(images != (Image **) NULL);
7838 assert((*images)->previous == (Image *) NULL);
7839 assert((*images)->signature == MagickCoreSignature);
7840 if (IsEventLogging() != MagickFalse)
7841 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
7842 (*images)->filename);
7843 if ((argc <= 0) || (*argv == (
char *) NULL))
7845 interpolate_method=UndefinedInterpolatePixel;
7846 mogrify_info=CloneImageInfo(image_info);
7847 quantize_info=AcquireQuantizeInfo(mogrify_info);
7849 for (i=0; i < (ssize_t) argc; i++)
7851 if (*images == (Image *) NULL)
7854 if (IsCommandOption(option) == MagickFalse)
7856 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7857 count=MagickMax(count,0L);
7858 if ((i+count) >= (ssize_t) argc)
7860 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
7861 switch (*(option+1))
7865 if (LocaleCompare(
"affinity",option+1) == 0)
7867 (void) SyncImagesSettings(mogrify_info,*images,exception);
7870 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7877 if (LocaleCompare(
"append",option+1) == 0)
7882 (void) SyncImagesSettings(mogrify_info,*images,exception);
7883 append_image=AppendImages(*images,*option ==
'-' ? MagickTrue :
7884 MagickFalse,exception);
7885 if (append_image == (Image *) NULL)
7890 *images=DestroyImageList(*images);
7891 *images=append_image;
7894 if (LocaleCompare(
"average",option+1) == 0)
7902 (void) SyncImagesSettings(mogrify_info,*images,exception);
7903 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7905 if (average_image == (Image *) NULL)
7910 *images=DestroyImageList(*images);
7911 *images=average_image;
7918 if (LocaleCompare(
"channel-fx",option+1) == 0)
7923 (void) SyncImagesSettings(mogrify_info,*images,exception);
7924 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7925 if (channel_image == (Image *) NULL)
7930 *images=DestroyImageList(*images);
7931 *images=channel_image;
7934 if (LocaleCompare(
"clut",option+1) == 0)
7940 (void) SyncImagesSettings(mogrify_info,*images,exception);
7941 image=RemoveFirstImageFromList(images);
7942 clut_image=RemoveFirstImageFromList(images);
7943 if (clut_image == (Image *) NULL)
7945 (void) ThrowMagickException(exception,GetMagickModule(),
7946 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7947 image=DestroyImage(image);
7951 (void) ClutImage(image,clut_image,interpolate_method,exception);
7952 clut_image=DestroyImage(clut_image);
7953 *images=DestroyImageList(*images);
7957 if (LocaleCompare(
"coalesce",option+1) == 0)
7962 (void) SyncImagesSettings(mogrify_info,*images,exception);
7963 coalesce_image=CoalesceImages(*images,exception);
7964 if (coalesce_image == (Image *) NULL)
7969 *images=DestroyImageList(*images);
7970 *images=coalesce_image;
7973 if (LocaleCompare(
"combine",option+1) == 0)
7981 (void) SyncImagesSettings(mogrify_info,*images,exception);
7982 colorspace=(*images)->colorspace;
7983 if ((*images)->number_channels < GetImageListLength(*images))
7984 colorspace=sRGBColorspace;
7986 colorspace=(ColorspaceType) ParseCommandOption(
7987 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7988 combine_image=CombineImages(*images,colorspace,exception);
7989 if (combine_image == (Image *) NULL)
7994 *images=DestroyImageList(*images);
7995 *images=combine_image;
7998 if (LocaleCompare(
"compare",option+1) == 0)
8015 (void) SyncImagesSettings(mogrify_info,*images,exception);
8016 image=RemoveFirstImageFromList(images);
8017 reconstruct_image=RemoveFirstImageFromList(images);
8018 if (reconstruct_image == (Image *) NULL)
8020 (void) ThrowMagickException(exception,GetMagickModule(),
8021 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8022 image=DestroyImage(image);
8026 metric=UndefinedErrorMetric;
8027 option=GetImageOption(mogrify_info,
"metric");
8028 if (option != (
const char *) NULL)
8029 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
8030 MagickFalse,option);
8031 difference_image=CompareImages(image,reconstruct_image,metric,
8032 &distortion,exception);
8033 if (difference_image == (Image *) NULL)
8035 reconstruct_image=DestroyImage(reconstruct_image);
8036 image=DestroyImage(image);
8037 if (*images != (Image *) NULL)
8038 *images=DestroyImageList(*images);
8039 *images=difference_image;
8042 if (LocaleCompare(
"complex",option+1) == 0)
8050 (void) SyncImageSettings(mogrify_info,*images,exception);
8051 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
8052 MagickFalse,argv[i+1]);
8053 complex_images=ComplexImages(*images,op,exception);
8054 if (complex_images == (Image *) NULL)
8059 *images=DestroyImageList(*images);
8060 *images=complex_images;
8063 if (LocaleCompare(
"composite",option+1) == 0)
8083 (void) SyncImageSettings(mogrify_info,*images,exception);
8084 value=GetImageOption(mogrify_info,
"compose");
8085 if (value == (
const char *) NULL)
8086 compose=OverCompositeOp;
8088 compose=(CompositeOperator) ParseCommandOption(
8089 MagickComposeOptions,MagickFalse,value);
8092 clip_to_self=GetCompositeClipToSelf(compose);
8093 value=GetImageOption(mogrify_info,
"compose:clip-to-self");
8094 if (value != (
const char *) NULL)
8095 clip_to_self=IsStringTrue(value);
8096 value=GetImageOption(mogrify_info,
"compose:outside-overlay");
8097 if (value != (
const char *) NULL)
8098 clip_to_self=IsStringFalse(value);
8100 new_images=RemoveFirstImageFromList(images);
8101 source_image=RemoveFirstImageFromList(images);
8102 if (source_image == (Image *) NULL)
8104 (void) ThrowMagickException(exception,GetMagickModule(),
8105 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8106 new_images=DestroyImage(new_images);
8112 if (source_image->geometry != (
char *) NULL)
8117 (void) ParseRegionGeometry(source_image,source_image->geometry,
8118 &resize_geometry,exception);
8119 if ((source_image->columns != resize_geometry.width) ||
8120 (source_image->rows != resize_geometry.height))
8125 resize_image=ResizeImage(source_image,resize_geometry.width,
8126 resize_geometry.height,source_image->filter,exception);
8127 if (resize_image != (Image *) NULL)
8129 source_image=DestroyImage(source_image);
8130 source_image=resize_image;
8134 SetGeometry(source_image,&geometry);
8135 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
8136 GravityAdjustGeometry(new_images->columns,new_images->rows,
8137 new_images->gravity,&geometry);
8138 mask_image=RemoveFirstImageFromList(images);
8139 if (mask_image == (Image *) NULL)
8140 status&=(MagickStatusType) CompositeImage(new_images,source_image,
8141 compose,clip_to_self,geometry.x,geometry.y,exception);
8147 canvas_image=CloneImage(new_images,0,0,MagickTrue,exception);
8148 if (canvas_image == (Image *) NULL)
8152 case BlendCompositeOp:
8154 status&=(MagickStatusType) CompositeImage(new_images,
8155 source_image,compose,clip_to_self,geometry.x,geometry.y,
8157 status&=(MagickStatusType) CompositeImage(new_images,
8158 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8161 case DisplaceCompositeOp:
8162 case DistortCompositeOp:
8164 status&=(MagickStatusType) CompositeImage(source_image,
8165 mask_image,CopyGreenCompositeOp,MagickTrue,0,0,exception);
8166 (void) SetImageColorspace(source_image,sRGBColorspace,
8168 status&=(MagickStatusType) CompositeImage(new_images,
8169 source_image,compose,clip_to_self,geometry.x,geometry.y,
8173 case SaliencyBlendCompositeOp:
8174 case SeamlessBlendCompositeOp:
8176 status&=(MagickStatusType) CompositeImage(source_image,
8177 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8178 status&=(MagickStatusType) CompositeImage(new_images,
8179 source_image,compose,clip_to_self,geometry.x,geometry.y,
8188 clone_image=CloneImage(new_images,0,0,MagickTrue,exception);
8189 if (clone_image == (Image *) NULL)
8191 status&=(MagickStatusType) CompositeImage(new_images,
8192 source_image,compose,clip_to_self,geometry.x,geometry.y,
8194 status&=(MagickStatusType) CompositeImage(new_images,
8195 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8196 status&=(MagickStatusType) CompositeImage(clone_image,
8197 new_images,OverCompositeOp,clip_to_self,0,0,exception);
8198 new_images=DestroyImageList(new_images);
8199 new_images=clone_image;
8205 case DisplaceCompositeOp:
8206 case DistortCompositeOp:
8208 status&=(MagickStatusType) CompositeImage(canvas_image,
8209 new_images,CopyCompositeOp,clip_to_self,0,0,exception);
8214 status&=(MagickStatusType) CompositeImage(canvas_image,
8215 new_images,OverCompositeOp,clip_to_self,0,0,exception);
8219 new_images=DestroyImageList(new_images);
8220 new_images=canvas_image;
8221 mask_image=DestroyImage(mask_image);
8223 source_image=DestroyImage(source_image);
8224 *images=DestroyImageList(*images);
8228 if (LocaleCompare(
"copy",option+1) == 0)
8242 (void) SyncImageSettings(mogrify_info,*images,exception);
8243 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8244 offset.x=geometry.x;
8245 offset.y=geometry.y;
8246 source_image=(*images);
8247 if (source_image->next != (Image *) NULL)
8248 source_image=source_image->next;
8249 (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8251 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8259 if (LocaleCompare(
"deconstruct",option+1) == 0)
8264 (void) SyncImagesSettings(mogrify_info,*images,exception);
8265 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
8267 if (deconstruct_image == (Image *) NULL)
8272 *images=DestroyImageList(*images);
8273 *images=deconstruct_image;
8276 if (LocaleCompare(
"delete",option+1) == 0)
8279 DeleteImages(images,
"-1",exception);
8281 DeleteImages(images,argv[i+1],exception);
8284 if (LocaleCompare(
"dither",option+1) == 0)
8288 quantize_info->dither_method=NoDitherMethod;
8291 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8292 MagickDitherOptions,MagickFalse,argv[i+1]);
8295 if (LocaleCompare(
"duplicate",option+1) == 0)
8301 duplicate_images=DuplicateImages(*images,1,
"-1",exception);
8310 number_duplicates=(size_t) StringToLong(argv[i+1]);
8311 p=strchr(argv[i+1],
',');
8312 if (p == (
const char *) NULL)
8313 duplicate_images=DuplicateImages(*images,number_duplicates,
8316 duplicate_images=DuplicateImages(*images,number_duplicates,
8319 AppendImageToList(images, duplicate_images);
8320 (void) SyncImagesSettings(mogrify_info,*images,exception);
8327 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
8332 MagickEvaluateOperator
8335 (void) SyncImageSettings(mogrify_info,*images,exception);
8336 op=(MagickEvaluateOperator) ParseCommandOption(
8337 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8338 evaluate_image=EvaluateImages(*images,op,exception);
8339 if (evaluate_image == (Image *) NULL)
8344 *images=DestroyImageList(*images);
8345 *images=evaluate_image;
8352 if (LocaleCompare(
"fft",option+1) == 0)
8360 (void) SyncImageSettings(mogrify_info,*images,exception);
8361 fourier_image=ForwardFourierTransformImage(*images,*option ==
'-' ?
8362 MagickTrue : MagickFalse,exception);
8363 if (fourier_image == (Image *) NULL)
8365 *images=DestroyImageList(*images);
8366 *images=fourier_image;
8369 if (LocaleCompare(
"flatten",option+1) == 0)
8374 (void) SyncImagesSettings(mogrify_info,*images,exception);
8375 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8376 if (flatten_image == (Image *) NULL)
8378 *images=DestroyImageList(*images);
8379 *images=flatten_image;
8382 if (LocaleCompare(
"fx",option+1) == 0)
8387 (void) SyncImagesSettings(mogrify_info,*images,exception);
8388 fx_image=FxImage(*images,argv[i+1],exception);
8389 if (fx_image == (Image *) NULL)
8394 *images=DestroyImageList(*images);
8402 if (LocaleCompare(
"hald-clut",option+1) == 0)
8408 (void) SyncImagesSettings(mogrify_info,*images,exception);
8409 image=RemoveFirstImageFromList(images);
8410 hald_image=RemoveFirstImageFromList(images);
8411 if (hald_image == (Image *) NULL)
8413 (void) ThrowMagickException(exception,GetMagickModule(),
8414 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8415 image=DestroyImage(image);
8419 (void) HaldClutImage(image,hald_image,exception);
8420 hald_image=DestroyImage(hald_image);
8421 if (*images != (Image *) NULL)
8422 *images=DestroyImageList(*images);
8430 if (LocaleCompare(
"ift",option+1) == 0)
8440 (void) SyncImagesSettings(mogrify_info,*images,exception);
8441 magnitude_image=RemoveFirstImageFromList(images);
8442 phase_image=RemoveFirstImageFromList(images);
8443 if (phase_image == (Image *) NULL)
8445 (void) ThrowMagickException(exception,GetMagickModule(),
8446 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8447 magnitude_image=DestroyImage(magnitude_image);
8451 fourier_image=InverseFourierTransformImage(magnitude_image,
8452 phase_image,*option ==
'-' ? MagickTrue : MagickFalse,exception);
8453 magnitude_image=DestroyImage(magnitude_image);
8454 phase_image=DestroyImage(phase_image);
8455 if (fourier_image == (Image *) NULL)
8457 if (*images != (Image *) NULL)
8458 *images=DestroyImageList(*images);
8459 *images=fourier_image;
8462 if (LocaleCompare(
"insert",option+1) == 0)
8470 index=(ssize_t) StringToLong(argv[i+1]);
8471 p=RemoveLastImageFromList(images);
8472 if (p == (Image *) NULL)
8474 (void) ThrowMagickException(exception,GetMagickModule(),
8475 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8481 PrependImageToList(images,q);
8483 if (index == (ssize_t) GetImageListLength(*images))
8484 AppendImageToList(images,q);
8487 q=GetImageFromList(*images,index-1);
8488 if (q == (Image *) NULL)
8491 (void) ThrowMagickException(exception,GetMagickModule(),
8492 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8496 InsertImageInList(&q,p);
8498 *images=GetFirstImageInList(q);
8501 if (LocaleCompare(
"interpolate",option+1) == 0)
8503 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8504 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8511 if (LocaleCompare(
"layers",option+1) == 0)
8519 (void) SyncImagesSettings(mogrify_info,*images,exception);
8520 layers=(Image *) NULL;
8521 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8522 MagickFalse,argv[i+1]);
8527 layers=CoalesceImages(*images,exception);
8530 case CompareAnyLayer:
8531 case CompareClearLayer:
8532 case CompareOverlayLayer:
8535 layers=CompareImagesLayers(*images,method,exception);
8541 case TrimBoundsLayer:
8543 layers=MergeImageLayers(*images,method,exception);
8548 layers=DisposeImages(*images,exception);
8551 case OptimizeImageLayer:
8553 layers=OptimizeImageLayers(*images,exception);
8556 case OptimizePlusLayer:
8558 layers=OptimizePlusImageLayers(*images,exception);
8561 case OptimizeTransLayer:
8563 OptimizeImageTransparency(*images,exception);
8566 case RemoveDupsLayer:
8568 RemoveDuplicateLayers(images,exception);
8571 case RemoveZeroLayer:
8573 RemoveZeroDelayLayers(images,exception);
8581 layers=CoalesceImages(*images,exception);
8582 if (layers == (Image *) NULL)
8587 *images=DestroyImageList(*images);
8589 layers=OptimizeImageLayers(*images,exception);
8590 if (layers == (Image *) NULL)
8595 *images=DestroyImageList(*images);
8597 layers=(Image *) NULL;
8598 OptimizeImageTransparency(*images,exception);
8599 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8603 case CompositeLayer:
8618 while (source != (Image *) NULL)
8620 source=GetNextImageInList(source);
8621 if ((source != (Image *) NULL) &&
8622 (LocaleCompare(source->magick,
"NULL") == 0))
8625 if (source != (Image *) NULL)
8627 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8628 (GetNextImageInList(source) == (Image *) NULL))
8629 source=(Image *) NULL;
8635 source=SplitImageList(source->previous);
8636 DeleteImageFromList(&source);
8639 if (source == (Image *) NULL)
8641 (void) ThrowMagickException(exception,GetMagickModule(),
8642 OptionError,
"MissingNullSeparator",
"layers Composite");
8649 SetGeometry(*images,&geometry);
8650 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8651 geometry.width=source->page.width != 0 ?
8652 source->page.width : source->columns;
8653 geometry.height=source->page.height != 0 ?
8654 source->page.height : source->rows;
8655 GravityAdjustGeometry((*images)->page.width != 0 ?
8656 (*images)->page.width : (*images)->columns,
8657 (*images)->page.height != 0 ? (*images)->page.height :
8658 (*images)->rows,(*images)->gravity,&geometry);
8659 compose=OverCompositeOp;
8660 option=GetImageOption(mogrify_info,
"compose");
8661 if (option != (
const char *) NULL)
8662 compose=(CompositeOperator) ParseCommandOption(
8663 MagickComposeOptions,MagickFalse,option);
8664 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8666 source=DestroyImageList(source);
8670 if (layers == (Image *) NULL)
8672 *images=DestroyImageList(*images);
8680 if (LocaleCompare(
"map",option+1) == 0)
8682 (void) SyncImagesSettings(mogrify_info,*images,exception);
8685 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8692 if (LocaleCompare(
"maximum",option+1) == 0)
8700 (void) SyncImagesSettings(mogrify_info,*images,exception);
8701 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8702 if (maximum_image == (Image *) NULL)
8707 *images=DestroyImageList(*images);
8708 *images=maximum_image;
8711 if (LocaleCompare(
"minimum",option+1) == 0)
8719 (void) SyncImagesSettings(mogrify_info,*images,exception);
8720 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8721 if (minimum_image == (Image *) NULL)
8726 *images=DestroyImageList(*images);
8727 *images=minimum_image;
8730 if (LocaleCompare(
"morph",option+1) == 0)
8735 (void) SyncImagesSettings(mogrify_info,*images,exception);
8736 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8738 if (morph_image == (Image *) NULL)
8743 *images=DestroyImageList(*images);
8744 *images=morph_image;
8747 if (LocaleCompare(
"mosaic",option+1) == 0)
8752 (void) SyncImagesSettings(mogrify_info,*images,exception);
8753 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8754 if (mosaic_image == (Image *) NULL)
8759 *images=DestroyImageList(*images);
8760 *images=mosaic_image;
8767 if (LocaleCompare(
"poly",option+1) == 0)
8771 token[MagickPathExtent];
8791 (void) SyncImageSettings(mogrify_info,*images,exception);
8792 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8794 if (args == (
char *) NULL)
8797 for (x=0; *p !=
'\0'; x++)
8799 (void) GetNextToken(p,&p,MagickPathExtent,token);
8801 (void) GetNextToken(p,&p,MagickPathExtent,token);
8803 number_arguments=(size_t) x;
8804 arguments=(
double *) AcquireQuantumMemory(number_arguments,
8805 sizeof(*arguments));
8806 if (arguments == (
double *) NULL)
8807 ThrowWandFatalException(ResourceLimitFatalError,
8808 "MemoryAllocationFailed",(*images)->filename);
8809 (void) memset(arguments,0,number_arguments*
8810 sizeof(*arguments));
8812 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
8814 (void) GetNextToken(p,&p,MagickPathExtent,token);
8816 (void) GetNextToken(p,&p,MagickPathExtent,token);
8817 arguments[x]=StringToDouble(token,(
char **) NULL);
8819 args=DestroyString(args);
8820 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8821 arguments,exception);
8822 arguments=(
double *) RelinquishMagickMemory(arguments);
8823 if (polynomial_image == (Image *) NULL)
8828 *images=DestroyImageList(*images);
8829 *images=polynomial_image;
8831 if (LocaleCompare(
"print",option+1) == 0)
8836 (void) SyncImagesSettings(mogrify_info,*images,exception);
8837 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8839 if (
string == (
char *) NULL)
8841 (void) FormatLocaleFile(stdout,
"%s",
string);
8842 string=DestroyString(
string);
8844 if (LocaleCompare(
"process",option+1) == 0)
8846#define DestroyArguments(arguments,number_arguments) \
8850 for ( ; j < (ssize_t) (number_arguments); j++) \
8851 (arguments)[j]=DestroyString((arguments)[j]); \
8852 (arguments)=(char **) RelinquishMagickMemory(arguments); \
8861 (void) SyncImagesSettings(mogrify_info,*images,exception);
8862 arguments=StringToArgv(argv[i+1],&number_arguments);
8863 if ((arguments == (
char **) NULL) || (number_arguments == 1))
8865 DestroyArguments(arguments,number_arguments);
8868 if ((argc > 1) && (strchr(arguments[1],
'=') != (
char *) NULL))
8891 length=strlen(argv[i+1]);
8892 token=(
char *) NULL;
8893 if (~length >= (MagickPathExtent-1))
8894 token=(
char *) AcquireQuantumMemory(length+MagickPathExtent,
8896 if (token == (
char *) NULL)
8898 DestroyArguments(arguments,number_arguments);
8903 token_info=AcquireTokenInfo();
8904 token_status=Tokenizer(token_info,0,token,length,argument,
"",
8905 "=",
"\"",
'\0',&breaker,&next,"e);
8906 token_info=DestroyTokenInfo(token_info);
8907 if (token_status == 0)
8912 arg=(&(argument[next]));
8913 (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
8916 token=DestroyString(token);
8917 DestroyArguments(arguments,number_arguments);
8920 (void) SubstituteString(&arguments[1],
"-",
"");
8921 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8922 number_arguments-2,(
const char **) arguments+2,exception);
8923 DestroyArguments(arguments,number_arguments);
8930 if (LocaleCompare(
"reverse",option+1) == 0)
8932 ReverseImageList(images);
8939 if (LocaleCompare(
"smush",option+1) == 0)
8947 (void) SyncImagesSettings(mogrify_info,*images,exception);
8948 offset=(ssize_t) StringToLong(argv[i+1]);
8949 smush_image=SmushImages(*images,*option ==
'-' ? MagickTrue :
8950 MagickFalse,offset,exception);
8951 if (smush_image == (Image *) NULL)
8956 *images=DestroyImageList(*images);
8957 *images=smush_image;
8960 if (LocaleCompare(
"swap",option+1) == 0)
8982 flags=ParseGeometry(argv[i+1],&geometry_info);
8983 index=(ssize_t) geometry_info.rho;
8984 if ((flags & SigmaValue) != 0)
8985 swap_index=(ssize_t) geometry_info.sigma;
8987 p=GetImageFromList(*images,index);
8988 q=GetImageFromList(*images,swap_index);
8989 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8991 (void) ThrowMagickException(exception,GetMagickModule(),
8992 OptionError,
"NoSuchImage",
"`%s'",(*images)->filename);
8998 u=CloneImage(p,0,0,MagickTrue,exception);
8999 if (u == (Image *) NULL)
9001 v=CloneImage(q,0,0,MagickTrue,exception);
9002 if (v == (Image *) NULL)
9007 ReplaceImageInList(&p,v);
9008 ReplaceImageInList(&q,u);
9009 *images=GetFirstImageInList(q);
9016 if (LocaleCompare(
"write",option+1) == 0)
9019 key[MagickPathExtent];
9027 (void) SyncImagesSettings(mogrify_info,*images,exception);
9028 (void) FormatLocaleString(key,MagickPathExtent,
"cache:%s",
9030 (void) DeleteImageRegistry(key);
9031 write_images=CloneImageList(*images,exception);
9032 write_info=CloneImageInfo(mogrify_info);
9033 status&=(MagickStatusType) WriteImages(write_info,write_images,
9034 argv[i+1],exception);
9035 write_info=DestroyImageInfo(write_info);
9036 write_images=DestroyImageList(write_images);
9046 quantize_info=DestroyQuantizeInfo(quantize_info);
9047 mogrify_info=DestroyImageInfo(mogrify_info);
9048 status&=(MagickStatusType) MogrifyImageInfo(image_info,argc,argv,exception);
9049 return(status != 0 ? MagickTrue : MagickFalse);
9089WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
9090 const MagickBooleanType post,
const int argc,
const char **argv,
9091 Image **images,ExceptionInfo *exception)
9093#define MogrifyImageTag "Mogrify/Image"
9107 assert(image_info != (ImageInfo *) NULL);
9108 assert(image_info->signature == MagickCoreSignature);
9109 if (images == (Image **) NULL)
9110 return(MogrifyImage(image_info,argc,argv,images,exception));
9111 assert((*images)->previous == (Image *) NULL);
9112 assert((*images)->signature == MagickCoreSignature);
9113 if (IsEventLogging() != MagickFalse)
9114 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
9115 (*images)->filename);
9116 if ((argc <= 0) || (*argv == (
char *) NULL))
9118 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
9122 (void) FormatLocaleFile(stderr,
"mogrify start %s %d (%s)\n",argv[0],argc,
9128 if (post == MagickFalse)
9129 status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9135 n=GetImageListLength(*images);
9139 (void) FormatLocaleFile(stderr,
"mogrify %ld of %ld\n",(
long)
9140 GetImageIndexInList(*images),(
long)GetImageListLength(*images));
9142 status&=(MagickStatusType) MogrifyImage(image_info,argc,argv,images,
9144 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
9145 if (proceed == MagickFalse)
9147 if ( (*images)->next == (Image *) NULL )
9149 *images=(*images)->next;
9152 assert( *images != (Image *) NULL );
9154 (void) FormatLocaleFile(stderr,
"mogrify end %ld of %ld\n",(
long)
9155 GetImageIndexInList(*images),(
long)GetImageListLength(*images));
9160 *images=GetFirstImageInList(*images);
9161 if (post != MagickFalse)
9162 status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9164 return(status != 0 ? MagickTrue : MagickFalse);