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 | O_BINARY | O_NOFOLLOW,S_MODE);
3937 if ((file >= 0) || (errno != EEXIST))
3940 random_info=DestroyRandomInfo(random_info);
3942 *backup_filename=
'\0';
3944 file=close_utf8(file)-1;
3949 image_info->synchronize=MagickTrue;
3951 Image *clone_image = CloneImageList(image,exception);
3952 if (clone_image != (Image *) NULL)
3955 output_filename[MagickPathExtent];
3957 *output_filename=
'\0';
3958 if (*backup_filename !=
'\0')
3963 if (*clone_image->magick ==
'\0')
3964 (void) CopyMagickString(clone_image->magick,
3965 image_info->magick,MaxTextExtent);
3966 output_format=(format != (
char *) NULL) ? format :
3967 clone_image->magick;
3968 if ((*magic !=
'\0') || (*output_format ==
'\0'))
3969 (void) CopyMagickString(output_filename,backup_filename,
3972 (
void) FormatLocaleString(output_filename,MagickPathExtent,
3973 "%s:%s",output_format,backup_filename);
3975 status&=(MagickStatusType) WriteImages(image_info,clone_image,
3976 (*output_filename !=
'\0') ? output_filename :
3977 clone_image->filename,exception);
3978 clone_image=DestroyImageList(clone_image);
3981 if (status != MagickFalse)
3987 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3988 "preserve-timestamp"));
3989 if (preserve_timestamp != MagickFalse)
3990 (void) set_file_timestamp(image->filename,&properties);
3992 if (*backup_filename !=
'\0')
3994 if (rename_utf8(backup_filename,image->filename) != 0)
3999 if (*backup_filename !=
'\0')
4000 (void) remove_utf8(backup_filename);
4001 RemoveAllImageStack();
4004 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4005 switch (*(option+1))
4009 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
4012 if (i == (ssize_t) argc)
4013 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4014 if (IsGeometry(argv[i]) == MagickFalse)
4015 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4018 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
4021 if (i == (ssize_t) argc)
4022 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4023 if (IsGeometry(argv[i]) == MagickFalse)
4024 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4027 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
4030 if (i == (ssize_t) argc)
4031 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4032 if (IsGeometry(argv[i]) == MagickFalse)
4033 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4036 if (LocaleCompare(
"affine",option+1) == 0)
4041 if (i == (ssize_t) argc)
4042 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4045 if (LocaleCompare(
"alpha",option+1) == 0)
4053 if (i == (ssize_t) argc)
4054 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4055 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
4058 ThrowMogrifyException(OptionError,
4059 "UnrecognizedAlphaChannelOption",argv[i]);
4062 if (LocaleCompare(
"annotate",option+1) == 0)
4067 if (i == (ssize_t) argc)
4068 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4069 if (IsGeometry(argv[i]) == MagickFalse)
4070 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4071 if (i == (ssize_t) argc)
4072 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4076 if (LocaleCompare(
"antialias",option+1) == 0)
4078 if (LocaleCompare(
"append",option+1) == 0)
4080 if (LocaleCompare(
"attenuate",option+1) == 0)
4085 if (i == (ssize_t) argc)
4086 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4087 if (IsGeometry(argv[i]) == MagickFalse)
4088 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4091 if (LocaleCompare(
"authenticate",option+1) == 0)
4096 if (i == (ssize_t) argc)
4097 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4100 if (LocaleCompare(
"auto-gamma",option+1) == 0)
4102 if (LocaleCompare(
"auto-level",option+1) == 0)
4104 if (LocaleCompare(
"auto-orient",option+1) == 0)
4106 if (LocaleCompare(
"auto-threshold",option+1) == 0)
4114 if (i == (ssize_t) argc)
4115 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4116 method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
4119 ThrowMogrifyException(OptionError,
"UnrecognizedThresholdMethod",
4123 if (LocaleCompare(
"average",option+1) == 0)
4125 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4129 if (LocaleCompare(
"background",option+1) == 0)
4134 if (i == (ssize_t) argc)
4135 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4138 if (LocaleCompare(
"bias",option+1) == 0)
4143 if (i == (ssize_t) argc)
4144 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4145 if (IsGeometry(argv[i]) == MagickFalse)
4146 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4149 if (LocaleCompare(
"bilateral-blur",option+1) == 0)
4154 if (i == (ssize_t) argc)
4155 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4156 if (IsGeometry(argv[i]) == MagickFalse)
4157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4160 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
4162 if (LocaleCompare(
"black-threshold",option+1) == 0)
4167 if (i == (ssize_t) argc)
4168 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4169 if (IsGeometry(argv[i]) == MagickFalse)
4170 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4173 if (LocaleCompare(
"blue-primary",option+1) == 0)
4178 if (i == (ssize_t) argc)
4179 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4180 if (IsGeometry(argv[i]) == MagickFalse)
4181 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4184 if (LocaleCompare(
"blue-shift",option+1) == 0)
4187 if (i == (ssize_t) argc)
4188 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4189 if (IsGeometry(argv[i]) == MagickFalse)
4190 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4193 if (LocaleCompare(
"blur",option+1) == 0)
4196 if (i == (ssize_t) argc)
4197 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4198 if (IsGeometry(argv[i]) == MagickFalse)
4199 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4202 if (LocaleCompare(
"border",option+1) == 0)
4207 if (i == (ssize_t) argc)
4208 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4209 if (IsGeometry(argv[i]) == MagickFalse)
4210 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4213 if (LocaleCompare(
"bordercolor",option+1) == 0)
4218 if (i == (ssize_t) argc)
4219 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4222 if (LocaleCompare(
"box",option+1) == 0)
4227 if (i == (ssize_t) argc)
4228 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4231 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
4234 if (i == (ssize_t) argc)
4235 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4236 if (IsGeometry(argv[i]) == MagickFalse)
4237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4240 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4244 if (LocaleCompare(
"cache",option+1) == 0)
4249 if (i == (ssize_t) argc)
4250 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4251 if (IsGeometry(argv[i]) == MagickFalse)
4252 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4255 if (LocaleCompare(
"canny",option+1) == 0)
4260 if (i == (ssize_t) argc)
4261 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4262 if (IsGeometry(argv[i]) == MagickFalse)
4263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4266 if (LocaleCompare(
"caption",option+1) == 0)
4271 if (i == (ssize_t) argc)
4272 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4275 if (LocaleCompare(
"channel",option+1) == 0)
4283 if (i == (ssize_t) argc)
4284 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4285 channel=ParseChannelOption(argv[i]);
4287 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4291 if (LocaleCompare(
"channel-fx",option+1) == 0)
4299 if (i == (ssize_t) argc)
4300 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4301 channel=ParsePixelChannelOption(argv[i]);
4303 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4307 if (LocaleCompare(
"cdl",option+1) == 0)
4312 if (i == (ssize_t) argc)
4313 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4316 if (LocaleCompare(
"charcoal",option+1) == 0)
4321 if (i == (ssize_t) argc)
4322 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4323 if (IsGeometry(argv[i]) == MagickFalse)
4324 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4327 if (LocaleCompare(
"chop",option+1) == 0)
4332 if (i == (ssize_t) argc)
4333 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4334 if (IsGeometry(argv[i]) == MagickFalse)
4335 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4338 if (LocaleCompare(
"clahe",option+1) == 0)
4343 if (i == (ssize_t) argc)
4344 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4345 if (IsGeometry(argv[i]) == MagickFalse)
4346 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4349 if (LocaleCompare(
"clamp",option+1) == 0)
4351 if (LocaleCompare(
"clip",option+1) == 0)
4353 if (LocaleCompare(
"clip-mask",option+1) == 0)
4358 if (i == (ssize_t) argc)
4359 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4362 if (LocaleCompare(
"clut",option+1) == 0)
4364 if (LocaleCompare(
"coalesce",option+1) == 0)
4366 if (LocaleCompare(
"colorize",option+1) == 0)
4371 if (i == (ssize_t) argc)
4372 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4373 if (IsGeometry(argv[i]) == MagickFalse)
4374 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4377 if (LocaleCompare(
"color-matrix",option+1) == 0)
4385 if (i == (ssize_t) argc)
4386 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4387 kernel_info=AcquireKernelInfo(argv[i],exception);
4388 if (kernel_info == (KernelInfo *) NULL)
4389 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4390 kernel_info=DestroyKernelInfo(kernel_info);
4393 if (LocaleCompare(
"colors",option+1) == 0)
4398 if (i == (ssize_t) argc)
4399 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4400 if (IsGeometry(argv[i]) == MagickFalse)
4401 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4404 if (LocaleCompare(
"colorspace",option+1) == 0)
4412 if (i == (ssize_t) argc)
4413 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4414 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4417 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4421 if (LocaleCompare(
"color-threshold",option+1) == 0)
4426 if (i == (ssize_t) argc)
4427 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4430 if (LocaleCompare(
"combine",option+1) == 0)
4438 if (i == (ssize_t) argc)
4439 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4440 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4443 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4447 if (LocaleCompare(
"comment",option+1) == 0)
4452 if (i == (ssize_t) argc)
4453 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4456 if (LocaleCompare(
"compare",option+1) == 0)
4458 if (LocaleCompare(
"compose",option+1) == 0)
4466 if (i == (ssize_t) argc)
4467 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4468 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4471 ThrowMogrifyException(OptionError,
"UnrecognizedComposeOperator",
4475 if (LocaleCompare(
"composite",option+1) == 0)
4477 if (LocaleCompare(
"compress",option+1) == 0)
4485 if (i == (ssize_t) argc)
4486 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4487 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4490 ThrowMogrifyException(OptionError,
"UnrecognizedImageCompression",
4494 if (LocaleCompare(
"concurrent",option+1) == 0)
4496 if (LocaleCompare(
"connected-components",option+1) == 0)
4499 if (i == (ssize_t) argc)
4500 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4501 if (IsGeometry(argv[i]) == MagickFalse)
4502 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4505 if (LocaleCompare(
"contrast",option+1) == 0)
4507 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
4510 if (i == (ssize_t) argc)
4511 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4512 if (IsGeometry(argv[i]) == MagickFalse)
4513 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4516 if (LocaleCompare(
"convolve",option+1) == 0)
4524 if (i == (ssize_t) argc)
4525 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4526 kernel_info=AcquireKernelInfo(argv[i],exception);
4527 if (kernel_info == (KernelInfo *) NULL)
4528 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4529 kernel_info=DestroyKernelInfo(kernel_info);
4532 if (LocaleCompare(
"copy",option+1) == 0)
4537 if (i == (ssize_t) argc)
4538 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4539 if (IsGeometry(argv[i]) == MagickFalse)
4540 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4542 if (i == (ssize_t) argc)
4543 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4544 if (IsGeometry(argv[i]) == MagickFalse)
4545 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4548 if (LocaleCompare(
"crop",option+1) == 0)
4553 if (i == (ssize_t) argc)
4554 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4555 if (IsGeometry(argv[i]) == MagickFalse)
4556 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4559 if (LocaleCompare(
"cycle",option+1) == 0)
4564 if (i == (ssize_t) argc)
4565 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4566 if (IsGeometry(argv[i]) == MagickFalse)
4567 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4570 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4574 if (LocaleCompare(
"decipher",option+1) == 0)
4579 if (i == (ssize_t) argc)
4580 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4583 if (LocaleCompare(
"deconstruct",option+1) == 0)
4585 if (LocaleCompare(
"debug",option+1) == 0)
4593 if (i == (ssize_t) argc)
4594 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4595 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4597 ThrowMogrifyException(OptionError,
"UnrecognizedEventType",
4599 (void) SetLogEventMask(argv[i]);
4602 if (LocaleCompare(
"define",option+1) == 0)
4605 if (i == (ssize_t) argc)
4606 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4612 define=GetImageOption(image_info,argv[i]);
4613 if (define == (
const char *) NULL)
4614 ThrowMogrifyException(OptionError,
"NoSuchOption",argv[i]);
4619 if (LocaleCompare(
"delay",option+1) == 0)
4624 if (i == (ssize_t) argc)
4625 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4626 if (IsGeometry(argv[i]) == MagickFalse)
4627 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4630 if (LocaleCompare(
"delete",option+1) == 0)
4635 if (i == (ssize_t) argc)
4636 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4637 if (LocaleNCompare(argv[i],
"registry:",9) == 0)
4639 (void) DeleteImageRegistry(argv[i]+9);
4642 if (IsGeometry(argv[i]) == MagickFalse)
4643 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4646 if (LocaleCompare(
"density",option+1) == 0)
4651 if (i == (ssize_t) argc)
4652 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4653 if (IsGeometry(argv[i]) == MagickFalse)
4654 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4657 if (LocaleCompare(
"depth",option+1) == 0)
4662 if (i == (ssize_t) argc)
4663 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4664 if (IsGeometry(argv[i]) == MagickFalse)
4665 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4668 if (LocaleCompare(
"deskew",option+1) == 0)
4673 if (i == (ssize_t) argc)
4674 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4675 if (IsGeometry(argv[i]) == MagickFalse)
4676 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4679 if (LocaleCompare(
"despeckle",option+1) == 0)
4681 if (LocaleCompare(
"dft",option+1) == 0)
4683 if (LocaleCompare(
"direction",option+1) == 0)
4691 if (i == (ssize_t) argc)
4692 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4693 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4696 ThrowMogrifyException(OptionError,
"UnrecognizedDirectionType",
4700 if (LocaleCompare(
"display",option+1) == 0)
4705 if (i == (ssize_t) argc)
4706 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4709 if (LocaleCompare(
"dispose",option+1) == 0)
4717 if (i == (ssize_t) argc)
4718 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4719 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4722 ThrowMogrifyException(OptionError,
"UnrecognizedDisposeMethod",
4726 if (LocaleCompare(
"distort",option+1) == 0)
4732 if (i == (ssize_t) argc)
4733 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4734 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4736 ThrowMogrifyException(OptionError,
"UnrecognizedDistortMethod",
4739 if (i == (ssize_t) argc)
4740 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4743 if (LocaleCompare(
"dither",option+1) == 0)
4751 if (i == (ssize_t) argc)
4752 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4753 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4755 ThrowMogrifyException(OptionError,
"UnrecognizedDitherMethod",
4759 if (LocaleCompare(
"draw",option+1) == 0)
4764 if (i == (ssize_t) argc)
4765 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4768 if (LocaleCompare(
"duplicate",option+1) == 0)
4773 if (i == (ssize_t) argc)
4774 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4775 if (IsGeometry(argv[i]) == MagickFalse)
4776 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4779 if (LocaleCompare(
"duration",option+1) == 0)
4784 if (i == (ssize_t) argc)
4785 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4786 if (IsGeometry(argv[i]) == MagickFalse)
4787 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4790 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4794 if (LocaleCompare(
"edge",option+1) == 0)
4799 if (i == (ssize_t) argc)
4800 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4801 if (IsGeometry(argv[i]) == MagickFalse)
4802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4805 if (LocaleCompare(
"emboss",option+1) == 0)
4810 if (i == (ssize_t) argc)
4811 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4812 if (IsGeometry(argv[i]) == MagickFalse)
4813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4816 if (LocaleCompare(
"encipher",option+1) == 0)
4821 if (i == (ssize_t) argc)
4822 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4825 if (LocaleCompare(
"encoding",option+1) == 0)
4830 if (i == (ssize_t) argc)
4831 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4834 if (LocaleCompare(
"endian",option+1) == 0)
4842 if (i == (ssize_t) argc)
4843 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4844 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4846 ThrowMogrifyException(OptionError,
"UnrecognizedEndianType",
4850 if (LocaleCompare(
"enhance",option+1) == 0)
4852 if (LocaleCompare(
"equalize",option+1) == 0)
4854 if (LocaleCompare(
"evaluate",option+1) == 0)
4862 if (i == (ssize_t) argc)
4863 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4864 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4866 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4869 if (i == (ssize_t) argc)
4870 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4871 if (IsGeometry(argv[i]) == MagickFalse)
4872 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4875 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4883 if (i == (ssize_t) argc)
4884 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4885 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4887 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4891 if (LocaleCompare(
"extent",option+1) == 0)
4896 if (i == (ssize_t) argc)
4897 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4898 if (IsGeometry(argv[i]) == MagickFalse)
4899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4902 if (LocaleCompare(
"extract",option+1) == 0)
4907 if (i == (ssize_t) argc)
4908 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4909 if (IsGeometry(argv[i]) == MagickFalse)
4910 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4913 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4917 if (LocaleCompare(
"family",option+1) == 0)
4922 if (i == (ssize_t) argc)
4923 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4926 if (LocaleCompare(
"features",option+1) == 0)
4931 if (i == (ssize_t) argc)
4932 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4933 if (IsGeometry(argv[i]) == MagickFalse)
4934 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4937 if (LocaleCompare(
"fill",option+1) == 0)
4942 if (i == (ssize_t) argc)
4943 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4946 if (LocaleCompare(
"filter",option+1) == 0)
4954 if (i == (ssize_t) argc)
4955 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4956 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4958 ThrowMogrifyException(OptionError,
"UnrecognizedImageFilter",
4962 if (LocaleCompare(
"flatten",option+1) == 0)
4964 if (LocaleCompare(
"flip",option+1) == 0)
4966 if (LocaleCompare(
"flop",option+1) == 0)
4968 if (LocaleCompare(
"floodfill",option+1) == 0)
4973 if (i == (ssize_t) argc)
4974 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4975 if (IsGeometry(argv[i]) == MagickFalse)
4976 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4978 if (i == (ssize_t) argc)
4979 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4982 if (LocaleCompare(
"font",option+1) == 0)
4987 if (i == (ssize_t) argc)
4988 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4991 if (LocaleCompare(
"format",option+1) == 0)
4993 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
4994 (void) CloneString(&format,(
char *) NULL);
4998 if (i == (ssize_t) argc)
4999 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5000 (void) CloneString(&format,argv[i]);
5001 (void) CopyMagickString(image_info->filename,format,
5003 (void) ConcatenateMagickString(image_info->filename,
":",
5005 (void) SetImageInfo(image_info,0,exception);
5006 if (*image_info->magick ==
'\0')
5007 ThrowMogrifyException(OptionError,
"UnrecognizedImageFormat",
5011 if (LocaleCompare(
"frame",option+1) == 0)
5016 if (i == (ssize_t) argc)
5017 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5018 if (IsGeometry(argv[i]) == MagickFalse)
5019 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5022 if (LocaleCompare(
"function",option+1) == 0)
5030 if (i == (ssize_t) argc)
5031 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5032 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
5034 ThrowMogrifyException(OptionError,
"UnrecognizedFunction",argv[i]);
5036 if (i == (ssize_t) argc)
5037 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5040 if (LocaleCompare(
"fuzz",option+1) == 0)
5045 if (i == (ssize_t) argc)
5046 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5047 if (IsGeometry(argv[i]) == MagickFalse)
5048 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5051 if (LocaleCompare(
"fx",option+1) == 0)
5054 if (i == (ssize_t) argc)
5055 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5058 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5062 if (LocaleCompare(
"gamma",option+1) == 0)
5065 if (i == (ssize_t) argc)
5066 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5067 if (IsGeometry(argv[i]) == MagickFalse)
5068 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5071 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
5072 (LocaleCompare(
"gaussian",option+1) == 0))
5075 if (i == (ssize_t) argc)
5076 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5077 if (IsGeometry(argv[i]) == MagickFalse)
5078 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5081 if (LocaleCompare(
"geometry",option+1) == 0)
5086 if (i == (ssize_t) argc)
5087 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5088 if (IsGeometry(argv[i]) == MagickFalse)
5089 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5092 if (LocaleCompare(
"gravity",option+1) == 0)
5100 if (i == (ssize_t) argc)
5101 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5102 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5105 ThrowMogrifyException(OptionError,
"UnrecognizedGravityType",
5109 if (LocaleCompare(
"grayscale",option+1) == 0)
5117 if (i == (ssize_t) argc)
5118 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5119 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5122 ThrowMogrifyException(OptionError,
"UnrecognizedIntensityMethod",
5126 if (LocaleCompare(
"green-primary",option+1) == 0)
5131 if (i == (ssize_t) argc)
5132 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5133 if (IsGeometry(argv[i]) == MagickFalse)
5134 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5137 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5141 if (LocaleCompare(
"hald-clut",option+1) == 0)
5143 if ((LocaleCompare(
"help",option+1) == 0) ||
5144 (LocaleCompare(
"-help",option+1) == 0))
5147 return(MogrifyUsage());
5149 if (LocaleCompare(
"hough-lines",option+1) == 0)
5154 if (i == (ssize_t) argc)
5155 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5156 if (IsGeometry(argv[i]) == MagickFalse)
5157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5160 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5164 if (LocaleCompare(
"identify",option+1) == 0)
5166 if (LocaleCompare(
"idft",option+1) == 0)
5168 if (LocaleCompare(
"illuminant",option+1) == 0)
5176 if (i == (ssize_t) argc)
5177 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5178 type=ParseCommandOption(MagickIlluminantOptions,MagickFalse,
5181 ThrowMogrifyException(OptionError,
"UnrecognizedIlluminantMethod",
5185 if (LocaleCompare(
"implode",option+1) == 0)
5190 if (i == (ssize_t) argc)
5191 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5192 if (IsGeometry(argv[i]) == MagickFalse)
5193 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5196 if (LocaleCompare(
"intensity",option+1) == 0)
5204 if (i == (ssize_t) argc)
5205 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5206 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5207 MagickFalse,argv[i]);
5209 ThrowMogrifyException(OptionError,
5210 "UnrecognizedPixelIntensityMethod",argv[i]);
5213 if (LocaleCompare(
"integral",option+1) == 0)
5215 if (LocaleCompare(
"intent",option+1) == 0)
5223 if (i == (ssize_t) argc)
5224 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5225 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5227 ThrowMogrifyException(OptionError,
"UnrecognizedIntentType",
5231 if (LocaleCompare(
"interlace",option+1) == 0)
5239 if (i == (ssize_t) argc)
5240 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5241 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5244 ThrowMogrifyException(OptionError,
"UnrecognizedInterlaceType",
5248 if (LocaleCompare(
"interline-spacing",option+1) == 0)
5253 if (i == (ssize_t) argc)
5254 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5255 if (IsGeometry(argv[i]) == MagickFalse)
5256 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5259 if (LocaleCompare(
"interpolate",option+1) == 0)
5267 if (i == (ssize_t) argc)
5268 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5269 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5271 if (interpolate < 0)
5272 ThrowMogrifyException(OptionError,
"UnrecognizedInterpolateMethod",
5276 if (LocaleCompare(
"interword-spacing",option+1) == 0)
5281 if (i == (ssize_t) argc)
5282 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5283 if (IsGeometry(argv[i]) == MagickFalse)
5284 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5287 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5291 if (LocaleCompare(
"kerning",option+1) == 0)
5296 if (i == (ssize_t) argc)
5297 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5298 if (IsGeometry(argv[i]) == MagickFalse)
5299 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5302 if (LocaleCompare(
"kmeans",option+1) == 0)
5305 if (i == (ssize_t) argc)
5306 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5307 if (IsGeometry(argv[i]) == MagickFalse)
5308 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5311 if (LocaleCompare(
"kuwahara",option+1) == 0)
5314 if (i == (ssize_t) argc)
5315 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5316 if (IsGeometry(argv[i]) == MagickFalse)
5317 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5320 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5324 if (LocaleCompare(
"label",option+1) == 0)
5329 if (i == (ssize_t) argc)
5330 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5333 if (LocaleCompare(
"lat",option+1) == 0)
5338 if (i == (ssize_t) argc)
5339 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5340 if (IsGeometry(argv[i]) == MagickFalse)
5341 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5344 if (LocaleCompare(
"layers",option+1) == 0)
5352 if (i == (ssize_t) argc)
5353 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5354 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5356 ThrowMogrifyException(OptionError,
"UnrecognizedLayerMethod",
5360 if (LocaleCompare(
"level",option+1) == 0)
5363 if (i == (ssize_t) argc)
5364 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5365 if (IsGeometry(argv[i]) == MagickFalse)
5366 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5369 if (LocaleCompare(
"level-colors",option+1) == 0)
5372 if (i == (ssize_t) argc)
5373 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5376 if (LocaleCompare(
"limit",option+1) == 0)
5390 if (i == (ssize_t) argc)
5391 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5392 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5395 ThrowMogrifyException(OptionError,
"UnrecognizedResourceType",
5398 if (i == (ssize_t) argc)
5399 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5400 value=StringToDouble(argv[i],&p);
5402 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
5403 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5406 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
5409 if (i == (ssize_t) argc)
5410 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5411 if (IsGeometry(argv[i]) == MagickFalse)
5412 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5415 if (LocaleCompare(
"list",option+1) == 0)
5423 if (i == (ssize_t) argc)
5424 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5425 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5427 ThrowMogrifyException(OptionError,
"UnrecognizedListType",argv[i]);
5428 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
5430 return(status == 0 ? MagickFalse : MagickTrue);
5432 if (LocaleCompare(
"log",option+1) == 0)
5437 if ((i == (ssize_t) argc) ||
5438 (strchr(argv[i],
'%') == (
char *) NULL))
5439 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5442 if (LocaleCompare(
"loop",option+1) == 0)
5447 if (i == (ssize_t) argc)
5448 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5449 if (IsGeometry(argv[i]) == MagickFalse)
5450 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5453 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5457 if (LocaleCompare(
"magnify",option+1) == 0)
5459 if (LocaleCompare(
"map",option+1) == 0)
5461 global_colormap=(*option ==
'+') ? MagickTrue : MagickFalse;
5465 if (i == (ssize_t) argc)
5466 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5469 if (LocaleCompare(
"mask",option+1) == 0)
5474 if (i == (ssize_t) argc)
5475 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5478 if (LocaleCompare(
"matte",option+1) == 0)
5480 if (LocaleCompare(
"mattecolor",option+1) == 0)
5485 if (i == (ssize_t) argc)
5486 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5489 if (LocaleCompare(
"maximum",option+1) == 0)
5491 if (LocaleCompare(
"mean-shift",option+1) == 0)
5496 if (i == (ssize_t) argc)
5497 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5498 if (IsGeometry(argv[i]) == MagickFalse)
5499 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5502 if (LocaleCompare(
"median",option+1) == 0)
5507 if (i == (ssize_t) argc)
5508 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5509 if (IsGeometry(argv[i]) == MagickFalse)
5510 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5513 if (LocaleCompare(
"metric",option+1) == 0)
5521 if (i == (ssize_t) argc)
5522 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5523 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5525 ThrowMogrifyException(OptionError,
"UnrecognizedMetricType",
5529 if (LocaleCompare(
"minimum",option+1) == 0)
5531 if (LocaleCompare(
"modulate",option+1) == 0)
5536 if (i == (ssize_t) argc)
5537 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5538 if (IsGeometry(argv[i]) == MagickFalse)
5539 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5542 if (LocaleCompare(
"mode",option+1) == 0)
5547 if (i == (ssize_t) argc)
5548 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5549 if (IsGeometry(argv[i]) == MagickFalse)
5550 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5553 if (LocaleCompare(
"monitor",option+1) == 0)
5555 if (LocaleCompare(
"monochrome",option+1) == 0)
5557 if (LocaleCompare(
"morph",option+1) == 0)
5562 if (i == (ssize_t) argc)
5563 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5564 if (IsGeometry(argv[i]) == MagickFalse)
5565 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5568 if (LocaleCompare(
"morphology",option+1) == 0)
5571 token[MagickPathExtent];
5580 if (i == (ssize_t) argc)
5581 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5582 (void) GetNextToken(argv[i],(
const char **) NULL,MagickPathExtent,
5584 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5586 ThrowMogrifyException(OptionError,
"UnrecognizedMorphologyMethod",
5589 if (i == (ssize_t) argc)
5590 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5591 kernel_info=AcquireKernelInfo(argv[i],exception);
5592 if (kernel_info == (KernelInfo *) NULL)
5593 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5594 kernel_info=DestroyKernelInfo(kernel_info);
5597 if (LocaleCompare(
"mosaic",option+1) == 0)
5599 if (LocaleCompare(
"motion-blur",option+1) == 0)
5604 if (i == (ssize_t) argc)
5605 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5606 if (IsGeometry(argv[i]) == MagickFalse)
5607 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5610 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5614 if (LocaleCompare(
"negate",option+1) == 0)
5616 if (LocaleCompare(
"noise",option+1) == 0)
5619 if (i == (ssize_t) argc)
5620 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5626 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
5629 ThrowMogrifyException(OptionError,
"UnrecognizedNoiseType",
5633 if (IsGeometry(argv[i]) == MagickFalse)
5634 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5637 if (LocaleCompare(
"noop",option+1) == 0)
5639 if (LocaleCompare(
"normalize",option+1) == 0)
5641 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5645 if (LocaleCompare(
"opaque",option+1) == 0)
5648 if (i == (ssize_t) argc)
5649 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5652 if (LocaleCompare(
"ordered-dither",option+1) == 0)
5657 if (i == (ssize_t) argc)
5658 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5661 if (LocaleCompare(
"orient",option+1) == 0)
5666 orientation=UndefinedOrientation;
5670 if (i == (ssize_t) argc)
5671 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5672 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5674 if (orientation < 0)
5675 ThrowMogrifyException(OptionError,
"UnrecognizedImageOrientation",
5679 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5683 if (LocaleCompare(
"page",option+1) == 0)
5688 if (i == (ssize_t) argc)
5689 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5692 if (LocaleCompare(
"paint",option+1) == 0)
5697 if (i == (ssize_t) argc)
5698 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5699 if (IsGeometry(argv[i]) == MagickFalse)
5700 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5703 if (LocaleCompare(
"path",option+1) == 0)
5705 (void) CloneString(&path,(
char *) NULL);
5709 if (i == (ssize_t) argc)
5710 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5711 (void) CloneString(&path,argv[i]);
5714 if (LocaleCompare(
"perceptible",option+1) == 0)
5719 if (i == (ssize_t) argc)
5720 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5721 if (IsGeometry(argv[i]) == MagickFalse)
5722 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5725 if (LocaleCompare(
"pointsize",option+1) == 0)
5730 if (i == (ssize_t) argc)
5731 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5732 if (IsGeometry(argv[i]) == MagickFalse)
5733 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5736 if (LocaleCompare(
"polaroid",option+1) == 0)
5741 if (i == (ssize_t) argc)
5742 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5743 if (IsGeometry(argv[i]) == MagickFalse)
5744 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5747 if (LocaleCompare(
"poly",option+1) == 0)
5752 if (i == (ssize_t) argc)
5753 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5754 if (IsGeometry(argv[i]) == MagickFalse)
5755 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5758 if (LocaleCompare(
"posterize",option+1) == 0)
5763 if (i == (ssize_t) argc)
5764 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5765 if (IsGeometry(argv[i]) == MagickFalse)
5766 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5769 if (LocaleCompare(
"precision",option+1) == 0)
5774 if (i == (ssize_t) argc)
5775 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5776 if (IsGeometry(argv[i]) == MagickFalse)
5777 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5780 if (LocaleCompare(
"print",option+1) == 0)
5785 if (i == (ssize_t) argc)
5786 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5789 if (LocaleCompare(
"process",option+1) == 0)
5794 if (i == (ssize_t) argc)
5795 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5798 if (LocaleCompare(
"profile",option+1) == 0)
5801 if (i == (ssize_t) argc)
5802 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5805 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5809 if (LocaleCompare(
"quality",option+1) == 0)
5814 if (i == (ssize_t) argc)
5815 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5816 if (IsGeometry(argv[i]) == MagickFalse)
5817 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5820 if (LocaleCompare(
"quantize",option+1) == 0)
5828 if (i == (ssize_t) argc)
5829 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5830 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5833 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
5837 if (LocaleCompare(
"quiet",option+1) == 0)
5839 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5843 if (LocaleCompare(
"rotational-blur",option+1) == 0)
5846 if (i == (ssize_t) argc)
5847 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5848 if (IsGeometry(argv[i]) == MagickFalse)
5849 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5852 if (LocaleCompare(
"raise",option+1) == 0)
5855 if (i == (ssize_t) argc)
5856 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5857 if (IsGeometry(argv[i]) == MagickFalse)
5858 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5861 if (LocaleCompare(
"random-threshold",option+1) == 0)
5866 if (i == (ssize_t) argc)
5867 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5868 if (IsGeometry(argv[i]) == MagickFalse)
5869 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5872 if (LocaleCompare(
"range-threshold",option+1) == 0)
5877 if (i == (ssize_t) argc)
5878 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5879 if (IsGeometry(argv[i]) == MagickFalse)
5880 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5883 if (LocaleCompare(
"read-mask",option+1) == 0)
5888 if (i == (ssize_t) argc)
5889 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5892 if (LocaleCompare(
"red-primary",option+1) == 0)
5897 if (i == (ssize_t) argc)
5898 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5899 if (IsGeometry(argv[i]) == MagickFalse)
5900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5902 if (LocaleCompare(
"regard-warnings",option+1) == 0)
5904 if (LocaleCompare(
"region",option+1) == 0)
5909 if (i == (ssize_t) argc)
5910 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5911 if (IsGeometry(argv[i]) == MagickFalse)
5912 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5915 if (LocaleCompare(
"remap",option+1) == 0)
5920 if (i == (ssize_t) argc)
5921 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5924 if (LocaleCompare(
"render",option+1) == 0)
5926 if (LocaleCompare(
"repage",option+1) == 0)
5931 if (i == (ssize_t) argc)
5932 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5933 if (IsGeometry(argv[i]) == MagickFalse)
5934 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5937 if (LocaleCompare(
"resample",option+1) == 0)
5942 if (i == (ssize_t) argc)
5943 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5944 if (IsGeometry(argv[i]) == MagickFalse)
5945 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5948 if (LocaleCompare(
"reshape",option+1) == 0)
5953 if (i == (ssize_t) argc)
5954 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5955 if (IsGeometry(argv[i]) == MagickFalse)
5956 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5959 if (LocaleCompare(
"resize",option+1) == 0)
5964 if (i == (ssize_t) argc)
5965 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5966 if (IsGeometry(argv[i]) == MagickFalse)
5967 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5970 if ((LocaleNCompare(
"respect-parentheses",option+1,17) == 0) ||
5971 (LocaleNCompare(
"respect-parenthesis",option+1,17) == 0))
5973 respect_parentheses=(*option ==
'-') ? MagickTrue : MagickFalse;
5976 if (LocaleCompare(
"reverse",option+1) == 0)
5978 if (LocaleCompare(
"roll",option+1) == 0)
5983 if (i == (ssize_t) argc)
5984 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5985 if (IsGeometry(argv[i]) == MagickFalse)
5986 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5989 if (LocaleCompare(
"rotate",option+1) == 0)
5992 if (i == (ssize_t) argc)
5993 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5994 if (IsGeometry(argv[i]) == MagickFalse)
5995 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5998 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6002 if (LocaleCompare(
"sample",option+1) == 0)
6007 if (i == (ssize_t) argc)
6008 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6009 if (IsGeometry(argv[i]) == MagickFalse)
6010 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6013 if (LocaleCompare(
"sampling-factor",option+1) == 0)
6018 if (i == (ssize_t) argc)
6019 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6020 if (IsGeometry(argv[i]) == MagickFalse)
6021 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6024 if (LocaleCompare(
"scale",option+1) == 0)
6029 if (i == (ssize_t) argc)
6030 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6031 if (IsGeometry(argv[i]) == MagickFalse)
6032 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6035 if (LocaleCompare(
"scene",option+1) == 0)
6040 if (i == (ssize_t) argc)
6041 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6042 if (IsGeometry(argv[i]) == MagickFalse)
6043 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6046 if (LocaleCompare(
"seed",option+1) == 0)
6051 if (i == (ssize_t) argc)
6052 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6053 if (IsGeometry(argv[i]) == MagickFalse)
6054 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6057 if (LocaleCompare(
"segment",option+1) == 0)
6062 if (i == (ssize_t) argc)
6063 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6064 if (IsGeometry(argv[i]) == MagickFalse)
6065 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6068 if (LocaleCompare(
"selective-blur",option+1) == 0)
6071 if (i == (ssize_t) argc)
6072 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6073 if (IsGeometry(argv[i]) == MagickFalse)
6074 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6077 if (LocaleCompare(
"separate",option+1) == 0)
6079 if (LocaleCompare(
"sepia-tone",option+1) == 0)
6084 if (i == (ssize_t) argc)
6085 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6086 if (IsGeometry(argv[i]) == MagickFalse)
6087 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6090 if (LocaleCompare(
"set",option+1) == 0)
6093 if (i == (ssize_t) argc)
6094 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6098 if (i == (ssize_t) argc)
6099 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6102 if (LocaleCompare(
"shade",option+1) == 0)
6105 if (i == (ssize_t) argc)
6106 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6107 if (IsGeometry(argv[i]) == MagickFalse)
6108 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6111 if (LocaleCompare(
"shadow",option+1) == 0)
6116 if (i == (ssize_t) argc)
6117 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6118 if (IsGeometry(argv[i]) == MagickFalse)
6119 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6122 if (LocaleCompare(
"sharpen",option+1) == 0)
6125 if (i == (ssize_t) argc)
6126 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6127 if (IsGeometry(argv[i]) == MagickFalse)
6128 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6131 if (LocaleCompare(
"shave",option+1) == 0)
6136 if (i == (ssize_t) argc)
6137 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6138 if (IsGeometry(argv[i]) == MagickFalse)
6139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6142 if (LocaleCompare(
"shear",option+1) == 0)
6145 if (i == (ssize_t) argc)
6146 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6147 if (IsGeometry(argv[i]) == MagickFalse)
6148 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6151 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
6154 if (i == (ssize_t) argc)
6155 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6156 if (IsGeometry(argv[i]) == MagickFalse)
6157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6160 if (LocaleCompare(
"size",option+1) == 0)
6165 if (i == (ssize_t) argc)
6166 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6167 if (IsGeometry(argv[i]) == MagickFalse)
6168 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6171 if (LocaleCompare(
"sketch",option+1) == 0)
6176 if (i == (ssize_t) argc)
6177 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6178 if (IsGeometry(argv[i]) == MagickFalse)
6179 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6182 if (LocaleCompare(
"smush",option+1) == 0)
6185 if (i == (ssize_t) argc)
6186 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6187 if (IsGeometry(argv[i]) == MagickFalse)
6188 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6192 if (LocaleCompare(
"solarize",option+1) == 0)
6197 if (i == (ssize_t) argc)
6198 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6199 if (IsGeometry(argv[i]) == MagickFalse)
6200 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6203 if (LocaleCompare(
"sort",option+1) == 0)
6205 if (LocaleCompare(
"sparse-color",option+1) == 0)
6211 if (i == (ssize_t) argc)
6212 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6213 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6215 ThrowMogrifyException(OptionError,
"UnrecognizedSparseColorMethod",
6218 if (i == (ssize_t) argc)
6219 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6222 if (LocaleCompare(
"splice",option+1) == 0)
6227 if (i == (ssize_t) argc)
6228 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6229 if (IsGeometry(argv[i]) == MagickFalse)
6230 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6233 if (LocaleCompare(
"spread",option+1) == 0)
6238 if (i == (ssize_t) argc)
6239 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6240 if (IsGeometry(argv[i]) == MagickFalse)
6241 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6244 if (LocaleCompare(
"statistic",option+1) == 0)
6252 if (i == (ssize_t) argc)
6253 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6254 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6256 ThrowMogrifyException(OptionError,
"UnrecognizedStatisticType",
6259 if (i == (ssize_t) argc)
6260 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6261 if (IsGeometry(argv[i]) == MagickFalse)
6262 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6265 if (LocaleCompare(
"stretch",option+1) == 0)
6273 if (i == (ssize_t) argc)
6274 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6275 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
6278 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6282 if (LocaleCompare(
"strip",option+1) == 0)
6284 if (LocaleCompare(
"stroke",option+1) == 0)
6289 if (i == (ssize_t) argc)
6290 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6293 if (LocaleCompare(
"strokewidth",option+1) == 0)
6298 if (i == (ssize_t) argc)
6299 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6300 if (IsGeometry(argv[i]) == MagickFalse)
6301 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6304 if (LocaleCompare(
"style",option+1) == 0)
6312 if (i == (ssize_t) argc)
6313 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6314 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6316 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6320 if (LocaleCompare(
"swap",option+1) == 0)
6325 if (i == (ssize_t) argc)
6326 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6327 if (IsGeometry(argv[i]) == MagickFalse)
6328 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6331 if (LocaleCompare(
"swirl",option+1) == 0)
6336 if (i == (ssize_t) argc)
6337 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6338 if (IsGeometry(argv[i]) == MagickFalse)
6339 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6342 if (LocaleCompare(
"synchronize",option+1) == 0)
6344 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6348 if (LocaleCompare(
"taint",option+1) == 0)
6350 if (LocaleCompare(
"texture",option+1) == 0)
6355 if (i == (ssize_t) argc)
6356 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6359 if (LocaleCompare(
"tile",option+1) == 0)
6364 if (i == (ssize_t) argc)
6365 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6368 if (LocaleCompare(
"tile-offset",option+1) == 0)
6373 if (i == (ssize_t) argc)
6374 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6375 if (IsGeometry(argv[i]) == MagickFalse)
6376 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6379 if (LocaleCompare(
"tint",option+1) == 0)
6384 if (i == (ssize_t) argc)
6385 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6386 if (IsGeometry(argv[i]) == MagickFalse)
6387 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6390 if (LocaleCompare(
"transform",option+1) == 0)
6392 if (LocaleCompare(
"transpose",option+1) == 0)
6394 if (LocaleCompare(
"transverse",option+1) == 0)
6396 if (LocaleCompare(
"threshold",option+1) == 0)
6401 if (i == (ssize_t) argc)
6402 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6403 if (IsGeometry(argv[i]) == MagickFalse)
6404 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6407 if (LocaleCompare(
"thumbnail",option+1) == 0)
6412 if (i == (ssize_t) argc)
6413 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6414 if (IsGeometry(argv[i]) == MagickFalse)
6415 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6418 if (LocaleCompare(
"transparent",option+1) == 0)
6421 if (i == (ssize_t) argc)
6422 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6425 if (LocaleCompare(
"transparent-color",option+1) == 0)
6430 if (i == (ssize_t) argc)
6431 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6434 if (LocaleCompare(
"treedepth",option+1) == 0)
6439 if (i == (ssize_t) argc)
6440 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6441 if (IsGeometry(argv[i]) == MagickFalse)
6442 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6445 if (LocaleCompare(
"trim",option+1) == 0)
6447 if (LocaleCompare(
"type",option+1) == 0)
6455 if (i == (ssize_t) argc)
6456 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6457 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6459 ThrowMogrifyException(OptionError,
"UnrecognizedImageType",
6463 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6467 if (LocaleCompare(
"undercolor",option+1) == 0)
6472 if (i == (ssize_t) argc)
6473 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6476 if (LocaleCompare(
"unique-colors",option+1) == 0)
6478 if (LocaleCompare(
"units",option+1) == 0)
6486 if (i == (ssize_t) argc)
6487 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6488 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6491 ThrowMogrifyException(OptionError,
"UnrecognizedUnitsType",
6495 if (LocaleCompare(
"unsharp",option+1) == 0)
6498 if (i == (ssize_t) argc)
6499 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6500 if (IsGeometry(argv[i]) == MagickFalse)
6501 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6504 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6508 if (LocaleCompare(
"verbose",option+1) == 0)
6510 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
6513 if ((LocaleCompare(
"version",option+1) == 0) ||
6514 (LocaleCompare(
"-version",option+1) == 0))
6516 ListMagickVersion(stdout);
6519 if (LocaleCompare(
"vignette",option+1) == 0)
6524 if (i == (ssize_t) argc)
6525 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6526 if (IsGeometry(argv[i]) == MagickFalse)
6527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6530 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
6538 if (i == (ssize_t) argc)
6539 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6540 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6543 ThrowMogrifyException(OptionError,
6544 "UnrecognizedVirtualPixelMethod",argv[i]);
6547 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6551 if (LocaleCompare(
"wave",option+1) == 0)
6554 if (i == (ssize_t) argc)
6555 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6556 if (IsGeometry(argv[i]) == MagickFalse)
6557 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6560 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
6563 if (i == (ssize_t) argc)
6564 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6565 if (IsGeometry(argv[i]) == MagickFalse)
6566 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6569 if (LocaleCompare(
"weight",option+1) == 0)
6574 if (i == (ssize_t) argc)
6575 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6578 if (LocaleCompare(
"word-break",option+1) == 0)
6586 if (i == (ssize_t) argc)
6587 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6588 word_break=ParseCommandOption(MagickWordBreakOptions,MagickFalse,
6591 ThrowMogrifyException(OptionError,
"UnrecognizedArgument",argv[i]);
6594 if (LocaleCompare(
"white-balance",option+1) == 0)
6596 if (LocaleCompare(
"white-point",option+1) == 0)
6601 if (i == (ssize_t) argc)
6602 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6603 if (IsGeometry(argv[i]) == MagickFalse)
6604 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6607 if (LocaleCompare(
"white-threshold",option+1) == 0)
6612 if (i == (ssize_t) argc)
6613 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6614 if (IsGeometry(argv[i]) == MagickFalse)
6615 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6618 if (LocaleCompare(
"write",option+1) == 0)
6621 if (i == (ssize_t) argc)
6622 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6625 if (LocaleCompare(
"write-mask",option+1) == 0)
6630 if (i == (ssize_t) argc)
6631 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6634 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6639 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6641 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6642 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6643 if (fire != MagickFalse)
6644 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6647 ThrowMogrifyException(OptionError,
"UnbalancedParenthesis",argv[i]);
6648 if (i != (ssize_t) argc)
6649 ThrowMogrifyException(OptionError,
"MissingAnImageFilename",argv[i]);
6651 return(status != 0 ? MagickTrue : MagickFalse);
6686WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6687 const int argc,
const char **argv,ExceptionInfo *exception)
6704 assert(image_info != (ImageInfo *) NULL);
6705 assert(image_info->signature == MagickCoreSignature);
6706 if (IsEventLogging() != MagickFalse)
6707 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
6708 image_info->filename);
6714 for (i=0; i < (ssize_t) argc; i++)
6717 if (IsCommandOption(option) == MagickFalse)
6719 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6720 count=MagickMax(count,0L);
6721 if ((i+count) >= (ssize_t) argc)
6723 switch (*(option+1))
6727 if (LocaleCompare(
"adjoin",option+1) == 0)
6729 image_info->adjoin=(*option ==
'-') ? MagickTrue : MagickFalse;
6732 if (LocaleCompare(
"antialias",option+1) == 0)
6734 image_info->antialias=(*option ==
'-') ? MagickTrue : MagickFalse;
6737 if (LocaleCompare(
"authenticate",option+1) == 0)
6740 (void) DeleteImageOption(image_info,option+1);
6742 (
void) SetImageOption(image_info,option+1,argv[i+1]);
6749 if (LocaleCompare(
"background",option+1) == 0)
6753 (void) DeleteImageOption(image_info,option+1);
6754 (void) QueryColorCompliance(MogrifyBackgroundColor,
6755 AllCompliance,&image_info->background_color,exception);
6758 (void) SetImageOption(image_info,option+1,argv[i+1]);
6759 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6760 &image_info->background_color,exception);
6763 if (LocaleCompare(
"bias",option+1) == 0)
6767 (void) SetImageOption(image_info,
"convolve:bias",
"0.0");
6770 (void) SetImageOption(image_info,
"convolve:bias",argv[i+1]);
6773 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
6777 (void) SetImageOption(image_info,option+1,
"false");
6780 (void) SetImageOption(image_info,option+1,
"true");
6783 if (LocaleCompare(
"blue-primary",option+1) == 0)
6787 (void) SetImageOption(image_info,option+1,
"0.0");
6790 (void) SetImageOption(image_info,option+1,argv[i+1]);
6793 if (LocaleCompare(
"bordercolor",option+1) == 0)
6797 (void) DeleteImageOption(image_info,option+1);
6798 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6799 &image_info->border_color,exception);
6802 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6803 &image_info->border_color,exception);
6804 (void) SetImageOption(image_info,option+1,argv[i+1]);
6807 if (LocaleCompare(
"box",option+1) == 0)
6811 (void) SetImageOption(image_info,
"undercolor",
"none");
6814 (void) SetImageOption(image_info,
"undercolor",argv[i+1]);
6821 if (LocaleCompare(
"cache",option+1) == 0)
6826 limit=MagickResourceInfinity;
6827 if (LocaleCompare(
"unlimited",argv[i+1]) != 0)
6828 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6830 (void) SetMagickResourceLimit(MemoryResource,limit);
6831 (void) SetMagickResourceLimit(MapResource,2*limit);
6834 if (LocaleCompare(
"caption",option+1) == 0)
6838 (void) DeleteImageOption(image_info,option+1);
6841 (void) SetImageOption(image_info,option+1,argv[i+1]);
6844 if (LocaleCompare(
"colorspace",option+1) == 0)
6848 image_info->colorspace=UndefinedColorspace;
6849 (void) SetImageOption(image_info,option+1,
"undefined");
6852 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6853 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6854 (void) SetImageOption(image_info,option+1,argv[i+1]);
6857 if (LocaleCompare(
"comment",option+1) == 0)
6861 (void) DeleteImageOption(image_info,option+1);
6864 (void) SetImageOption(image_info,option+1,argv[i+1]);
6867 if (LocaleCompare(
"compose",option+1) == 0)
6871 (void) SetImageOption(image_info,option+1,
"undefined");
6874 (void) SetImageOption(image_info,option+1,argv[i+1]);
6877 if (LocaleCompare(
"compress",option+1) == 0)
6881 image_info->compression=UndefinedCompression;
6882 (void) SetImageOption(image_info,option+1,
"undefined");
6885 image_info->compression=(CompressionType) ParseCommandOption(
6886 MagickCompressOptions,MagickFalse,argv[i+1]);
6887 (void) SetImageOption(image_info,option+1,argv[i+1]);
6894 if (LocaleCompare(
"debug",option+1) == 0)
6897 (void) SetLogEventMask(
"none");
6899 (
void) SetLogEventMask(argv[i+1]);
6900 image_info->debug=IsEventLogging();
6903 if (LocaleCompare(
"define",option+1) == 0)
6907 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6908 (void) DeleteImageRegistry(argv[i+1]+9);
6910 (
void) DeleteImageOption(image_info,argv[i+1]);
6913 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6915 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6919 (void) DefineImageOption(image_info,argv[i+1]);
6922 if (LocaleCompare(
"delay",option+1) == 0)
6926 (void) SetImageOption(image_info,option+1,
"0");
6929 (void) SetImageOption(image_info,option+1,argv[i+1]);
6932 if (LocaleCompare(
"density",option+1) == 0)
6939 if (image_info->density != (
char *) NULL)
6940 image_info->density=DestroyString(image_info->density);
6941 (void) SetImageOption(image_info,option+1,
"72");
6944 (void) CloneString(&image_info->density,argv[i+1]);
6945 (void) SetImageOption(image_info,option+1,argv[i+1]);
6948 if (LocaleCompare(
"depth",option+1) == 0)
6952 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6955 image_info->depth=StringToUnsignedLong(argv[i+1]);
6958 if (LocaleCompare(
"direction",option+1) == 0)
6962 (void) SetImageOption(image_info,option+1,
"undefined");
6965 (void) SetImageOption(image_info,option+1,argv[i+1]);
6968 if (LocaleCompare(
"display",option+1) == 0)
6972 if (image_info->server_name != (
char *) NULL)
6973 image_info->server_name=DestroyString(
6974 image_info->server_name);
6977 (void) CloneString(&image_info->server_name,argv[i+1]);
6980 if (LocaleCompare(
"dispose",option+1) == 0)
6984 (void) SetImageOption(image_info,option+1,
"undefined");
6987 (void) SetImageOption(image_info,option+1,argv[i+1]);
6990 if (LocaleCompare(
"dither",option+1) == 0)
6994 image_info->dither=MagickFalse;
6995 (void) SetImageOption(image_info,option+1,
"none");
6998 (void) SetImageOption(image_info,option+1,argv[i+1]);
6999 image_info->dither=MagickTrue;
7006 if (LocaleCompare(
"encoding",option+1) == 0)
7010 (void) SetImageOption(image_info,option+1,
"undefined");
7013 (void) SetImageOption(image_info,option+1,argv[i+1]);
7016 if (LocaleCompare(
"endian",option+1) == 0)
7020 image_info->endian=UndefinedEndian;
7021 (void) SetImageOption(image_info,option+1,
"undefined");
7024 image_info->endian=(EndianType) ParseCommandOption(
7025 MagickEndianOptions,MagickFalse,argv[i+1]);
7026 (void) SetImageOption(image_info,option+1,argv[i+1]);
7029 if (LocaleCompare(
"extract",option+1) == 0)
7036 if (image_info->extract != (
char *) NULL)
7037 image_info->extract=DestroyString(image_info->extract);
7040 (void) CloneString(&image_info->extract,argv[i+1]);
7047 if (LocaleCompare(
"family",option+1) == 0)
7050 (void) SetImageOption(image_info,option+1,argv[i+1]);
7053 if (LocaleCompare(
"fill",option+1) == 0)
7057 (void) SetImageOption(image_info,option+1,
"none");
7060 (void) SetImageOption(image_info,option+1,argv[i+1]);
7063 if (LocaleCompare(
"filter",option+1) == 0)
7067 (void) SetImageOption(image_info,option+1,
"undefined");
7070 (void) SetImageOption(image_info,option+1,argv[i+1]);
7073 if (LocaleCompare(
"font",option+1) == 0)
7077 if (image_info->font != (
char *) NULL)
7078 image_info->font=DestroyString(image_info->font);
7081 (void) CloneString(&image_info->font,argv[i+1]);
7084 if (LocaleCompare(
"format",option+1) == 0)
7086 (void) SetImageOption(image_info,option+1,argv[i+1]);
7089 if (LocaleCompare(
"fuzz",option+1) == 0)
7093 image_info->fuzz=0.0;
7094 (void) SetImageOption(image_info,option+1,
"0");
7097 image_info->fuzz=StringToDoubleInterval(argv[i+1],(
double)
7099 (void) SetImageOption(image_info,option+1,argv[i+1]);
7106 if (LocaleCompare(
"gravity",option+1) == 0)
7110 (void) SetImageOption(image_info,option+1,
"undefined");
7113 (void) SetImageOption(image_info,option+1,argv[i+1]);
7116 if (LocaleCompare(
"green-primary",option+1) == 0)
7120 (void) SetImageOption(image_info,option+1,
"0.0");
7123 (void) SetImageOption(image_info,option+1,argv[i+1]);
7130 if (LocaleCompare(
"intensity",option+1) == 0)
7134 (void) SetImageOption(image_info,option+1,
"undefined");
7137 (void) SetImageOption(image_info,option+1,argv[i+1]);
7140 if (LocaleCompare(
"intent",option+1) == 0)
7144 (void) SetImageOption(image_info,option+1,
"undefined");
7147 (void) SetImageOption(image_info,option+1,argv[i+1]);
7150 if (LocaleCompare(
"interlace",option+1) == 0)
7154 image_info->interlace=UndefinedInterlace;
7155 (void) SetImageOption(image_info,option+1,
"undefined");
7158 image_info->interlace=(InterlaceType) ParseCommandOption(
7159 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7160 (void) SetImageOption(image_info,option+1,argv[i+1]);
7163 if (LocaleCompare(
"interline-spacing",option+1) == 0)
7167 (void) SetImageOption(image_info,option+1,
"undefined");
7170 (void) SetImageOption(image_info,option+1,argv[i+1]);
7173 if (LocaleCompare(
"interpolate",option+1) == 0)
7177 (void) SetImageOption(image_info,option+1,
"undefined");
7180 (void) SetImageOption(image_info,option+1,argv[i+1]);
7183 if (LocaleCompare(
"interword-spacing",option+1) == 0)
7187 (void) SetImageOption(image_info,option+1,
"undefined");
7190 (void) SetImageOption(image_info,option+1,argv[i+1]);
7197 if (LocaleCompare(
"kerning",option+1) == 0)
7201 (void) SetImageOption(image_info,option+1,
"undefined");
7204 (void) SetImageOption(image_info,option+1,argv[i+1]);
7211 if (LocaleCompare(
"label",option+1) == 0)
7215 (void) DeleteImageOption(image_info,option+1);
7218 (void) SetImageOption(image_info,option+1,argv[i+1]);
7221 if (LocaleCompare(
"limit",option+1) == 0)
7231 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7232 MagickFalse,argv[i+1]);
7233 limit=MagickResourceInfinity;
7234 if (LocaleCompare(
"unlimited",argv[i+2]) != 0)
7235 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7236 if (type == TimeResource)
7237 limit=(MagickSizeType) ParseMagickTimeToLive(argv[i+2]);
7238 (void) SetMagickResourceLimit(type,limit);
7241 if (LocaleCompare(
"list",option+1) == 0)
7249 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7252 case MagickCoderOptions:
7254 (void) ListCoderInfo((FILE *) NULL,exception);
7257 case MagickColorOptions:
7259 (void) ListColorInfo((FILE *) NULL,exception);
7262 case MagickConfigureOptions:
7264 (void) ListConfigureInfo((FILE *) NULL,exception);
7267 case MagickDelegateOptions:
7269 (void) ListDelegateInfo((FILE *) NULL,exception);
7272 case MagickFontOptions:
7274 (void) ListTypeInfo((FILE *) NULL,exception);
7277 case MagickFormatOptions:
7279 (void) ListMagickInfo((FILE *) NULL,exception);
7282 case MagickLocaleOptions:
7284 (void) ListLocaleInfo((FILE *) NULL,exception);
7287 case MagickLogOptions:
7289 (void) ListLogInfo((FILE *) NULL,exception);
7292 case MagickMagicOptions:
7294 (void) ListMagicInfo((FILE *) NULL,exception);
7297 case MagickMimeOptions:
7299 (void) ListMimeInfo((FILE *) NULL,exception);
7302 case MagickModuleOptions:
7304 (void) ListModuleInfo((FILE *) NULL,exception);
7307 case MagickPagesizeOptions:
7309 (void) ListPagesizes((FILE *) NULL,exception);
7312 case MagickPolicyOptions:
7314 (void) ListPolicyInfo((FILE *) NULL,exception);
7317 case MagickResourceOptions:
7319 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7322 case MagickThresholdOptions:
7324 (void) ListThresholdMaps((FILE *) NULL,exception);
7329 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7336 if (LocaleCompare(
"log",option+1) == 0)
7340 (void) SetLogFormat(argv[i+1]);
7343 if (LocaleCompare(
"loop",option+1) == 0)
7347 (void) SetImageOption(image_info,option+1,
"0");
7350 (void) SetImageOption(image_info,option+1,argv[i+1]);
7357 if (LocaleCompare(
"matte",option+1) == 0)
7361 (void) SetImageOption(image_info,option+1,
"false");
7364 (void) SetImageOption(image_info,option+1,
"true");
7367 if (LocaleCompare(
"mattecolor",option+1) == 0)
7371 (void) SetImageOption(image_info,option+1,argv[i+1]);
7372 (void) QueryColorCompliance(MogrifyAlphaColor,AllCompliance,
7373 &image_info->matte_color,exception);
7376 (void) SetImageOption(image_info,option+1,argv[i+1]);
7377 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7378 &image_info->matte_color,exception);
7381 if (LocaleCompare(
"metric",option+1) == 0)
7384 (void) DeleteImageOption(image_info,option+1);
7386 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7389 if (LocaleCompare(
"monitor",option+1) == 0)
7391 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7395 if (LocaleCompare(
"monochrome",option+1) == 0)
7397 image_info->monochrome=(*option ==
'-') ? MagickTrue : MagickFalse;
7404 if (LocaleCompare(
"orient",option+1) == 0)
7408 image_info->orientation=UndefinedOrientation;
7409 (void) SetImageOption(image_info,option+1,
"undefined");
7412 image_info->orientation=(OrientationType) ParseCommandOption(
7413 MagickOrientationOptions,MagickFalse,argv[i+1]);
7414 (void) SetImageOption(image_info,option+1,argv[i+1]);
7421 if (LocaleCompare(
"page",option+1) == 0)
7425 page[MagickPathExtent];
7438 (void) DeleteImageOption(image_info,option+1);
7439 (void) CloneString(&image_info->page,(
char *) NULL);
7442 (void) memset(&geometry,0,
sizeof(geometry));
7443 image_option=GetImageOption(image_info,
"page");
7444 if (image_option != (
const char *) NULL)
7445 flags=ParseAbsoluteGeometry(image_option,&geometry);
7446 canonical_page=GetPageGeometry(argv[i+1]);
7447 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7448 canonical_page=DestroyString(canonical_page);
7449 (void) FormatLocaleString(page,MagickPathExtent,
"%lux%lu",
7450 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
7451 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7452 (void) FormatLocaleString(page,MagickPathExtent,
"%lux%lu%+ld%+ld",
7453 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
7454 (
long) geometry.x,(
long) geometry.y);
7455 (void) SetImageOption(image_info,option+1,page);
7456 (void) CloneString(&image_info->page,page);
7459 if (LocaleCompare(
"ping",option+1) == 0)
7461 image_info->ping=(*option ==
'-') ? MagickTrue : MagickFalse;
7464 if (LocaleCompare(
"pointsize",option+1) == 0)
7467 geometry_info.rho=0.0;
7469 (
void) ParseGeometry(argv[i+1],&geometry_info);
7470 image_info->pointsize=geometry_info.rho;
7473 if (LocaleCompare(
"precision",option+1) == 0)
7475 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7482 if (LocaleCompare(
"quality",option+1) == 0)
7489 image_info->quality=UndefinedCompressionQuality;
7490 (void) SetImageOption(image_info,option+1,
"0");
7493 image_info->quality=StringToUnsignedLong(argv[i+1]);
7494 (void) SetImageOption(image_info,option+1,argv[i+1]);
7497 if (LocaleCompare(
"quiet",option+1) == 0)
7499 static WarningHandler
7500 warning_handler = (WarningHandler) NULL;
7507 warning_handler=SetWarningHandler(warning_handler);
7513 warning_handler=SetWarningHandler((WarningHandler) NULL);
7520 if (LocaleCompare(
"red-primary",option+1) == 0)
7524 (void) SetImageOption(image_info,option+1,
"0.0");
7527 (void) SetImageOption(image_info,option+1,argv[i+1]);
7534 if (LocaleCompare(
"sampling-factor",option+1) == 0)
7541 if (image_info->sampling_factor != (
char *) NULL)
7542 image_info->sampling_factor=DestroyString(
7543 image_info->sampling_factor);
7546 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7549 if (LocaleCompare(
"scene",option+1) == 0)
7556 image_info->scene=0;
7557 (void) SetImageOption(image_info,option+1,
"0");
7560 image_info->scene=StringToUnsignedLong(argv[i+1]);
7561 (void) SetImageOption(image_info,option+1,argv[i+1]);
7564 if (LocaleCompare(
"seed",option+1) == 0)
7571 seed=(
unsigned long) time((time_t *) NULL);
7572 SetRandomSecretKey(seed);
7575 seed=StringToUnsignedLong(argv[i+1]);
7576 SetRandomSecretKey(seed);
7579 if (LocaleCompare(
"size",option+1) == 0)
7583 if (image_info->size != (
char *) NULL)
7584 image_info->size=DestroyString(image_info->size);
7587 (void) CloneString(&image_info->size,argv[i+1]);
7590 if (LocaleCompare(
"stroke",option+1) == 0)
7594 (void) SetImageOption(image_info,option+1,
"none");
7597 (void) SetImageOption(image_info,option+1,argv[i+1]);
7600 if (LocaleCompare(
"strokewidth",option+1) == 0)
7603 (void) SetImageOption(image_info,option+1,
"0");
7605 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7608 if (LocaleCompare(
"style",option+1) == 0)
7612 (void) SetImageOption(image_info,option+1,
"none");
7615 (void) SetImageOption(image_info,option+1,argv[i+1]);
7618 if (LocaleCompare(
"synchronize",option+1) == 0)
7622 image_info->synchronize=MagickFalse;
7625 image_info->synchronize=MagickTrue;
7632 if (LocaleCompare(
"taint",option+1) == 0)
7636 (void) SetImageOption(image_info,option+1,
"false");
7639 (void) SetImageOption(image_info,option+1,
"true");
7642 if (LocaleCompare(
"texture",option+1) == 0)
7646 if (image_info->texture != (
char *) NULL)
7647 image_info->texture=DestroyString(image_info->texture);
7650 (void) CloneString(&image_info->texture,argv[i+1]);
7653 if (LocaleCompare(
"tile-offset",option+1) == 0)
7656 (void) SetImageOption(image_info,option+1,
"0");
7658 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7661 if (LocaleCompare(
"transparent-color",option+1) == 0)
7665 (void) QueryColorCompliance(
"none",AllCompliance,
7666 &image_info->transparent_color,exception);
7667 (void) SetImageOption(image_info,option+1,
"none");
7670 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7671 &image_info->transparent_color,exception);
7672 (void) SetImageOption(image_info,option+1,argv[i+1]);
7675 if (LocaleCompare(
"type",option+1) == 0)
7679 image_info->type=UndefinedType;
7680 (void) SetImageOption(image_info,option+1,
"undefined");
7683 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7684 MagickFalse,argv[i+1]);
7685 (void) SetImageOption(image_info,option+1,argv[i+1]);
7692 if (LocaleCompare(
"undercolor",option+1) == 0)
7695 (void) DeleteImageOption(image_info,option+1);
7697 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7700 if (LocaleCompare(
"units",option+1) == 0)
7704 image_info->units=UndefinedResolution;
7705 (void) SetImageOption(image_info,option+1,
"undefined");
7708 image_info->units=(ResolutionType) ParseCommandOption(
7709 MagickResolutionOptions,MagickFalse,argv[i+1]);
7710 (void) SetImageOption(image_info,option+1,argv[i+1]);
7717 if (LocaleCompare(
"verbose",option+1) == 0)
7721 image_info->verbose=MagickFalse;
7724 image_info->verbose=MagickTrue;
7725 image_info->ping=MagickFalse;
7728 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
7731 (void) SetImageOption(image_info,option+1,
"undefined");
7733 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7740 if (LocaleCompare(
"weight",option+1) == 0)
7743 (void) SetImageOption(image_info,option+1,
"0");
7745 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7748 if (LocaleCompare(
"white-point",option+1) == 0)
7751 (void) SetImageOption(image_info,option+1,
"0.0");
7753 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7756 if (LocaleCompare(
"word-break",option+1) == 0)
7760 (void) SetImageOption(image_info,option+1,
"undefined");
7763 (void) SetImageOption(image_info,option+1,argv[i+1]);
7810WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7811 const int argc,
const char **argv,Image **images,ExceptionInfo *exception)
7822 PixelInterpolateMethod
7838 assert(image_info != (ImageInfo *) NULL);
7839 assert(image_info->signature == MagickCoreSignature);
7840 assert(images != (Image **) NULL);
7841 assert((*images)->previous == (Image *) NULL);
7842 assert((*images)->signature == MagickCoreSignature);
7843 if (IsEventLogging() != MagickFalse)
7844 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
7845 (*images)->filename);
7846 if ((argc <= 0) || (*argv == (
char *) NULL))
7848 interpolate_method=UndefinedInterpolatePixel;
7849 mogrify_info=CloneImageInfo(image_info);
7850 quantize_info=AcquireQuantizeInfo(mogrify_info);
7852 for (i=0; i < (ssize_t) argc; i++)
7854 if (*images == (Image *) NULL)
7857 if (IsCommandOption(option) == MagickFalse)
7859 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7860 count=MagickMax(count,0L);
7861 if ((i+count) >= (ssize_t) argc)
7863 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
7864 switch (*(option+1))
7868 if (LocaleCompare(
"affinity",option+1) == 0)
7870 (void) SyncImagesSettings(mogrify_info,*images,exception);
7873 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7880 if (LocaleCompare(
"append",option+1) == 0)
7885 (void) SyncImagesSettings(mogrify_info,*images,exception);
7886 append_image=AppendImages(*images,*option ==
'-' ? MagickTrue :
7887 MagickFalse,exception);
7888 if (append_image == (Image *) NULL)
7893 *images=DestroyImageList(*images);
7894 *images=append_image;
7897 if (LocaleCompare(
"average",option+1) == 0)
7905 (void) SyncImagesSettings(mogrify_info,*images,exception);
7906 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7908 if (average_image == (Image *) NULL)
7913 *images=DestroyImageList(*images);
7914 *images=average_image;
7921 if (LocaleCompare(
"channel-fx",option+1) == 0)
7926 (void) SyncImagesSettings(mogrify_info,*images,exception);
7927 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7928 if (channel_image == (Image *) NULL)
7933 *images=DestroyImageList(*images);
7934 *images=channel_image;
7937 if (LocaleCompare(
"clut",option+1) == 0)
7943 (void) SyncImagesSettings(mogrify_info,*images,exception);
7944 image=RemoveFirstImageFromList(images);
7945 clut_image=RemoveFirstImageFromList(images);
7946 if (clut_image == (Image *) NULL)
7948 (void) ThrowMagickException(exception,GetMagickModule(),
7949 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7950 image=DestroyImage(image);
7954 (void) ClutImage(image,clut_image,interpolate_method,exception);
7955 clut_image=DestroyImage(clut_image);
7956 *images=DestroyImageList(*images);
7960 if (LocaleCompare(
"coalesce",option+1) == 0)
7965 (void) SyncImagesSettings(mogrify_info,*images,exception);
7966 coalesce_image=CoalesceImages(*images,exception);
7967 if (coalesce_image == (Image *) NULL)
7972 *images=DestroyImageList(*images);
7973 *images=coalesce_image;
7976 if (LocaleCompare(
"combine",option+1) == 0)
7984 (void) SyncImagesSettings(mogrify_info,*images,exception);
7985 colorspace=(*images)->colorspace;
7986 if ((*images)->number_channels < GetImageListLength(*images))
7987 colorspace=sRGBColorspace;
7989 colorspace=(ColorspaceType) ParseCommandOption(
7990 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7991 combine_image=CombineImages(*images,colorspace,exception);
7992 if (combine_image == (Image *) NULL)
7997 *images=DestroyImageList(*images);
7998 *images=combine_image;
8001 if (LocaleCompare(
"compare",option+1) == 0)
8018 (void) SyncImagesSettings(mogrify_info,*images,exception);
8019 image=RemoveFirstImageFromList(images);
8020 reconstruct_image=RemoveFirstImageFromList(images);
8021 if (reconstruct_image == (Image *) NULL)
8023 (void) ThrowMagickException(exception,GetMagickModule(),
8024 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8025 image=DestroyImage(image);
8029 metric=UndefinedErrorMetric;
8030 option=GetImageOption(mogrify_info,
"metric");
8031 if (option != (
const char *) NULL)
8032 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
8033 MagickFalse,option);
8034 difference_image=CompareImages(image,reconstruct_image,metric,
8035 &distortion,exception);
8036 if (difference_image == (Image *) NULL)
8038 reconstruct_image=DestroyImage(reconstruct_image);
8039 image=DestroyImage(image);
8040 if (*images != (Image *) NULL)
8041 *images=DestroyImageList(*images);
8042 *images=difference_image;
8045 if (LocaleCompare(
"complex",option+1) == 0)
8053 (void) SyncImageSettings(mogrify_info,*images,exception);
8054 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
8055 MagickFalse,argv[i+1]);
8056 complex_images=ComplexImages(*images,op,exception);
8057 if (complex_images == (Image *) NULL)
8062 *images=DestroyImageList(*images);
8063 *images=complex_images;
8066 if (LocaleCompare(
"composite",option+1) == 0)
8086 (void) SyncImageSettings(mogrify_info,*images,exception);
8087 value=GetImageOption(mogrify_info,
"compose");
8088 if (value == (
const char *) NULL)
8089 compose=OverCompositeOp;
8091 compose=(CompositeOperator) ParseCommandOption(
8092 MagickComposeOptions,MagickFalse,value);
8095 clip_to_self=GetCompositeClipToSelf(compose);
8096 value=GetImageOption(mogrify_info,
"compose:clip-to-self");
8097 if (value != (
const char *) NULL)
8098 clip_to_self=IsStringTrue(value);
8099 value=GetImageOption(mogrify_info,
"compose:outside-overlay");
8100 if (value != (
const char *) NULL)
8101 clip_to_self=IsStringFalse(value);
8103 new_images=RemoveFirstImageFromList(images);
8104 source_image=RemoveFirstImageFromList(images);
8105 if (source_image == (Image *) NULL)
8107 (void) ThrowMagickException(exception,GetMagickModule(),
8108 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8109 new_images=DestroyImage(new_images);
8115 if (source_image->geometry != (
char *) NULL)
8120 (void) ParseRegionGeometry(source_image,source_image->geometry,
8121 &resize_geometry,exception);
8122 if ((source_image->columns != resize_geometry.width) ||
8123 (source_image->rows != resize_geometry.height))
8128 resize_image=ResizeImage(source_image,resize_geometry.width,
8129 resize_geometry.height,source_image->filter,exception);
8130 if (resize_image != (Image *) NULL)
8132 source_image=DestroyImage(source_image);
8133 source_image=resize_image;
8137 SetGeometry(source_image,&geometry);
8138 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
8139 GravityAdjustGeometry(new_images->columns,new_images->rows,
8140 new_images->gravity,&geometry);
8141 mask_image=RemoveFirstImageFromList(images);
8142 if (mask_image == (Image *) NULL)
8143 status&=(MagickStatusType) CompositeImage(new_images,source_image,
8144 compose,clip_to_self,geometry.x,geometry.y,exception);
8150 canvas_image=CloneImage(new_images,0,0,MagickTrue,exception);
8151 if (canvas_image == (Image *) NULL)
8155 case BlendCompositeOp:
8157 status&=(MagickStatusType) CompositeImage(new_images,
8158 source_image,compose,clip_to_self,geometry.x,geometry.y,
8160 status&=(MagickStatusType) CompositeImage(new_images,
8161 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8164 case DisplaceCompositeOp:
8165 case DistortCompositeOp:
8167 status&=(MagickStatusType) CompositeImage(source_image,
8168 mask_image,CopyGreenCompositeOp,MagickTrue,0,0,exception);
8169 (void) SetImageColorspace(source_image,sRGBColorspace,
8171 status&=(MagickStatusType) CompositeImage(new_images,
8172 source_image,compose,clip_to_self,geometry.x,geometry.y,
8176 case SaliencyBlendCompositeOp:
8177 case SeamlessBlendCompositeOp:
8179 status&=(MagickStatusType) CompositeImage(source_image,
8180 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8181 status&=(MagickStatusType) CompositeImage(new_images,
8182 source_image,compose,clip_to_self,geometry.x,geometry.y,
8191 clone_image=CloneImage(new_images,0,0,MagickTrue,exception);
8192 if (clone_image == (Image *) NULL)
8194 status&=(MagickStatusType) CompositeImage(new_images,
8195 source_image,compose,clip_to_self,geometry.x,geometry.y,
8197 status&=(MagickStatusType) CompositeImage(new_images,
8198 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8199 status&=(MagickStatusType) CompositeImage(clone_image,
8200 new_images,OverCompositeOp,clip_to_self,0,0,exception);
8201 new_images=DestroyImageList(new_images);
8202 new_images=clone_image;
8208 case DisplaceCompositeOp:
8209 case DistortCompositeOp:
8211 status&=(MagickStatusType) CompositeImage(canvas_image,
8212 new_images,CopyCompositeOp,clip_to_self,0,0,exception);
8217 status&=(MagickStatusType) CompositeImage(canvas_image,
8218 new_images,OverCompositeOp,clip_to_self,0,0,exception);
8222 new_images=DestroyImageList(new_images);
8223 new_images=canvas_image;
8224 mask_image=DestroyImage(mask_image);
8226 source_image=DestroyImage(source_image);
8227 *images=DestroyImageList(*images);
8231 if (LocaleCompare(
"copy",option+1) == 0)
8245 (void) SyncImageSettings(mogrify_info,*images,exception);
8246 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8247 offset.x=geometry.x;
8248 offset.y=geometry.y;
8249 source_image=(*images);
8250 if (source_image->next != (Image *) NULL)
8251 source_image=source_image->next;
8252 (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8254 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8262 if (LocaleCompare(
"deconstruct",option+1) == 0)
8267 (void) SyncImagesSettings(mogrify_info,*images,exception);
8268 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
8270 if (deconstruct_image == (Image *) NULL)
8275 *images=DestroyImageList(*images);
8276 *images=deconstruct_image;
8279 if (LocaleCompare(
"delete",option+1) == 0)
8282 DeleteImages(images,
"-1",exception);
8284 DeleteImages(images,argv[i+1],exception);
8287 if (LocaleCompare(
"dither",option+1) == 0)
8291 quantize_info->dither_method=NoDitherMethod;
8294 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8295 MagickDitherOptions,MagickFalse,argv[i+1]);
8298 if (LocaleCompare(
"duplicate",option+1) == 0)
8304 duplicate_images=DuplicateImages(*images,1,
"-1",exception);
8313 number_duplicates=(size_t) StringToLong(argv[i+1]);
8314 p=strchr(argv[i+1],
',');
8315 if (p == (
const char *) NULL)
8316 duplicate_images=DuplicateImages(*images,number_duplicates,
8319 duplicate_images=DuplicateImages(*images,number_duplicates,
8322 AppendImageToList(images, duplicate_images);
8323 (void) SyncImagesSettings(mogrify_info,*images,exception);
8330 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
8335 MagickEvaluateOperator
8338 (void) SyncImageSettings(mogrify_info,*images,exception);
8339 op=(MagickEvaluateOperator) ParseCommandOption(
8340 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8341 evaluate_image=EvaluateImages(*images,op,exception);
8342 if (evaluate_image == (Image *) NULL)
8347 *images=DestroyImageList(*images);
8348 *images=evaluate_image;
8355 if (LocaleCompare(
"fft",option+1) == 0)
8363 (void) SyncImageSettings(mogrify_info,*images,exception);
8364 fourier_image=ForwardFourierTransformImage(*images,*option ==
'-' ?
8365 MagickTrue : MagickFalse,exception);
8366 if (fourier_image == (Image *) NULL)
8368 *images=DestroyImageList(*images);
8369 *images=fourier_image;
8372 if (LocaleCompare(
"flatten",option+1) == 0)
8377 (void) SyncImagesSettings(mogrify_info,*images,exception);
8378 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8379 if (flatten_image == (Image *) NULL)
8381 *images=DestroyImageList(*images);
8382 *images=flatten_image;
8385 if (LocaleCompare(
"fx",option+1) == 0)
8390 (void) SyncImagesSettings(mogrify_info,*images,exception);
8391 fx_image=FxImage(*images,argv[i+1],exception);
8392 if (fx_image == (Image *) NULL)
8397 *images=DestroyImageList(*images);
8405 if (LocaleCompare(
"hald-clut",option+1) == 0)
8411 (void) SyncImagesSettings(mogrify_info,*images,exception);
8412 image=RemoveFirstImageFromList(images);
8413 hald_image=RemoveFirstImageFromList(images);
8414 if (hald_image == (Image *) NULL)
8416 (void) ThrowMagickException(exception,GetMagickModule(),
8417 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8418 image=DestroyImage(image);
8422 (void) HaldClutImage(image,hald_image,exception);
8423 hald_image=DestroyImage(hald_image);
8424 if (*images != (Image *) NULL)
8425 *images=DestroyImageList(*images);
8433 if (LocaleCompare(
"ift",option+1) == 0)
8443 (void) SyncImagesSettings(mogrify_info,*images,exception);
8444 magnitude_image=RemoveFirstImageFromList(images);
8445 phase_image=RemoveFirstImageFromList(images);
8446 if (phase_image == (Image *) NULL)
8448 (void) ThrowMagickException(exception,GetMagickModule(),
8449 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8450 magnitude_image=DestroyImage(magnitude_image);
8454 fourier_image=InverseFourierTransformImage(magnitude_image,
8455 phase_image,*option ==
'-' ? MagickTrue : MagickFalse,exception);
8456 magnitude_image=DestroyImage(magnitude_image);
8457 phase_image=DestroyImage(phase_image);
8458 if (fourier_image == (Image *) NULL)
8460 if (*images != (Image *) NULL)
8461 *images=DestroyImageList(*images);
8462 *images=fourier_image;
8465 if (LocaleCompare(
"insert",option+1) == 0)
8473 index=(ssize_t) StringToLong(argv[i+1]);
8474 p=RemoveLastImageFromList(images);
8475 if (p == (Image *) NULL)
8477 (void) ThrowMagickException(exception,GetMagickModule(),
8478 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8484 PrependImageToList(images,q);
8486 if (index == (ssize_t) GetImageListLength(*images))
8487 AppendImageToList(images,q);
8490 q=GetImageFromList(*images,index-1);
8491 if (q == (Image *) NULL)
8494 (void) ThrowMagickException(exception,GetMagickModule(),
8495 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8499 InsertImageInList(&q,p);
8501 *images=GetFirstImageInList(q);
8504 if (LocaleCompare(
"interpolate",option+1) == 0)
8506 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8507 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8514 if (LocaleCompare(
"layers",option+1) == 0)
8522 (void) SyncImagesSettings(mogrify_info,*images,exception);
8523 layers=(Image *) NULL;
8524 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8525 MagickFalse,argv[i+1]);
8530 layers=CoalesceImages(*images,exception);
8533 case CompareAnyLayer:
8534 case CompareClearLayer:
8535 case CompareOverlayLayer:
8538 layers=CompareImagesLayers(*images,method,exception);
8544 case TrimBoundsLayer:
8546 layers=MergeImageLayers(*images,method,exception);
8551 layers=DisposeImages(*images,exception);
8554 case OptimizeImageLayer:
8556 layers=OptimizeImageLayers(*images,exception);
8559 case OptimizePlusLayer:
8561 layers=OptimizePlusImageLayers(*images,exception);
8564 case OptimizeTransLayer:
8566 OptimizeImageTransparency(*images,exception);
8569 case RemoveDupsLayer:
8571 RemoveDuplicateLayers(images,exception);
8574 case RemoveZeroLayer:
8576 RemoveZeroDelayLayers(images,exception);
8584 layers=CoalesceImages(*images,exception);
8585 if (layers == (Image *) NULL)
8590 *images=DestroyImageList(*images);
8592 layers=OptimizeImageLayers(*images,exception);
8593 if (layers == (Image *) NULL)
8598 *images=DestroyImageList(*images);
8600 layers=(Image *) NULL;
8601 OptimizeImageTransparency(*images,exception);
8602 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8606 case CompositeLayer:
8621 while (source != (Image *) NULL)
8623 source=GetNextImageInList(source);
8624 if ((source != (Image *) NULL) &&
8625 (LocaleCompare(source->magick,
"NULL") == 0))
8628 if (source != (Image *) NULL)
8630 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8631 (GetNextImageInList(source) == (Image *) NULL))
8632 source=(Image *) NULL;
8638 source=SplitImageList(source->previous);
8639 DeleteImageFromList(&source);
8642 if (source == (Image *) NULL)
8644 (void) ThrowMagickException(exception,GetMagickModule(),
8645 OptionError,
"MissingNullSeparator",
"layers Composite");
8652 SetGeometry(*images,&geometry);
8653 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8654 geometry.width=source->page.width != 0 ?
8655 source->page.width : source->columns;
8656 geometry.height=source->page.height != 0 ?
8657 source->page.height : source->rows;
8658 GravityAdjustGeometry((*images)->page.width != 0 ?
8659 (*images)->page.width : (*images)->columns,
8660 (*images)->page.height != 0 ? (*images)->page.height :
8661 (*images)->rows,(*images)->gravity,&geometry);
8662 compose=OverCompositeOp;
8663 option=GetImageOption(mogrify_info,
"compose");
8664 if (option != (
const char *) NULL)
8665 compose=(CompositeOperator) ParseCommandOption(
8666 MagickComposeOptions,MagickFalse,option);
8667 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8669 source=DestroyImageList(source);
8673 if (layers == (Image *) NULL)
8675 *images=DestroyImageList(*images);
8683 if (LocaleCompare(
"map",option+1) == 0)
8685 (void) SyncImagesSettings(mogrify_info,*images,exception);
8688 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8695 if (LocaleCompare(
"maximum",option+1) == 0)
8703 (void) SyncImagesSettings(mogrify_info,*images,exception);
8704 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8705 if (maximum_image == (Image *) NULL)
8710 *images=DestroyImageList(*images);
8711 *images=maximum_image;
8714 if (LocaleCompare(
"minimum",option+1) == 0)
8722 (void) SyncImagesSettings(mogrify_info,*images,exception);
8723 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8724 if (minimum_image == (Image *) NULL)
8729 *images=DestroyImageList(*images);
8730 *images=minimum_image;
8733 if (LocaleCompare(
"morph",option+1) == 0)
8738 (void) SyncImagesSettings(mogrify_info,*images,exception);
8739 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8741 if (morph_image == (Image *) NULL)
8746 *images=DestroyImageList(*images);
8747 *images=morph_image;
8750 if (LocaleCompare(
"mosaic",option+1) == 0)
8755 (void) SyncImagesSettings(mogrify_info,*images,exception);
8756 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8757 if (mosaic_image == (Image *) NULL)
8762 *images=DestroyImageList(*images);
8763 *images=mosaic_image;
8770 if (LocaleCompare(
"poly",option+1) == 0)
8774 token[MagickPathExtent];
8794 (void) SyncImageSettings(mogrify_info,*images,exception);
8795 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8797 if (args == (
char *) NULL)
8800 for (x=0; *p !=
'\0'; x++)
8802 (void) GetNextToken(p,&p,MagickPathExtent,token);
8804 (void) GetNextToken(p,&p,MagickPathExtent,token);
8806 number_arguments=(size_t) x;
8807 arguments=(
double *) AcquireQuantumMemory(number_arguments,
8808 sizeof(*arguments));
8809 if (arguments == (
double *) NULL)
8810 ThrowWandFatalException(ResourceLimitFatalError,
8811 "MemoryAllocationFailed",(*images)->filename);
8812 (void) memset(arguments,0,number_arguments*
8813 sizeof(*arguments));
8815 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
8817 (void) GetNextToken(p,&p,MagickPathExtent,token);
8819 (void) GetNextToken(p,&p,MagickPathExtent,token);
8820 arguments[x]=StringToDouble(token,(
char **) NULL);
8822 args=DestroyString(args);
8823 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8824 arguments,exception);
8825 arguments=(
double *) RelinquishMagickMemory(arguments);
8826 if (polynomial_image == (Image *) NULL)
8831 *images=DestroyImageList(*images);
8832 *images=polynomial_image;
8834 if (LocaleCompare(
"print",option+1) == 0)
8839 (void) SyncImagesSettings(mogrify_info,*images,exception);
8840 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8842 if (
string == (
char *) NULL)
8844 (void) FormatLocaleFile(stdout,
"%s",
string);
8845 string=DestroyString(
string);
8847 if (LocaleCompare(
"process",option+1) == 0)
8849#define DestroyArguments(arguments,number_arguments) \
8853 for ( ; j < (ssize_t) (number_arguments); j++) \
8854 (arguments)[j]=DestroyString((arguments)[j]); \
8855 (arguments)=(char **) RelinquishMagickMemory(arguments); \
8864 (void) SyncImagesSettings(mogrify_info,*images,exception);
8865 arguments=StringToArgv(argv[i+1],&number_arguments);
8866 if ((arguments == (
char **) NULL) || (number_arguments == 1))
8868 DestroyArguments(arguments,number_arguments);
8871 if ((argc > 1) && (strchr(arguments[1],
'=') != (
char *) NULL))
8894 length=strlen(argv[i+1]);
8895 token=(
char *) NULL;
8896 if (~length >= (MagickPathExtent-1))
8897 token=(
char *) AcquireQuantumMemory(length+MagickPathExtent,
8899 if (token == (
char *) NULL)
8901 DestroyArguments(arguments,number_arguments);
8906 token_info=AcquireTokenInfo();
8907 token_status=Tokenizer(token_info,0,token,length,argument,
"",
8908 "=",
"\"",
'\0',&breaker,&next,"e);
8909 token_info=DestroyTokenInfo(token_info);
8910 if (token_status == 0)
8915 arg=(&(argument[next]));
8916 (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
8919 token=DestroyString(token);
8920 DestroyArguments(arguments,number_arguments);
8923 (void) SubstituteString(&arguments[1],
"-",
"");
8924 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8925 number_arguments-2,(
const char **) arguments+2,exception);
8926 DestroyArguments(arguments,number_arguments);
8933 if (LocaleCompare(
"reverse",option+1) == 0)
8935 ReverseImageList(images);
8942 if (LocaleCompare(
"shuffle",option+1) == 0)
8947 (void) SyncImagesSettings(mogrify_info,*images,exception);
8948 shuffle_type=(ShuffleMode) ParseCommandOption(
8949 MagickShuffleOptions,MagickFalse,argv[i+1]);
8950 (void) ShuffleImages(&(*images),shuffle_type,exception);
8953 if (LocaleCompare(
"smush",option+1) == 0)
8961 (void) SyncImagesSettings(mogrify_info,*images,exception);
8962 offset=(ssize_t) StringToLong(argv[i+1]);
8963 smush_image=SmushImages(*images,*option ==
'-' ? MagickTrue :
8964 MagickFalse,offset,exception);
8965 if (smush_image == (Image *) NULL)
8970 *images=DestroyImageList(*images);
8971 *images=smush_image;
8974 if (LocaleCompare(
"swap",option+1) == 0)
8996 flags=ParseGeometry(argv[i+1],&geometry_info);
8997 index=(ssize_t) geometry_info.rho;
8998 if ((flags & SigmaValue) != 0)
8999 swap_index=(ssize_t) geometry_info.sigma;
9001 p=GetImageFromList(*images,index);
9002 q=GetImageFromList(*images,swap_index);
9003 if ((p == (Image *) NULL) || (q == (Image *) NULL))
9005 (void) ThrowMagickException(exception,GetMagickModule(),
9006 OptionError,
"NoSuchImage",
"`%s'",(*images)->filename);
9012 u=CloneImage(p,0,0,MagickTrue,exception);
9013 if (u == (Image *) NULL)
9015 v=CloneImage(q,0,0,MagickTrue,exception);
9016 if (v == (Image *) NULL)
9021 ReplaceImageInList(&p,v);
9022 ReplaceImageInList(&q,u);
9023 *images=GetFirstImageInList(q);
9030 if (LocaleCompare(
"write",option+1) == 0)
9033 key[MagickPathExtent];
9041 (void) SyncImagesSettings(mogrify_info,*images,exception);
9042 (void) FormatLocaleString(key,MagickPathExtent,
"cache:%s",
9044 (void) DeleteImageRegistry(key);
9045 write_images=CloneImageList(*images,exception);
9046 write_info=CloneImageInfo(mogrify_info);
9047 status&=(MagickStatusType) WriteImages(write_info,write_images,
9048 argv[i+1],exception);
9049 write_info=DestroyImageInfo(write_info);
9050 write_images=DestroyImageList(write_images);
9060 quantize_info=DestroyQuantizeInfo(quantize_info);
9061 mogrify_info=DestroyImageInfo(mogrify_info);
9062 status&=(MagickStatusType) MogrifyImageInfo(image_info,argc,argv,exception);
9063 return(status != 0 ? MagickTrue : MagickFalse);
9103WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
9104 const MagickBooleanType post,
const int argc,
const char **argv,
9105 Image **images,ExceptionInfo *exception)
9107#define MogrifyImageTag "Mogrify/Image"
9121 assert(image_info != (ImageInfo *) NULL);
9122 assert(image_info->signature == MagickCoreSignature);
9123 if (images == (Image **) NULL)
9124 return(MogrifyImage(image_info,argc,argv,images,exception));
9125 assert((*images)->previous == (Image *) NULL);
9126 assert((*images)->signature == MagickCoreSignature);
9127 if (IsEventLogging() != MagickFalse)
9128 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
9129 (*images)->filename);
9130 if ((argc <= 0) || (*argv == (
char *) NULL))
9132 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
9136 (void) FormatLocaleFile(stderr,
"mogrify start %s %d (%s)\n",argv[0],argc,
9142 if (post == MagickFalse)
9143 status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9149 n=GetImageListLength(*images);
9153 (void) FormatLocaleFile(stderr,
"mogrify %ld of %ld\n",(
long)
9154 GetImageIndexInList(*images),(
long)GetImageListLength(*images));
9156 status&=(MagickStatusType) MogrifyImage(image_info,argc,argv,images,
9158 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
9159 if (proceed == MagickFalse)
9161 if ( (*images)->next == (Image *) NULL )
9163 *images=(*images)->next;
9166 assert( *images != (Image *) NULL );
9168 (void) FormatLocaleFile(stderr,
"mogrify end %ld of %ld\n",(
long)
9169 GetImageIndexInList(*images),(
long)GetImageListLength(*images));
9174 *images=GetFirstImageInList(*images);
9175 if (post != MagickFalse)
9176 status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9178 return(status != 0 ? MagickTrue : MagickFalse);