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,
864 if (LocaleCompare(
"channel",option+1) == 0)
869 (void) SyncImageSettings(mogrify_info,*image,exception);
872 (void) SetPixelChannelMask(*image,DefaultChannels);
875 channel=(ChannelType) ParseChannelOption(argv[i+1]);
876 (void) SetPixelChannelMask(*image,channel);
879 if (LocaleCompare(
"charcoal",option+1) == 0)
884 (void) SyncImageSettings(mogrify_info,*image,exception);
885 flags=ParseGeometry(argv[i+1],&geometry_info);
886 if ((flags & SigmaValue) == 0)
887 geometry_info.sigma=1.0;
888 if ((flags & XiValue) == 0)
889 geometry_info.xi=1.0;
890 mogrify_image=CharcoalImage(*image,geometry_info.rho,
891 geometry_info.sigma,exception);
894 if (LocaleCompare(
"chop",option+1) == 0)
899 (void) SyncImageSettings(mogrify_info,*image,exception);
900 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
901 mogrify_image=ChopImage(*image,&geometry,exception);
904 if (LocaleCompare(
"clahe",option+1) == 0)
909 (void) SyncImageSettings(mogrify_info,*image,exception);
910 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
911 flags=ParseGeometry(argv[i+1],&geometry_info);
912 (void) CLAHEImage(*image,geometry.width,geometry.height,
913 (
size_t) geometry.x,geometry_info.psi,exception);
916 if (LocaleCompare(
"clip",option+1) == 0)
918 (void) SyncImageSettings(mogrify_info,*image,exception);
921 (void) SetImageMask(*image,WritePixelMask,(
const Image *) NULL,
925 (void) ClipImage(*image,exception);
928 if (LocaleCompare(
"clip-mask",option+1) == 0)
933 (void) SyncImageSettings(mogrify_info,*image,exception);
939 (void) SetImageMask(*image,WritePixelMask,(
const Image *) NULL,
946 clip_mask=GetImageCache(mogrify_info,argv[i+1],exception);
947 if (clip_mask == (Image *) NULL)
949 (void) SetImageMask(*image,WritePixelMask,clip_mask,exception);
950 clip_mask=DestroyImage(clip_mask);
953 if (LocaleCompare(
"clip-path",option+1) == 0)
955 (void) SyncImageSettings(mogrify_info,*image,exception);
956 (void) ClipImagePath(*image,argv[i+1],*option ==
'-' ? MagickTrue :
957 MagickFalse,exception);
960 if (LocaleCompare(
"colorize",option+1) == 0)
965 (void) SyncImageSettings(mogrify_info,*image,exception);
966 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
969 if (LocaleCompare(
"color-matrix",option+1) == 0)
974 (void) SyncImageSettings(mogrify_info,*image,exception);
975 kernel=AcquireKernelInfo(argv[i+1],exception);
976 if (kernel == (KernelInfo *) NULL)
979 mogrify_image=ColorMatrixImage(*image,kernel,exception);
980 kernel=DestroyKernelInfo(kernel);
983 if (LocaleCompare(
"colors",option+1) == 0)
988 (void) SyncImageSettings(mogrify_info,*image,exception);
989 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
990 if (quantize_info->number_colors == 0)
992 if (((*image)->storage_class == DirectClass) ||
993 (*image)->colors > quantize_info->number_colors)
994 (void) QuantizeImage(quantize_info,*image,exception);
996 (
void) CompressImageColormap(*image,exception);
999 if (LocaleCompare(
"colorspace",option+1) == 0)
1004 (void) SyncImageSettings(mogrify_info,*image,exception);
1007 (void) TransformImageColorspace(*image,sRGBColorspace,
1011 colorspace=(ColorspaceType) ParseCommandOption(
1012 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1013 (void) TransformImageColorspace(*image,colorspace,exception);
1016 if (LocaleCompare(
"color-threshold",option+1) == 0)
1025 (void) SyncImageSettings(mogrify_info,*image,exception);
1027 (void) GetColorRange(
"white-black",&start,&stop,exception);
1029 (
void) GetColorRange(argv[i+1],&start,&stop,exception);
1030 (void) ColorThresholdImage(*image,&start,&stop,exception);
1033 if (LocaleCompare(
"compose",option+1) == 0)
1035 (void) SyncImageSettings(mogrify_info,*image,exception);
1036 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1037 MagickFalse,argv[i+1]);
1040 if (LocaleCompare(
"connected-components",option+1) == 0)
1042 (void) SyncImageSettings(mogrify_info,*image,exception);
1043 mogrify_image=ConnectedComponentsImage(*image,(
size_t)
1044 StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);
1047 if (LocaleCompare(
"contrast",option+1) == 0)
1049 (void) SyncImageSettings(mogrify_info,*image,exception);
1050 (void) ContrastImage(*image,(*option ==
'-') ? MagickTrue :
1051 MagickFalse,exception);
1054 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
1063 (void) SyncImageSettings(mogrify_info,*image,exception);
1064 flags=ParseGeometry(argv[i+1],&geometry_info);
1065 black_point=geometry_info.rho;
1066 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1068 if ((flags & PercentValue) != 0)
1070 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1071 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1073 white_point=(double) (*image)->columns*(*image)->rows-
1075 (void) ContrastStretchImage(*image,black_point,white_point,
1079 if (LocaleCompare(
"convolve",option+1) == 0)
1093 (void) SyncImageSettings(mogrify_info,*image,exception);
1094 kernel_info=AcquireKernelInfo(argv[i+1],exception);
1095 if (kernel_info == (KernelInfo *) NULL)
1097 extent=kernel_info->width*kernel_info->height;
1099 for (j=0; j < (ssize_t) extent; j++)
1100 gamma+=kernel_info->values[j];
1101 gamma=1.0/(fabs((
double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1102 for (j=0; j < (ssize_t) extent; j++)
1103 kernel_info->values[j]*=gamma;
1104 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1105 kernel_info,exception);
1106 kernel_info=DestroyKernelInfo(kernel_info);
1109 if (LocaleCompare(
"crop",option+1) == 0)
1114 (void) SyncImageSettings(mogrify_info,*image,exception);
1115 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1118 if (LocaleCompare(
"cycle",option+1) == 0)
1123 (void) SyncImageSettings(mogrify_info,*image,exception);
1124 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1132 if (LocaleCompare(
"decipher",option+1) == 0)
1140 (void) SyncImageSettings(mogrify_info,*image,exception);
1141 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1142 if (passkey != (StringInfo *) NULL)
1144 (void) PasskeyDecipherImage(*image,passkey,exception);
1145 passkey=DestroyStringInfo(passkey);
1149 if (LocaleCompare(
"density",option+1) == 0)
1154 (void) CloneString(&draw_info->density,argv[i+1]);
1157 if (LocaleCompare(
"depth",option+1) == 0)
1159 (void) SyncImageSettings(mogrify_info,*image,exception);
1162 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1165 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1169 if (LocaleCompare(
"deskew",option+1) == 0)
1177 (void) SyncImageSettings(mogrify_info,*image,exception);
1179 threshold=40.0*(double) QuantumRange/100.0;
1181 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
1183 mogrify_image=DeskewImage(*image,threshold,exception);
1186 if (LocaleCompare(
"despeckle",option+1) == 0)
1191 (void) SyncImageSettings(mogrify_info,*image,exception);
1192 mogrify_image=DespeckleImage(*image,exception);
1195 if (LocaleCompare(
"display",option+1) == 0)
1197 (void) CloneString(&draw_info->server_name,argv[i+1]);
1200 if (LocaleCompare(
"distort",option+1) == 0)
1204 token[MagickPathExtent];
1224 (void) SyncImageSettings(mogrify_info,*image,exception);
1225 method=(DistortMethod) ParseCommandOption(MagickDistortOptions,
1226 MagickFalse,argv[i+1]);
1227 if (method == ResizeDistortion)
1236 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1238 resize_args[0]=(double) geometry.width;
1239 resize_args[1]=(double) geometry.height;
1240 mogrify_image=DistortImage(*image,method,(
size_t)2,
1241 resize_args,MagickTrue,exception);
1244 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1246 if (args == (
char *) NULL)
1249 for (x=0; *p !=
'\0'; x++)
1251 (void) GetNextToken(p,&p,MagickPathExtent,token);
1253 (void) GetNextToken(p,&p,MagickPathExtent,token);
1255 number_arguments=(size_t) x;
1256 arguments=(
double *) AcquireQuantumMemory(number_arguments,
1257 sizeof(*arguments));
1258 if (arguments == (
double *) NULL)
1259 ThrowWandFatalException(ResourceLimitFatalError,
1260 "MemoryAllocationFailed",(*image)->filename);
1261 (void) memset(arguments,0,number_arguments*
1262 sizeof(*arguments));
1264 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
1266 (void) GetNextToken(p,&p,MagickPathExtent,token);
1268 (void) GetNextToken(p,&p,MagickPathExtent,token);
1269 arguments[x]=StringToDouble(token,(
char **) NULL);
1271 args=DestroyString(args);
1272 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1273 (*option ==
'+') ? MagickTrue : MagickFalse,exception);
1274 arguments=(
double *) RelinquishMagickMemory(arguments);
1277 if (LocaleCompare(
"dither",option+1) == 0)
1281 quantize_info->dither_method=NoDitherMethod;
1284 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1285 MagickDitherOptions,MagickFalse,argv[i+1]);
1288 if (LocaleCompare(
"draw",option+1) == 0)
1293 (void) SyncImageSettings(mogrify_info,*image,exception);
1294 (void) CloneString(&draw_info->primitive,argv[i+1]);
1295 (void) DrawImage(*image,draw_info,exception);
1302 if (LocaleCompare(
"edge",option+1) == 0)
1307 (void) SyncImageSettings(mogrify_info,*image,exception);
1308 flags=ParseGeometry(argv[i+1],&geometry_info);
1309 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1312 if (LocaleCompare(
"emboss",option+1) == 0)
1317 (void) SyncImageSettings(mogrify_info,*image,exception);
1318 flags=ParseGeometry(argv[i+1],&geometry_info);
1319 if ((flags & SigmaValue) == 0)
1320 geometry_info.sigma=1.0;
1321 mogrify_image=EmbossImage(*image,geometry_info.rho,
1322 geometry_info.sigma,exception);
1325 if (LocaleCompare(
"encipher",option+1) == 0)
1333 (void) SyncImageSettings(mogrify_info,*image,exception);
1334 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1335 if (passkey != (StringInfo *) NULL)
1337 (void) PasskeyEncipherImage(*image,passkey,exception);
1338 passkey=DestroyStringInfo(passkey);
1342 if (LocaleCompare(
"encoding",option+1) == 0)
1344 (void) CloneString(&draw_info->encoding,argv[i+1]);
1347 if (LocaleCompare(
"enhance",option+1) == 0)
1352 (void) SyncImageSettings(mogrify_info,*image,exception);
1353 mogrify_image=EnhanceImage(*image,exception);
1356 if (LocaleCompare(
"equalize",option+1) == 0)
1361 (void) SyncImageSettings(mogrify_info,*image,exception);
1362 (void) EqualizeImage(*image,exception);
1365 if (LocaleCompare(
"evaluate",option+1) == 0)
1370 MagickEvaluateOperator
1373 (void) SyncImageSettings(mogrify_info,*image,exception);
1374 op=(MagickEvaluateOperator) ParseCommandOption(
1375 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1376 constant=StringToDoubleInterval(argv[i+2],(
double) QuantumRange+
1378 (void) EvaluateImage(*image,op,constant,exception);
1381 if (LocaleCompare(
"extent",option+1) == 0)
1386 (void) SyncImageSettings(mogrify_info,*image,exception);
1387 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1388 if (geometry.width == 0)
1389 geometry.width=(*image)->columns;
1390 if (geometry.height == 0)
1391 geometry.height=(*image)->rows;
1392 mogrify_image=ExtentImage(*image,&geometry,exception);
1399 if (LocaleCompare(
"family",option+1) == 0)
1403 if (draw_info->family != (
char *) NULL)
1404 draw_info->family=DestroyString(draw_info->family);
1407 (void) SetImageOption(image_info,option+1,argv[i+1]);
1408 (void) CloneString(&draw_info->family,argv[i+1]);
1411 if (LocaleCompare(
"features",option+1) == 0)
1415 (void) DeleteImageArtifact(*image,
"identify:features");
1418 (void) SetImageArtifact(*image,
"identify:features",argv[i+1]);
1419 (void) SetImageArtifact(*image,
"verbose",
"true");
1422 if (LocaleCompare(
"fill",option+1) == 0)
1430 GetPixelInfo(*image,&fill);
1433 (void) QueryColorCompliance(
"none",AllCompliance,&fill,
1435 draw_info->fill=fill;
1436 if (draw_info->fill_pattern != (Image *) NULL)
1437 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1440 sans=AcquireExceptionInfo();
1441 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1442 sans=DestroyExceptionInfo(sans);
1443 if (status == MagickFalse)
1444 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1447 draw_info->fill=fill=color;
1450 if (LocaleCompare(
"flip",option+1) == 0)
1455 (void) SyncImageSettings(mogrify_info,*image,exception);
1456 mogrify_image=FlipImage(*image,exception);
1459 if (LocaleCompare(
"floodfill",option+1) == 0)
1467 (void) SyncImageSettings(mogrify_info,*image,exception);
1468 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1469 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1471 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1472 geometry.y,*option ==
'-' ? MagickFalse : MagickTrue,exception);
1475 if (LocaleCompare(
"flop",option+1) == 0)
1480 (void) SyncImageSettings(mogrify_info,*image,exception);
1481 mogrify_image=FlopImage(*image,exception);
1484 if (LocaleCompare(
"font",option+1) == 0)
1488 if (draw_info->font != (
char *) NULL)
1489 draw_info->font=DestroyString(draw_info->font);
1492 (void) CloneString(&draw_info->font,argv[i+1]);
1495 if (LocaleCompare(
"format",option+1) == 0)
1500 if (LocaleCompare(
"frame",option+1) == 0)
1508 (void) SyncImageSettings(mogrify_info,*image,exception);
1509 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1510 frame_info.width=geometry.width;
1511 frame_info.height=geometry.height;
1512 frame_info.outer_bevel=geometry.x;
1513 frame_info.inner_bevel=geometry.y;
1514 frame_info.x=(ssize_t) frame_info.width;
1515 frame_info.y=(ssize_t) frame_info.height;
1516 frame_info.width=(*image)->columns+2*frame_info.width;
1517 frame_info.height=(*image)->rows+2*frame_info.height;
1518 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1521 if (LocaleCompare(
"function",option+1) == 0)
1525 token[MagickPathExtent];
1545 (void) SyncImageSettings(mogrify_info,*image,exception);
1546 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1547 MagickFalse,argv[i+1]);
1548 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1550 if (arguments == (
char *) NULL)
1552 p=(
char *) arguments;
1553 for (x=0; *p !=
'\0'; x++)
1555 (void) GetNextToken(p,&p,MagickPathExtent,token);
1557 (void) GetNextToken(p,&p,MagickPathExtent,token);
1559 number_parameters=(size_t) x;
1560 parameters=(
double *) AcquireQuantumMemory(number_parameters,
1561 sizeof(*parameters));
1562 if (parameters == (
double *) NULL)
1563 ThrowWandFatalException(ResourceLimitFatalError,
1564 "MemoryAllocationFailed",(*image)->filename);
1565 (void) memset(parameters,0,number_parameters*
1566 sizeof(*parameters));
1567 p=(
char *) arguments;
1568 for (x=0; (x < (ssize_t) number_parameters) && (*p !=
'\0'); x++)
1570 (void) GetNextToken(p,&p,MagickPathExtent,token);
1572 (void) GetNextToken(p,&p,MagickPathExtent,token);
1573 parameters[x]=StringToDouble(token,(
char **) NULL);
1575 arguments=DestroyString(arguments);
1576 (void) FunctionImage(*image,function,number_parameters,parameters,
1578 parameters=(
double *) RelinquishMagickMemory(parameters);
1585 if (LocaleCompare(
"gamma",option+1) == 0)
1590 (void) SyncImageSettings(mogrify_info,*image,exception);
1592 (*image)->gamma=StringToDouble(argv[i+1],(
char **) NULL);
1594 (
void) GammaImage(*image,StringToDouble(argv[i+1],(
char **) NULL),
1598 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
1599 (LocaleCompare(
"gaussian",option+1) == 0))
1604 (void) SyncImageSettings(mogrify_info,*image,exception);
1605 flags=ParseGeometry(argv[i+1],&geometry_info);
1606 if ((flags & SigmaValue) == 0)
1607 geometry_info.sigma=1.0;
1608 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1609 geometry_info.sigma,exception);
1612 if (LocaleCompare(
"geometry",option+1) == 0)
1617 (void) SyncImageSettings(mogrify_info,*image,exception);
1620 if ((*image)->geometry != (
char *) NULL)
1621 (*image)->geometry=DestroyString((*image)->geometry);
1624 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1625 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1626 (void) CloneString(&(*image)->geometry,argv[i+1]);
1628 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1629 (*image)->filter,exception);
1632 if (LocaleCompare(
"gravity",option+1) == 0)
1636 draw_info->gravity=UndefinedGravity;
1639 draw_info->gravity=(GravityType) ParseCommandOption(
1640 MagickGravityOptions,MagickFalse,argv[i+1]);
1643 if (LocaleCompare(
"grayscale",option+1) == 0)
1645 PixelIntensityMethod
1648 (void) SyncImageSettings(mogrify_info,*image,exception);
1649 method=(PixelIntensityMethod) ParseCommandOption(
1650 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1651 (void) GrayscaleImage(*image,method,exception);
1658 if (LocaleCompare(
"highlight-color",option+1) == 0)
1660 (void) SetImageArtifact(*image,
"compare:highlight-color",argv[i+1]);
1663 if (LocaleCompare(
"hough-lines",option+1) == 0)
1668 (void) SyncImageSettings(mogrify_info,*image,exception);
1669 flags=ParseGeometry(argv[i+1],&geometry_info);
1670 if ((flags & SigmaValue) == 0)
1671 geometry_info.sigma=geometry_info.rho;
1672 if ((flags & XiValue) == 0)
1673 geometry_info.xi=40;
1674 mogrify_image=HoughLineImage(*image,(
size_t) geometry_info.rho,
1675 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,exception);
1682 if (LocaleCompare(
"identify",option+1) == 0)
1687 (void) SyncImageSettings(mogrify_info,*image,exception);
1688 if (format == (
char *) NULL)
1690 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1694 text=InterpretImageProperties(mogrify_info,*image,format,exception);
1695 if (text == (
char *) NULL)
1697 (void) fputs(text,stdout);
1698 text=DestroyString(text);
1701 if (LocaleCompare(
"illuminant",option+1) == 0)
1703 (void) SetImageArtifact(*image,
"color:illuminant",argv[i+1]);
1706 if (LocaleCompare(
"implode",option+1) == 0)
1711 (void) SyncImageSettings(mogrify_info,*image,exception);
1712 (void) ParseGeometry(argv[i+1],&geometry_info);
1713 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1714 interpolate_method,exception);
1717 if (LocaleCompare(
"integral",option+1) == 0)
1719 (void) SyncImageSettings(mogrify_info,*image,exception);
1720 mogrify_image=IntegralImage(*image,exception);
1723 if (LocaleCompare(
"interline-spacing",option+1) == 0)
1726 (void) ParseGeometry(
"0",&geometry_info);
1728 (
void) ParseGeometry(argv[i+1],&geometry_info);
1729 draw_info->interline_spacing=geometry_info.rho;
1732 if (LocaleCompare(
"interpolate",option+1) == 0)
1734 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1735 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1738 if (LocaleCompare(
"interword-spacing",option+1) == 0)
1741 (void) ParseGeometry(
"0",&geometry_info);
1743 (
void) ParseGeometry(argv[i+1],&geometry_info);
1744 draw_info->interword_spacing=geometry_info.rho;
1747 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
1752 (void) SyncImageSettings(mogrify_info,*image,exception);
1753 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1754 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1755 geometry.height,interpolate_method,exception);
1762 if (LocaleCompare(
"kerning",option+1) == 0)
1765 (void) ParseGeometry(
"0",&geometry_info);
1767 (
void) ParseGeometry(argv[i+1],&geometry_info);
1768 draw_info->kerning=geometry_info.rho;
1771 if (LocaleCompare(
"kmeans",option+1) == 0)
1776 (void) SyncImageSettings(mogrify_info,*image,exception);
1777 flags=ParseGeometry(argv[i+1],&geometry_info);
1778 if ((flags & SigmaValue) == 0)
1779 geometry_info.sigma=300.0;
1780 if ((flags & XiValue) == 0)
1781 geometry_info.xi=0.0001;
1782 (void) KmeansImage(*image,(
size_t) geometry_info.rho,
1783 (
size_t) geometry_info.sigma,geometry_info.xi,exception);
1786 if (LocaleCompare(
"kuwahara",option+1) == 0)
1791 (void) SyncImageSettings(mogrify_info,*image,exception);
1792 flags=ParseGeometry(argv[i+1],&geometry_info);
1793 if ((flags & SigmaValue) == 0)
1794 geometry_info.sigma=geometry_info.rho-0.5;
1795 mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1796 geometry_info.sigma,exception);
1803 if (LocaleCompare(
"lat",option+1) == 0)
1808 (void) SyncImageSettings(mogrify_info,*image,exception);
1809 flags=ParseGeometry(argv[i+1],&geometry_info);
1810 if ((flags & PercentValue) != 0)
1811 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1812 mogrify_image=AdaptiveThresholdImage(*image,(
size_t)
1813 geometry_info.rho,(
size_t) geometry_info.sigma,(
double)
1814 geometry_info.xi,exception);
1817 if (LocaleCompare(
"level",option+1) == 0)
1827 (void) SyncImageSettings(mogrify_info,*image,exception);
1828 flags=ParseGeometry(argv[i+1],&geometry_info);
1829 black_point=geometry_info.rho;
1830 white_point=(double) QuantumRange;
1831 if ((flags & SigmaValue) != 0)
1832 white_point=geometry_info.sigma;
1834 if ((flags & XiValue) != 0)
1835 gamma=geometry_info.xi;
1836 if ((flags & PercentValue) != 0)
1838 black_point*=(double) QuantumRange/100.0;
1839 white_point*=(double) QuantumRange/100.0;
1841 if ((flags & SigmaValue) == 0)
1842 white_point=(double) QuantumRange-black_point;
1843 if ((*option ==
'+') || ((flags & AspectValue) != 0))
1844 (void) LevelizeImage(*image,black_point,white_point,gamma,
1847 (
void) LevelImage(*image,black_point,white_point,gamma,exception);
1850 if (LocaleCompare(
"level-colors",option+1) == 0)
1853 token[MagickPathExtent];
1862 p=(
const char *) argv[i+1];
1863 (void) GetNextToken(p,&p,MagickPathExtent,token);
1864 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
1865 (void) QueryColorCompliance(token,AllCompliance,&black_point,
1868 (
void) QueryColorCompliance(
"#000000",AllCompliance,&black_point,
1870 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
1871 (void) GetNextToken(p,&p,MagickPathExtent,token);
1873 white_point=black_point;
1876 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
1877 (void) GetNextToken(p,&p,MagickPathExtent,token);
1878 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
1879 (void) QueryColorCompliance(token,AllCompliance,&white_point,
1882 (
void) QueryColorCompliance(
"#ffffff",AllCompliance,
1883 &white_point,exception);
1885 (void) LevelImageColors(*image,&black_point,&white_point,
1886 *option ==
'+' ? MagickTrue : MagickFalse,exception);
1889 if (LocaleCompare(
"linear-stretch",option+1) == 0)
1895 (void) SyncImageSettings(mogrify_info,*image,exception);
1896 flags=ParseGeometry(argv[i+1],&geometry_info);
1897 black_point=geometry_info.rho;
1898 white_point=(double) (*image)->columns*(*image)->rows;
1899 if ((flags & SigmaValue) != 0)
1900 white_point=geometry_info.sigma;
1901 if ((flags & PercentValue) != 0)
1903 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1904 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1906 if ((flags & SigmaValue) == 0)
1907 white_point=(double) (*image)->columns*(*image)->rows-
1909 (void) LinearStretchImage(*image,black_point,white_point,exception);
1912 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
1917 (void) SyncImageSettings(mogrify_info,*image,exception);
1918 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1919 if ((flags & XValue) == 0)
1921 if ((flags & YValue) == 0)
1923 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1924 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1927 if (LocaleCompare(
"local-contrast",option+1) == 0)
1929 (void) SyncImageSettings(mogrify_info,*image,exception);
1930 flags=ParseGeometry(argv[i+1],&geometry_info);
1931 if ((flags & RhoValue) == 0)
1932 geometry_info.rho=10;
1933 if ((flags & SigmaValue) == 0)
1934 geometry_info.sigma=12.5;
1935 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
1936 geometry_info.sigma,exception);
1939 if (LocaleCompare(
"lowlight-color",option+1) == 0)
1941 (void) SetImageArtifact(*image,
"compare:lowlight-color",argv[i+1]);
1948 if (LocaleCompare(
"magnify",option+1) == 0)
1953 (void) SyncImageSettings(mogrify_info,*image,exception);
1954 mogrify_image=MagnifyImage(*image,exception);
1957 if (LocaleCompare(
"map",option+1) == 0)
1965 (void) SyncImageSettings(mogrify_info,*image,exception);
1968 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
1969 if (remap_image == (Image *) NULL)
1971 (void) RemapImage(quantize_info,*image,remap_image,exception);
1972 remap_image=DestroyImage(remap_image);
1975 if (LocaleCompare(
"mask",option+1) == 0)
1980 (void) SyncImageSettings(mogrify_info,*image,exception);
1986 (void) SetImageMask(*image,WritePixelMask,(
const Image *) NULL,
1993 mask=GetImageCache(mogrify_info,argv[i+1],exception);
1994 if (mask == (Image *) NULL)
1996 (void) SetImageMask(*image,WritePixelMask,mask,exception);
1997 mask=DestroyImage(mask);
2000 if (LocaleCompare(
"matte",option+1) == 0)
2002 (void) SetImageAlphaChannel(*image,(*option ==
'-') ?
2003 SetAlphaChannel : DeactivateAlphaChannel,exception);
2006 if (LocaleCompare(
"mean-shift",option+1) == 0)
2011 (void) SyncImageSettings(mogrify_info,*image,exception);
2012 flags=ParseGeometry(argv[i+1],&geometry_info);
2013 if ((flags & SigmaValue) == 0)
2014 geometry_info.sigma=geometry_info.rho;
2015 if ((flags & XiValue) == 0)
2016 geometry_info.xi=0.10*(double) QuantumRange;
2017 if ((flags & PercentValue) != 0)
2018 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2019 mogrify_image=MeanShiftImage(*image,(
size_t) geometry_info.rho,
2020 (
size_t) geometry_info.sigma,geometry_info.xi,exception);
2023 if (LocaleCompare(
"median",option+1) == 0)
2028 (void) SyncImageSettings(mogrify_info,*image,exception);
2029 flags=ParseGeometry(argv[i+1],&geometry_info);
2030 if ((flags & SigmaValue) == 0)
2031 geometry_info.sigma=geometry_info.rho;
2032 mogrify_image=StatisticImage(*image,MedianStatistic,(
size_t)
2033 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
2036 if (LocaleCompare(
"mode",option+1) == 0)
2041 (void) SyncImageSettings(mogrify_info,*image,exception);
2042 flags=ParseGeometry(argv[i+1],&geometry_info);
2043 if ((flags & SigmaValue) == 0)
2044 geometry_info.sigma=geometry_info.rho;
2045 mogrify_image=StatisticImage(*image,ModeStatistic,(
size_t)
2046 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
2049 if (LocaleCompare(
"modulate",option+1) == 0)
2051 (void) SyncImageSettings(mogrify_info,*image,exception);
2052 (void) ModulateImage(*image,argv[i+1],exception);
2055 if (LocaleCompare(
"moments",option+1) == 0)
2059 (void) DeleteImageArtifact(*image,
"identify:moments");
2062 (void) SetImageArtifact(*image,
"identify:moments",argv[i+1]);
2063 (void) SetImageArtifact(*image,
"verbose",
"true");
2066 if (LocaleCompare(
"monitor",option+1) == 0)
2070 (void) SetImageProgressMonitor(*image,
2071 (MagickProgressMonitor) NULL,(
void *) NULL);
2074 (void) SetImageProgressMonitor(*image,MonitorProgress,
2078 if (LocaleCompare(
"monochrome",option+1) == 0)
2080 (void) SyncImageSettings(mogrify_info,*image,exception);
2081 (void) SetImageType(*image,BilevelType,exception);
2084 if (LocaleCompare(
"morphology",option+1) == 0)
2087 token[MagickPathExtent];
2104 (void) SyncImageSettings(mogrify_info,*image,exception);
2106 (void) GetNextToken(p,&p,MagickPathExtent,token);
2107 method=(MorphologyMethod) ParseCommandOption(
2108 MagickMorphologyOptions,MagickFalse,token);
2110 (void) GetNextToken(p,&p,MagickPathExtent,token);
2111 if ((*p ==
':') || (*p ==
','))
2112 (void) GetNextToken(p,&p,MagickPathExtent,token);
2114 iterations=(ssize_t) StringToLong(p);
2115 kernel=AcquireKernelInfo(argv[i+2],exception);
2116 if (kernel == (KernelInfo *) NULL)
2118 (void) ThrowMagickException(exception,GetMagickModule(),
2119 OptionError,
"UnabletoParseKernel",
"morphology");
2123 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2125 kernel=DestroyKernelInfo(kernel);
2128 if (LocaleCompare(
"motion-blur",option+1) == 0)
2133 (void) SyncImageSettings(mogrify_info,*image,exception);
2134 flags=ParseGeometry(argv[i+1],&geometry_info);
2135 if ((flags & SigmaValue) == 0)
2136 geometry_info.sigma=1.0;
2137 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2138 geometry_info.sigma,geometry_info.xi,exception);
2145 if (LocaleCompare(
"negate",option+1) == 0)
2147 (void) SyncImageSettings(mogrify_info,*image,exception);
2148 (void) NegateImage(*image,*option ==
'+' ? MagickTrue :
2149 MagickFalse,exception);
2152 if (LocaleCompare(
"noise",option+1) == 0)
2154 (void) SyncImageSettings(mogrify_info,*image,exception);
2157 flags=ParseGeometry(argv[i+1],&geometry_info);
2158 if ((flags & SigmaValue) == 0)
2159 geometry_info.sigma=geometry_info.rho;
2160 mogrify_image=StatisticImage(*image,NonpeakStatistic,(
size_t)
2161 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
2168 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2169 MagickFalse,argv[i+1]);
2170 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2174 if (LocaleCompare(
"normalize",option+1) == 0)
2176 (void) SyncImageSettings(mogrify_info,*image,exception);
2177 (void) NormalizeImage(*image,exception);
2184 if (LocaleCompare(
"opaque",option+1) == 0)
2189 (void) SyncImageSettings(mogrify_info,*image,exception);
2190 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2192 (void) OpaquePaintImage(*image,&target,&fill,*option ==
'-' ?
2193 MagickFalse : MagickTrue,exception);
2196 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2198 (void) SyncImageSettings(mogrify_info,*image,exception);
2199 (void) OrderedDitherImage(*image,argv[i+1],exception);
2206 if (LocaleCompare(
"paint",option+1) == 0)
2208 (void) SyncImageSettings(mogrify_info,*image,exception);
2209 (void) ParseGeometry(argv[i+1],&geometry_info);
2210 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2211 geometry_info.sigma,exception);
2214 if (LocaleCompare(
"perceptible",option+1) == 0)
2219 (void) SyncImageSettings(mogrify_info,*image,exception);
2220 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2221 (
char **) NULL),exception);
2224 if (LocaleCompare(
"pointsize",option+1) == 0)
2227 (void) ParseGeometry(
"12",&geometry_info);
2229 (
void) ParseGeometry(argv[i+1],&geometry_info);
2230 draw_info->pointsize=geometry_info.rho;
2233 if (LocaleCompare(
"polaroid",option+1) == 0)
2247 (void) SyncImageSettings(mogrify_info,*image,exception);
2248 random_info=AcquireRandomInfo();
2249 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2250 random_info=DestroyRandomInfo(random_info);
2253 SetGeometryInfo(&geometry_info);
2254 flags=ParseGeometry(argv[i+1],&geometry_info);
2255 angle=geometry_info.rho;
2257 caption=GetImageProperty(*image,
"caption",exception);
2258 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2259 interpolate_method,exception);
2262 if (LocaleCompare(
"posterize",option+1) == 0)
2267 (void) SyncImageSettings(mogrify_info,*image,exception);
2268 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2269 quantize_info->dither_method,exception);
2272 if (LocaleCompare(
"preview",option+1) == 0)
2280 (void) SyncImageSettings(mogrify_info,*image,exception);
2282 preview_type=UndefinedPreview;
2284 preview_type=(PreviewType) ParseCommandOption(
2285 MagickPreviewOptions,MagickFalse,argv[i+1]);
2286 mogrify_image=PreviewImage(*image,preview_type,exception);
2289 if (LocaleCompare(
"profile",option+1) == 0)
2306 (void) SyncImageSettings(mogrify_info,*image,exception);
2312 (void) ProfileImage(*image,argv[i+1],(
const unsigned char *)
2319 profile_info=CloneImageInfo(mogrify_info);
2320 profile=GetImageProfile(*image,
"iptc");
2321 if (profile != (StringInfo *) NULL)
2322 profile_info->profile=(
void *) CloneStringInfo(profile);
2323 sans_exception=AcquireExceptionInfo();
2324 profile_image=GetImageCache(profile_info,argv[i+1],sans_exception);
2325 sans_exception=DestroyExceptionInfo(sans_exception);
2326 profile_info=DestroyImageInfo(profile_info);
2327 if (profile_image == (Image *) NULL)
2332 profile_info=CloneImageInfo(mogrify_info);
2333 (void) CopyMagickString(profile_info->filename,argv[i+1],
2335 file_data=FileToStringInfo(profile_info->filename,~0UL,
2337 if (file_data != (StringInfo *) NULL)
2339 (void) SetImageInfo(profile_info,0,exception);
2340 (void) ProfileImage(*image,profile_info->magick,
2341 GetStringInfoDatum(file_data),
2342 GetStringInfoLength(file_data),exception);
2343 file_data=DestroyStringInfo(file_data);
2345 profile_info=DestroyImageInfo(profile_info);
2348 ResetImageProfileIterator(profile_image);
2349 name=GetNextImageProfile(profile_image);
2350 while (name != (
const char *) NULL)
2352 profile=GetImageProfile(profile_image,name);
2353 if (profile != (StringInfo *) NULL)
2354 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2355 (
size_t) GetStringInfoLength(profile),exception);
2356 name=GetNextImageProfile(profile_image);
2358 profile_image=DestroyImage(profile_image);
2365 if (LocaleCompare(
"quantize",option+1) == 0)
2369 quantize_info->colorspace=UndefinedColorspace;
2372 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2373 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2380 if (LocaleCompare(
"rotational-blur",option+1) == 0)
2385 (void) SyncImageSettings(mogrify_info,*image,exception);
2386 flags=ParseGeometry(argv[i+1],&geometry_info);
2387 mogrify_image=RotationalBlurImage(*image,geometry_info.rho,
2391 if (LocaleCompare(
"raise",option+1) == 0)
2396 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2397 (void) RaiseImage(*image,&geometry,*option ==
'-' ? MagickTrue :
2398 MagickFalse,exception);
2401 if (LocaleCompare(
"random-threshold",option+1) == 0)
2410 (void) SyncImageSettings(mogrify_info,*image,exception);
2412 max_threshold=(double) QuantumRange;
2413 flags=ParseGeometry(argv[i+1],&geometry_info);
2414 min_threshold=geometry_info.rho;
2415 max_threshold=geometry_info.sigma;
2416 if ((flags & SigmaValue) == 0)
2417 max_threshold=min_threshold;
2418 if (strchr(argv[i+1],
'%') != (
char *) NULL)
2420 max_threshold*=0.01*(double) QuantumRange;
2421 min_threshold*=0.01*(double) QuantumRange;
2423 (void) RandomThresholdImage(*image,min_threshold,max_threshold,
2427 if (LocaleCompare(
"range-threshold",option+1) == 0)
2432 (void) SyncImageSettings(mogrify_info,*image,exception);
2433 flags=ParseGeometry(argv[i+1],&geometry_info);
2434 if ((flags & SigmaValue) == 0)
2435 geometry_info.sigma=geometry_info.rho;
2436 if ((flags & XiValue) == 0)
2437 geometry_info.xi=geometry_info.sigma;
2438 if ((flags & PsiValue) == 0)
2439 geometry_info.psi=geometry_info.xi;
2440 if (strchr(argv[i+1],
'%') != (
char *) NULL)
2442 geometry_info.rho*=0.01*(double) QuantumRange;
2443 geometry_info.sigma*=0.01*(double) QuantumRange;
2444 geometry_info.xi*=0.01*(double) QuantumRange;
2445 geometry_info.psi*=0.01*(double) QuantumRange;
2447 (void) RangeThresholdImage(*image,geometry_info.rho,
2448 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2451 if (LocaleCompare(
"read-mask",option+1) == 0)
2456 (void) SyncImageSettings(mogrify_info,*image,exception);
2462 (void) SetImageMask(*image,ReadPixelMask,(
const Image *) NULL,
2469 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2470 if (mask == (Image *) NULL)
2472 (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2473 mask=DestroyImage(mask);
2476 if (LocaleCompare(
"region",option+1) == 0)
2481 (void) SyncImageSettings(mogrify_info,*image,exception);
2484 (void) SetImageRegionMask(*image,WritePixelMask,
2485 (
const RectangleInfo *) NULL,exception);
2488 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2489 (void) SetImageRegionMask(*image,WritePixelMask,&geometry,
2493 if (LocaleCompare(
"render",option+1) == 0)
2495 (void) SyncImageSettings(mogrify_info,*image,exception);
2496 draw_info->render=(*option ==
'+') ? MagickTrue : MagickFalse;
2499 if (LocaleCompare(
"remap",option+1) == 0)
2507 (void) SyncImageSettings(mogrify_info,*image,exception);
2510 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2511 if (remap_image == (Image *) NULL)
2513 (void) RemapImage(quantize_info,*image,remap_image,exception);
2514 remap_image=DestroyImage(remap_image);
2517 if (LocaleCompare(
"repage",option+1) == 0)
2521 (void) ParseAbsoluteGeometry(
"0x0+0+0",&(*image)->page);
2524 (void) ResetImagePage(*image,argv[i+1]);
2527 if (LocaleCompare(
"resample",option+1) == 0)
2532 (void) SyncImageSettings(mogrify_info,*image,exception);
2533 flags=ParseGeometry(argv[i+1],&geometry_info);
2534 if ((flags & SigmaValue) == 0)
2535 geometry_info.sigma=geometry_info.rho;
2536 mogrify_image=ResampleImage(*image,geometry_info.rho,
2537 geometry_info.sigma,(*image)->filter,exception);
2540 if (LocaleCompare(
"reshape",option+1) == 0)
2545 (void) SyncImageSettings(mogrify_info,*image,exception);
2546 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2547 (void) ReshapePixelCache(*image,geometry.width,geometry.height,
2551 if (LocaleCompare(
"resize",option+1) == 0)
2556 (void) SyncImageSettings(mogrify_info,*image,exception);
2557 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2558 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2559 (*image)->filter,exception);
2562 if (LocaleCompare(
"roll",option+1) == 0)
2567 (void) SyncImageSettings(mogrify_info,*image,exception);
2568 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2569 if ((flags & PercentValue) != 0)
2571 geometry.x*=(ssize_t) ((*image)->columns/100.0);
2572 geometry.y*=(ssize_t) ((*image)->rows/100.0);
2574 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2577 if (LocaleCompare(
"rotate",option+1) == 0)
2585 (void) SyncImageSettings(mogrify_info,*image,exception);
2586 if (strchr(argv[i+1],
'>') != (
char *) NULL)
2587 if ((*image)->columns <= (*image)->rows)
2589 if (strchr(argv[i+1],
'<') != (
char *) NULL)
2590 if ((*image)->columns >= (*image)->rows)
2595 rotation=ConstantString(argv[i+1]);
2596 (void) SubstituteString(&rotation,
">",
"");
2597 (void) SubstituteString(&rotation,
"<",
"");
2598 (void) ParseGeometry(rotation,&geometry_info);
2599 rotation=DestroyString(rotation);
2600 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2607 if (LocaleCompare(
"sample",option+1) == 0)
2612 (void) SyncImageSettings(mogrify_info,*image,exception);
2613 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2614 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2618 if (LocaleCompare(
"scale",option+1) == 0)
2623 (void) SyncImageSettings(mogrify_info,*image,exception);
2624 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2625 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2629 if (LocaleCompare(
"selective-blur",option+1) == 0)
2634 (void) SyncImageSettings(mogrify_info,*image,exception);
2635 flags=ParseGeometry(argv[i+1],&geometry_info);
2636 if ((flags & PercentValue) != 0)
2637 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2638 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2639 geometry_info.sigma,geometry_info.xi,exception);
2642 if (LocaleCompare(
"separate",option+1) == 0)
2647 (void) SyncImageSettings(mogrify_info,*image,exception);
2648 mogrify_image=SeparateImages(*image,exception);
2651 if (LocaleCompare(
"sepia-tone",option+1) == 0)
2659 (void) SyncImageSettings(mogrify_info,*image,exception);
2660 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2662 mogrify_image=SepiaToneImage(*image,threshold,exception);
2665 if (LocaleCompare(
"segment",option+1) == 0)
2670 (void) SyncImageSettings(mogrify_info,*image,exception);
2671 flags=ParseGeometry(argv[i+1],&geometry_info);
2672 if ((flags & SigmaValue) == 0)
2673 geometry_info.sigma=1.0;
2674 (void) SegmentImage(*image,(*image)->colorspace,
2675 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2679 if (LocaleCompare(
"set",option+1) == 0)
2689 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2690 (void) DeleteImageRegistry(argv[i+1]+9);
2692 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2694 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2695 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2698 (
void) DeleteImageProperty(*image,argv[i+1]);
2701 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2703 if (value == (
char *) NULL)
2705 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2706 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2709 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2711 (void) SetImageOption(image_info,argv[i+1]+7,value);
2712 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2713 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2716 if (LocaleCompare(argv[i+1],
"profile") == 0)
2719 *profile = (StringInfo *) NULL;
2721 (void) CopyMagickString(image_info->filename,value,
2723 (void) SetImageInfo(image_info,1,exception);
2724 if (LocaleCompare(image_info->filename,
"-") != 0)
2725 profile=FileToStringInfo(image_info->filename,~0UL,
2727 if (profile != (StringInfo *) NULL)
2729 SetStringInfoName(profile,image_info->magick);
2730 status=SetImageProfilePrivate(*image,profile,exception);
2734 (
void) SetImageProperty(*image,argv[i+1],value,exception);
2735 value=DestroyString(value);
2738 if (LocaleCompare(
"shade",option+1) == 0)
2743 (void) SyncImageSettings(mogrify_info,*image,exception);
2744 flags=ParseGeometry(argv[i+1],&geometry_info);
2745 if ((flags & SigmaValue) == 0)
2746 geometry_info.sigma=1.0;
2747 mogrify_image=ShadeImage(*image,(*option ==
'-') ? MagickTrue :
2748 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2751 if (LocaleCompare(
"shadow",option+1) == 0)
2756 (void) SyncImageSettings(mogrify_info,*image,exception);
2757 flags=ParseGeometry(argv[i+1],&geometry_info);
2758 if ((flags & SigmaValue) == 0)
2759 geometry_info.sigma=1.0;
2760 if ((flags & XiValue) == 0)
2761 geometry_info.xi=4.0;
2762 if ((flags & PsiValue) == 0)
2763 geometry_info.psi=4.0;
2764 mogrify_image=ShadowImage(*image,geometry_info.rho,
2765 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2766 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2769 if (LocaleCompare(
"sharpen",option+1) == 0)
2774 (void) SyncImageSettings(mogrify_info,*image,exception);
2775 flags=ParseGeometry(argv[i+1],&geometry_info);
2776 if ((flags & SigmaValue) == 0)
2777 geometry_info.sigma=1.0;
2778 if ((flags & XiValue) == 0)
2779 geometry_info.xi=0.0;
2780 mogrify_image=SharpenImage(*image,geometry_info.rho,
2781 geometry_info.sigma,exception);
2784 if (LocaleCompare(
"shave",option+1) == 0)
2789 (void) SyncImageSettings(mogrify_info,*image,exception);
2790 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2791 mogrify_image=ShaveImage(*image,&geometry,exception);
2794 if (LocaleCompare(
"shear",option+1) == 0)
2799 (void) SyncImageSettings(mogrify_info,*image,exception);
2800 flags=ParseGeometry(argv[i+1],&geometry_info);
2801 if ((flags & SigmaValue) == 0)
2802 geometry_info.sigma=geometry_info.rho;
2803 mogrify_image=ShearImage(*image,geometry_info.rho,
2804 geometry_info.sigma,exception);
2807 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
2812 (void) SyncImageSettings(mogrify_info,*image,exception);
2813 flags=ParseGeometry(argv[i+1],&geometry_info);
2814 if ((flags & SigmaValue) == 0)
2815 geometry_info.sigma=(double) QuantumRange/2.0;
2816 if ((flags & PercentValue) != 0)
2817 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2819 (void) SigmoidalContrastImage(*image,(*option ==
'-') ?
2820 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2824 if (LocaleCompare(
"sketch",option+1) == 0)
2829 (void) SyncImageSettings(mogrify_info,*image,exception);
2830 flags=ParseGeometry(argv[i+1],&geometry_info);
2831 if ((flags & SigmaValue) == 0)
2832 geometry_info.sigma=1.0;
2833 mogrify_image=SketchImage(*image,geometry_info.rho,
2834 geometry_info.sigma,geometry_info.xi,exception);
2837 if (LocaleCompare(
"solarize",option+1) == 0)
2842 (void) SyncImageSettings(mogrify_info,*image,exception);
2843 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2845 (void) SolarizeImage(*image,threshold,exception);
2848 if (LocaleCompare(
"sort-pixels",option+1) == 0)
2853 (void) SyncImageSettings(mogrify_info,*image,exception);
2854 (void) SortImagePixels(*image,exception);
2857 if (LocaleCompare(
"sparse-color",option+1) == 0)
2868 (void) SyncImageSettings(mogrify_info,*image,exception);
2869 method=(SparseColorMethod) ParseCommandOption(
2870 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2871 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2873 if (arguments == (
char *) NULL)
2875 mogrify_image=SparseColorOption(*image,method,arguments,
2876 option[0] ==
'+' ? MagickTrue : MagickFalse,exception);
2877 arguments=DestroyString(arguments);
2880 if (LocaleCompare(
"splice",option+1) == 0)
2885 (void) SyncImageSettings(mogrify_info,*image,exception);
2886 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2887 mogrify_image=SpliceImage(*image,&geometry,exception);
2890 if (LocaleCompare(
"spread",option+1) == 0)
2895 (void) SyncImageSettings(mogrify_info,*image,exception);
2896 (void) ParseGeometry(argv[i+1],&geometry_info);
2897 mogrify_image=SpreadImage(*image,interpolate_method,
2898 geometry_info.rho,exception);
2901 if (LocaleCompare(
"statistic",option+1) == 0)
2906 (void) SyncImageSettings(mogrify_info,*image,exception);
2907 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2908 MagickFalse,argv[i+1]);
2909 (void) ParseGeometry(argv[i+2],&geometry_info);
2910 mogrify_image=StatisticImage(*image,type,(
size_t) geometry_info.rho,
2911 (
size_t) geometry_info.sigma,exception);
2914 if (LocaleCompare(
"stretch",option+1) == 0)
2918 draw_info->stretch=UndefinedStretch;
2921 draw_info->stretch=(StretchType) ParseCommandOption(
2922 MagickStretchOptions,MagickFalse,argv[i+1]);
2925 if (LocaleCompare(
"strip",option+1) == 0)
2930 (void) SyncImageSettings(mogrify_info,*image,exception);
2931 (void) StripImage(*image,exception);
2934 if (LocaleCompare(
"stroke",option+1) == 0)
2944 (void) QueryColorCompliance(
"none",AllCompliance,
2945 &draw_info->stroke,exception);
2946 if (draw_info->stroke_pattern != (Image *) NULL)
2947 draw_info->stroke_pattern=DestroyImage(
2948 draw_info->stroke_pattern);
2951 sans=AcquireExceptionInfo();
2952 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2953 sans=DestroyExceptionInfo(sans);
2954 if (status == MagickFalse)
2955 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2958 draw_info->stroke=color;
2961 if (LocaleCompare(
"strokewidth",option+1) == 0)
2963 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
2966 if (LocaleCompare(
"style",option+1) == 0)
2970 draw_info->style=UndefinedStyle;
2973 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2974 MagickFalse,argv[i+1]);
2977 if (LocaleCompare(
"swirl",option+1) == 0)
2982 (void) SyncImageSettings(mogrify_info,*image,exception);
2983 (void) ParseGeometry(argv[i+1],&geometry_info);
2984 mogrify_image=SwirlImage(*image,geometry_info.rho,
2985 interpolate_method,exception);
2992 if (LocaleCompare(
"threshold",option+1) == 0)
3000 (void) SyncImageSettings(mogrify_info,*image,exception);
3002 threshold=(double) QuantumRange/2;
3004 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
3006 (void) BilevelImage(*image,threshold,exception);
3009 if (LocaleCompare(
"thumbnail",option+1) == 0)
3014 (void) SyncImageSettings(mogrify_info,*image,exception);
3015 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3016 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3020 if (LocaleCompare(
"tile",option+1) == 0)
3024 if (draw_info->fill_pattern != (Image *) NULL)
3025 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3028 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3032 if (LocaleCompare(
"tint",option+1) == 0)
3037 (void) SyncImageSettings(mogrify_info,*image,exception);
3038 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3041 if (LocaleCompare(
"transform",option+1) == 0)
3046 (void) SyncImageSettings(mogrify_info,*image,exception);
3047 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3051 if (LocaleCompare(
"transparent",option+1) == 0)
3056 (void) SyncImageSettings(mogrify_info,*image,exception);
3057 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3059 (void) TransparentPaintImage(*image,&target,(Quantum)
3060 TransparentAlpha,*option ==
'-' ? MagickFalse : MagickTrue,
3064 if (LocaleCompare(
"transpose",option+1) == 0)
3069 (void) SyncImageSettings(mogrify_info,*image,exception);
3070 mogrify_image=TransposeImage(*image,exception);
3073 if (LocaleCompare(
"transverse",option+1) == 0)
3078 (void) SyncImageSettings(mogrify_info,*image,exception);
3079 mogrify_image=TransverseImage(*image,exception);
3082 if (LocaleCompare(
"treedepth",option+1) == 0)
3084 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3087 if (LocaleCompare(
"trim",option+1) == 0)
3092 (void) SyncImageSettings(mogrify_info,*image,exception);
3093 mogrify_image=TrimImage(*image,exception);
3096 if (LocaleCompare(
"type",option+1) == 0)
3101 (void) SyncImageSettings(mogrify_info,*image,exception);
3105 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3107 (*image)->type=UndefinedType;
3108 (void) SetImageType(*image,type,exception);
3115 if (LocaleCompare(
"undercolor",option+1) == 0)
3117 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3118 &draw_info->undercolor,exception);
3121 if (LocaleCompare(
"unique",option+1) == 0)
3125 (void) DeleteImageArtifact(*image,
"identify:unique-colors");
3128 (void) SetImageArtifact(*image,
"identify:unique-colors",
"true");
3129 (void) SetImageArtifact(*image,
"verbose",
"true");
3132 if (LocaleCompare(
"unique-colors",option+1) == 0)
3137 (void) SyncImageSettings(mogrify_info,*image,exception);
3138 mogrify_image=UniqueImageColors(*image,exception);
3141 if (LocaleCompare(
"unsharp",option+1) == 0)
3146 (void) SyncImageSettings(mogrify_info,*image,exception);
3147 flags=ParseGeometry(argv[i+1],&geometry_info);
3148 if ((flags & SigmaValue) == 0)
3149 geometry_info.sigma=1.0;
3150 if ((flags & XiValue) == 0)
3151 geometry_info.xi=1.0;
3152 if ((flags & PsiValue) == 0)
3153 geometry_info.psi=0.05;
3154 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3155 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3163 if (LocaleCompare(
"verbose",option+1) == 0)
3165 (void) SetImageArtifact(*image,option+1,
3166 *option ==
'+' ?
"false" :
"true");
3169 if (LocaleCompare(
"vignette",option+1) == 0)
3174 (void) SyncImageSettings(mogrify_info,*image,exception);
3175 flags=ParseGeometry(argv[i+1],&geometry_info);
3176 if ((flags & SigmaValue) == 0)
3177 geometry_info.sigma=1.0;
3178 if ((flags & XiValue) == 0)
3179 geometry_info.xi=0.1*(*image)->columns;
3180 if ((flags & PsiValue) == 0)
3181 geometry_info.psi=0.1*(*image)->rows;
3182 if ((flags & PercentValue) != 0)
3184 geometry_info.xi*=(double) (*image)->columns/100.0;
3185 geometry_info.psi*=(double) (*image)->rows/100.0;
3187 mogrify_image=VignetteImage(*image,geometry_info.rho,
3188 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3189 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3192 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
3196 (void) SetImageVirtualPixelMethod(*image,
3197 UndefinedVirtualPixelMethod,exception);
3200 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3201 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3202 argv[i+1]),exception);
3209 if (LocaleCompare(
"wave",option+1) == 0)
3214 (void) SyncImageSettings(mogrify_info,*image,exception);
3215 flags=ParseGeometry(argv[i+1],&geometry_info);
3216 if ((flags & SigmaValue) == 0)
3217 geometry_info.sigma=1.0;
3218 mogrify_image=WaveImage(*image,geometry_info.rho,
3219 geometry_info.sigma,interpolate_method,exception);
3222 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3227 (void) SyncImageSettings(mogrify_info,*image,exception);
3228 flags=ParseGeometry(argv[i+1],&geometry_info);
3229 if ((flags & PercentValue) != 0)
3231 geometry_info.rho=(double) QuantumRange*geometry_info.rho/100.0;
3232 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3235 if ((flags & SigmaValue) == 0)
3236 geometry_info.sigma=0.0;
3237 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3238 geometry_info.sigma,exception);
3241 if (LocaleCompare(
"weight",option+1) == 0)
3246 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3249 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3250 draw_info->weight=(size_t) weight;
3253 if (LocaleCompare(
"white-balance",option+1) == 0)
3258 (void) SyncImageSettings(mogrify_info,*image,exception);
3259 (void) WhiteBalanceImage(*image,exception);
3262 if (LocaleCompare(
"white-threshold",option+1) == 0)
3267 (void) SyncImageSettings(mogrify_info,*image,exception);
3268 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3271 if (LocaleCompare(
"write-mask",option+1) == 0)
3276 (void) SyncImageSettings(mogrify_info,*image,exception);
3282 (void) SetImageMask(*image,WritePixelMask,(
const Image *) NULL,
3289 mask=GetImageCache(mogrify_info,argv[i+1],exception);
3290 if (mask == (Image *) NULL)
3292 (void) SetImageMask(*image,WritePixelMask,mask,exception);
3293 mask=DestroyImage(mask);
3296 if (LocaleCompare(
"word-break",option+1) == 0)
3298 (void) SetImageOption(image_info,option+1,argv[i+1]);
3309 if (mogrify_image != (Image *) NULL)
3310 ReplaceImageInListReturnLast(image,mogrify_image);
3316 quantize_info=DestroyQuantizeInfo(quantize_info);
3317 draw_info=DestroyDrawInfo(draw_info);
3318 mogrify_info=DestroyImageInfo(mogrify_info);
3319 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3320 return(status == 0 ? MagickFalse : MagickTrue);
3357static MagickBooleanType MogrifyUsage(
void)
3360 channel_operators[] =
3361 " -channel-fx expression\n"
3362 " exchange, extract, or transfer one or more image channels\n"
3363 " -separate separate an image channel into a grayscale image",
3365 " -debug events display copious debugging information\n"
3366 " -distribute-cache port\n"
3367 " distributed pixel cache spanning one or more servers\n"
3368 " -help print program options\n"
3369 " -list type print a list of supported option arguments\n"
3370 " -log format format of debugging information\n"
3371 " -version print version information",
3373 " -adaptive-blur geometry\n"
3374 " adaptively blur pixels; decrease effect near edges\n"
3375 " -adaptive-resize geometry\n"
3376 " adaptively resize image using 'mesh' interpolation\n"
3377 " -adaptive-sharpen geometry\n"
3378 " adaptively sharpen pixels; increase effect near edges\n"
3379 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3380 " transparent, extract, background, or shape\n"
3381 " -annotate geometry text\n"
3382 " annotate the image with text\n"
3383 " -auto-gamma automagically adjust gamma level of image\n"
3384 " -auto-level automagically adjust color levels of image\n"
3385 " -auto-orient automagically orient (rotate) image\n"
3386 " -auto-threshold method\n"
3387 " automatically perform image thresholding\n"
3388 " -bench iterations measure performance\n"
3389 " -bilateral-blur geometry\n"
3390 " non-linear, edge-preserving, and noise-reducing smoothing filter\n"
3391 " -black-threshold value\n"
3392 " force all pixels below the threshold into black\n"
3393 " -blue-shift simulate a scene at nighttime in the moonlight\n"
3394 " -blur geometry reduce image noise and reduce detail levels\n"
3395 " -border geometry surround image with a border of color\n"
3396 " -bordercolor color border color\n"
3397 " -brightness-contrast geometry\n"
3398 " improve brightness / contrast of the image\n"
3399 " -canny geometry detect edges in the image\n"
3400 " -cdl filename color correct with a color decision list\n"
3401 " -channel mask set the image channel mask\n"
3402 " -charcoal geometry simulate a charcoal drawing\n"
3403 " -chop geometry remove pixels from the image interior\n"
3404 " -clahe geometry contrast limited adaptive histogram equalization\n"
3405 " -clamp keep pixel values in range (0-QuantumRange)\n"
3406 " -clip clip along the first path from the 8BIM profile\n"
3407 " -clip-mask filename associate a clip mask with the image\n"
3408 " -clip-path id clip along a named path from the 8BIM profile\n"
3409 " -colorize value colorize the image with the fill color\n"
3410 " -color-matrix matrix apply color correction to the image\n"
3411 " -colors value preferred number of colors in the image\n"
3412 " -color-threshold start_color-stop_color\n"
3413 " force all pixels in the color range to white otherwise black\n"
3414 " -connected-components connectivity\n"
3415 " connected-components uniquely labeled\n"
3416 " -contrast enhance or reduce the image contrast\n"
3417 " -contrast-stretch geometry\n"
3418 " improve contrast by 'stretching' the intensity range\n"
3419 " -convolve coefficients\n"
3420 " apply a convolution kernel to the image\n"
3421 " -cycle amount cycle the image colormap\n"
3422 " -decipher filename convert cipher pixels to plain pixels\n"
3423 " -deskew threshold straighten an image\n"
3424 " -despeckle reduce the speckles within an image\n"
3425 " -distort method args\n"
3426 " distort images according to given method ad args\n"
3427 " -draw string annotate the image with a graphic primitive\n"
3428 " -edge radius apply a filter to detect edges in the image\n"
3429 " -encipher filename convert plain pixels to cipher pixels\n"
3430 " -emboss radius emboss an image\n"
3431 " -enhance apply a digital filter to enhance a noisy image\n"
3432 " -equalize perform histogram equalization to an image\n"
3433 " -evaluate operator value\n"
3434 " evaluate an arithmetic, relational, or logical expression\n"
3435 " -extent geometry set the image size\n"
3436 " -extract geometry extract area from image\n"
3437 " -fft implements the discrete Fourier transform (DFT)\n"
3438 " -flip flip image vertically\n"
3439 " -floodfill geometry color\n"
3440 " floodfill the image with color\n"
3441 " -flop flop image horizontally\n"
3442 " -frame geometry surround image with an ornamental border\n"
3443 " -function name parameters\n"
3444 " apply function over image values\n"
3445 " -gamma value level of gamma correction\n"
3446 " -gaussian-blur geometry\n"
3447 " reduce image noise and reduce detail levels\n"
3448 " -geometry geometry preferred size or location of the image\n"
3449 " -grayscale method convert image to grayscale\n"
3450 " -hough-lines geometry\n"
3451 " identify lines in the image\n"
3452 " -identify identify the format and characteristics of the image\n"
3453 " -ift implements the inverse discrete Fourier transform (DFT)\n"
3454 " -implode amount implode image pixels about the center\n"
3455 " -integral calculate the sum of values (pixel values) in the image\n"
3456 " -interpolative-resize geometry\n"
3457 " resize image using interpolation\n"
3458 " -kmeans geometry K means color reduction\n"
3459 " -kuwahara geometry edge preserving noise reduction filter\n"
3460 " -lat geometry local adaptive thresholding\n"
3461 " -level value adjust the level of image contrast\n"
3462 " -level-colors color,color\n"
3463 " level image with the given colors\n"
3464 " -linear-stretch geometry\n"
3465 " improve contrast by 'stretching with saturation'\n"
3466 " -liquid-rescale geometry\n"
3467 " rescale image with seam-carving\n"
3468 " -local-contrast geometry\n"
3469 " enhance local contrast\n"
3470 " -magnify double the size of the image with pixel art scaling\n"
3471 " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3472 " -median geometry apply a median filter to the image\n"
3473 " -mode geometry make each pixel the 'predominant color' of the\n"
3475 " -modulate value vary the brightness, saturation, and hue\n"
3476 " -monochrome transform image to black and white\n"
3477 " -morphology method kernel\n"
3478 " apply a morphology method to the image\n"
3479 " -motion-blur geometry\n"
3480 " simulate motion blur\n"
3481 " -negate replace every pixel with its complementary color \n"
3482 " -noise geometry add or reduce noise in an image\n"
3483 " -normalize transform image to span the full range of colors\n"
3484 " -opaque color change this color to the fill color\n"
3485 " -ordered-dither NxN\n"
3486 " add a noise pattern to the image with specific\n"
3488 " -paint radius simulate an oil painting\n"
3489 " -perceptible epsilon\n"
3490 " pixel value less than |epsilon| become epsilon or\n"
3492 " -polaroid angle simulate a Polaroid picture\n"
3493 " -posterize levels reduce the image to a limited number of color levels\n"
3494 " -profile filename add, delete, or apply an image profile\n"
3495 " -quantize colorspace reduce colors in this colorspace\n"
3496 " -raise value lighten/darken image edges to create a 3-D effect\n"
3497 " -random-threshold low,high\n"
3498 " random threshold the image\n"
3499 " -range-threshold values\n"
3500 " perform either hard or soft thresholding within some range of values in an image\n"
3501 " -region geometry apply options to a portion of the image\n"
3502 " -render render vector graphics\n"
3503 " -repage geometry size and location of an image canvas\n"
3504 " -resample geometry change the resolution of an image\n"
3505 " -reshape geometry reshape the image\n"
3506 " -resize geometry resize the image\n"
3507 " -roll geometry roll an image vertically or horizontally\n"
3508 " -rotate degrees apply Paeth rotation to the image\n"
3509 " -rotational-blur angle\n"
3510 " rotational blur the image\n"
3511 " -sample geometry scale image with pixel sampling\n"
3512 " -scale geometry scale the image\n"
3513 " -segment values segment an image\n"
3514 " -selective-blur geometry\n"
3515 " selectively blur pixels within a contrast threshold\n"
3516 " -sepia-tone threshold\n"
3517 " simulate a sepia-toned photo\n"
3518 " -set property value set an image property\n"
3519 " -shade degrees shade the image using a distant light source\n"
3520 " -shadow geometry simulate an image shadow\n"
3521 " -sharpen geometry sharpen the image\n"
3522 " -shave geometry shave pixels from the image edges\n"
3523 " -shear geometry slide one edge of the image along the X or Y axis\n"
3524 " -sigmoidal-contrast geometry\n"
3525 " increase the contrast without saturating highlights or\n"
3527 " -sketch geometry simulate a pencil sketch\n"
3528 " -solarize threshold negate all pixels above the threshold level\n"
3529 " -sort-pixels sort each scanline in ascending order of intensity\n"
3530 " -sparse-color method args\n"
3531 " fill in a image based on a few color points\n"
3532 " -splice geometry splice the background color into the image\n"
3533 " -spread radius displace image pixels by a random amount\n"
3534 " -statistic type radius\n"
3535 " replace each pixel with corresponding statistic from the neighborhood\n"
3536 " -strip strip image of all profiles and comments\n"
3537 " -swirl degrees swirl image pixels about the center\n"
3538 " -threshold value threshold the image\n"
3539 " -thumbnail geometry create a thumbnail of the image\n"
3540 " -tile filename tile image when filling a graphic primitive\n"
3541 " -tint value tint the image with the fill color\n"
3542 " -transform affine transform image\n"
3543 " -transparent color make this color transparent within the image\n"
3544 " -transpose flip image vertically and rotate 90 degrees\n"
3545 " -transverse flop image horizontally and rotate 270 degrees\n"
3546 " -trim trim image edges\n"
3547 " -type type image type\n"
3548 " -unique-colors discard all but one of any pixel color\n"
3549 " -unsharp geometry sharpen the image\n"
3550 " -vignette geometry soften the edges of the image in vignette style\n"
3551 " -wave geometry alter an image along a sine wave\n"
3552 " -wavelet-denoise threshold\n"
3553 " removes noise from the image using a wavelet transform\n"
3554 " -white-balance automagically adjust white balance of image\n"
3555 " -white-threshold value\n"
3556 " force all pixels above the threshold into white",
3557 sequence_operators[] =
3558 " -affinity filename transform image colors to match this set of colors\n"
3559 " -append append an image sequence\n"
3560 " -clut apply a color lookup table to the image\n"
3561 " -coalesce merge a sequence of images\n"
3562 " -combine combine a sequence of images\n"
3563 " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3564 " -complex operator perform complex mathematics on an image sequence\n"
3565 " -composite composite image\n"
3566 " -copy geometry offset\n"
3567 " copy pixels from one area of an image to another\n"
3568 " -crop geometry cut out a rectangular region of the image\n"
3569 " -deconstruct break down an image sequence into constituent parts\n"
3570 " -evaluate-sequence operator\n"
3571 " evaluate an arithmetic, relational, or logical expression\n"
3572 " -flatten flatten a sequence of images\n"
3573 " -fx expression apply mathematical expression to an image channel(s)\n"
3574 " -hald-clut apply a Hald color lookup table to the image\n"
3575 " -layers method optimize, merge, or compare image layers\n"
3576 " -morph value morph an image sequence\n"
3577 " -mosaic create a mosaic from an image sequence\n"
3578 " -poly terms build a polynomial from the image sequence and the corresponding\n"
3579 " terms (coefficients and degree pairs).\n"
3580 " -print string interpret string and print to console\n"
3581 " -process arguments process the image with a custom image filter\n"
3582 " -smush geometry smush an image sequence together\n"
3583 " -write filename write images to this file",
3585 " -adjoin join images into a single multi-image file\n"
3586 " -affine matrix affine transform matrix\n"
3587 " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3588 " -antialias remove pixel-aliasing\n"
3589 " -authenticate password\n"
3590 " decipher image with this password\n"
3591 " -attenuate value lessen (or intensify) when adding noise to an image\n"
3592 " -background color background color\n"
3593 " -bias value add bias when convolving an image\n"
3594 " -black-point-compensation\n"
3595 " use black point compensation\n"
3596 " -blue-primary point chromaticity blue primary point\n"
3597 " -bordercolor color border color\n"
3598 " -caption string assign a caption to an image\n"
3599 " -colorspace type alternate image colorspace\n"
3600 " -comment string annotate image with comment\n"
3601 " -compose operator set image composite operator\n"
3602 " -compress type type of pixel compression when writing the image\n"
3603 " -define format:option=value\n"
3604 " define one or more image format options\n"
3605 " -delay value display the next image after pausing\n"
3606 " -density geometry horizontal and vertical density of the image\n"
3607 " -depth value image depth\n"
3608 " -direction type render text right-to-left or left-to-right\n"
3609 " -display server get image or font from this X server\n"
3610 " -dispose method layer disposal method\n"
3611 " -dither method apply error diffusion to image\n"
3612 " -encoding type text encoding type\n"
3613 " -endian type endianness (MSB or LSB) of the image\n"
3614 " -family name render text with this font family\n"
3615 " -features distance analyze image features (e.g. contrast, correlation)\n"
3616 " -fill color color to use when filling a graphic primitive\n"
3617 " -filter type use this filter when resizing an image\n"
3618 " -font name render text with this font\n"
3619 " -format \"string\" output formatted image characteristics\n"
3620 " -fuzz distance colors within this distance are considered equal\n"
3621 " -gravity type horizontal and vertical text placement\n"
3622 " -green-primary point chromaticity green primary point\n"
3623 " -illuminant type reference illuminant\n"
3624 " -intensity method method to generate an intensity value from a pixel\n"
3625 " -intent type type of rendering intent when managing the image color\n"
3626 " -interlace type type of image interlacing scheme\n"
3627 " -interline-spacing value\n"
3628 " set the space between two text lines\n"
3629 " -interpolate method pixel color interpolation method\n"
3630 " -interword-spacing value\n"
3631 " set the space between two words\n"
3632 " -kerning value set the space between two letters\n"
3633 " -label string assign a label to an image\n"
3634 " -limit type value pixel cache resource limit\n"
3635 " -loop iterations add Netscape loop extension to your GIF animation\n"
3636 " -matte store matte channel if the image has one\n"
3637 " -mattecolor color frame color\n"
3638 " -monitor monitor progress\n"
3639 " -orient type image orientation\n"
3640 " -page geometry size and location of an image canvas (setting)\n"
3641 " -path path write images to this path on disk\n"
3642 " -ping efficiently determine image attributes\n"
3643 " -pointsize value font point size\n"
3644 " -precision value maximum number of significant digits to print\n"
3645 " -preview type image preview type\n"
3646 " -quality value JPEG/MIFF/PNG compression level\n"
3647 " -quiet suppress all warning messages\n"
3648 " -read-mask filename associate a read mask with the image\n"
3649 " -red-primary point chromaticity red primary point\n"
3650 " -regard-warnings pay attention to warning messages\n"
3651 " -remap filename transform image colors to match this set of colors\n"
3652 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3653 " -sampling-factor geometry\n"
3654 " horizontal and vertical sampling factor\n"
3655 " -scene value image scene number\n"
3656 " -seed value seed a new sequence of pseudo-random numbers\n"
3657 " -size geometry width and height of image\n"
3658 " -stretch type render text with this font stretch\n"
3659 " -stroke color graphic primitive stroke color\n"
3660 " -strokewidth value graphic primitive stroke width\n"
3661 " -style type render text with this font style\n"
3662 " -synchronize synchronize image to storage device\n"
3663 " -taint declare the image as modified\n"
3664 " -texture filename name of texture to tile onto the image background\n"
3665 " -tile-offset geometry\n"
3667 " -treedepth value color tree depth\n"
3668 " -transparent-color color\n"
3669 " transparent color\n"
3670 " -undercolor color annotation bounding box color\n"
3671 " -units type the units of image resolution\n"
3672 " -verbose print detailed information about the image\n"
3673 " -view FlashPix viewing transforms\n"
3674 " -virtual-pixel method\n"
3675 " virtual pixel access method\n"
3676 " -weight type render text with this font weight\n"
3677 " -white-point point chromaticity white point\n"
3678 " -word-break type sets whether line breaks appear wherever the text would otherwise overflow"
3679 " -write-mask filename associate a write mask with the image",
3681 " -delete indexes delete the image from the image sequence\n"
3682 " -duplicate count,indexes\n"
3683 " duplicate an image one or more times\n"
3684 " -insert index insert last image into the image sequence\n"
3685 " -reverse reverse image sequence\n"
3686 " -swap indexes swap two images in the image sequence";
3688 ListMagickVersion(stdout);
3689 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
3691 (void) fprintf(stdout,
"\nImage Settings:\n");
3692 (void) fputs(settings,stdout);
3693 (void) fprintf(stdout,
"\nImage Operators:\n");
3694 (void) fputs(operators,stdout);
3695 (void) fprintf(stdout,
"\nImage Channel Operators:\n");
3696 (void) fputs(channel_operators,stdout);
3697 (void) fprintf(stdout,
"\nImage Sequence Operators:\n");
3698 (void) fputs(sequence_operators,stdout);
3699 (void) fprintf(stdout,
"\nImage Stack Operators:\n");
3700 (void) fputs(stack_operators,stdout);
3701 (void) fprintf(stdout,
"\nMiscellaneous Options:\n");
3702 (void) fputs(miscellaneous,stdout);
3703 (void) fprintf(stdout,
3704 "\nBy default, the image format of 'file' is determined by its magic\n");
3705 (void) fprintf(stdout,
3706 "number. To specify a particular image format, precede the filename\n");
3707 (void) fprintf(stdout,
3708 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3709 (void) fprintf(stdout,
3710 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3711 (void) fprintf(stdout,
"'-' for standard input or output.\n");
3715WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3716 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
3718#define DestroyMogrify() \
3720 if (format != (char *) NULL) \
3721 format=DestroyString(format); \
3722 if (path != (char *) NULL) \
3723 path=DestroyString(path); \
3724 DestroyImageStack(); \
3725 for (i=0; i < (ssize_t) argc; i++) \
3726 argv[i]=DestroyString(argv[i]); \
3727 argv=(char **) RelinquishMagickMemory(argv); \
3729#define ThrowMogrifyException(asperity,tag,option) \
3731 char *message = GetExceptionMessage(errno); \
3732 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \
3733 "`%s'",option == (char *) NULL ? message : option); \
3734 message=DestroyString(message); \
3736 return(MagickFalse); \
3738#define ThrowMogrifyInvalidArgumentException(option,argument) \
3740 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3741 "InvalidArgument","'%s': %s",argument,option); \
3743 return(MagickFalse); \
3755 image_stack[MaxImageStackDepth+1];
3763 respect_parentheses;
3775 wand_unreferenced(metadata);
3780 assert(image_info != (ImageInfo *) NULL);
3781 assert(image_info->signature == MagickCoreSignature);
3782 if (IsEventLogging() != MagickFalse)
3783 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3784 assert(exception != (ExceptionInfo *) NULL);
3788 if ((LocaleCompare(
"version",option+1) == 0) ||
3789 (LocaleCompare(
"-version",option+1) == 0))
3791 ListMagickVersion(stdout);
3797 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3798 "MissingArgument",
"%s",
"");
3799 (void) MogrifyUsage();
3800 return(MagickFalse);
3802 format=(
char *) NULL;
3804 global_colormap=MagickFalse;
3808 option=(
char *) NULL;
3810 respect_parentheses=MagickFalse;
3815 ReadCommandlLine(argc,&argv);
3816 status=ExpandFilenames(&argc,&argv);
3817 if (status == MagickFalse)
3818 ThrowMogrifyException(ResourceLimitError,
"MemoryAllocationFailed",
3820 for (i=1; i < (ssize_t) argc; i++)
3823 if (LocaleCompare(option,
"(") == 0)
3825 FireImageStack(MagickFalse,MagickTrue,pend);
3826 if (k == MaxImageStackDepth)
3827 ThrowMogrifyException(OptionError,
"ParenthesisNestedTooDeeply",
3832 if (LocaleCompare(option,
")") == 0)
3834 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3836 ThrowMogrifyException(OptionError,
"UnableToParseExpression",option);
3840 if (IsCommandOption(option) == MagickFalse)
3843 backup_filename[MagickPathExtent],
3845 magic[MagickPathExtent];
3856 FireImageStack(MagickFalse,MagickFalse,pend);
3858 if ((LocaleCompare(filename,
"--") == 0) && (i < ((ssize_t) argc-1)))
3860 images=ReadImages(image_info,filename,exception);
3861 status&=(MagickStatusType) (images != (Image *) NULL) &&
3862 (exception->severity < ErrorException);
3863 if (images == (Image *) NULL)
3865 properties=(*GetBlobProperties(images));
3866 if (format != (
char *) NULL)
3867 GetPathComponent(images->magick_filename,
3868 BasePathSansCompressExtension,images->filename);
3869 if (path != (
char *) NULL)
3871 GetPathComponent(option,TailPath,filename);
3872 (void) FormatLocaleString(images->filename,MagickPathExtent,
3873 "%s%c%s",path,*DirectorySeparator,filename);
3875 if (format != (
char *) NULL)
3876 AppendImageFormat(format,images->filename);
3877 AppendImageStack(images);
3878 FinalizeImageSettings(image_info,image,MagickFalse);
3879 if (image == (Image *) NULL)
3881 if (global_colormap != MagickFalse)
3886 quantize_info=AcquireQuantizeInfo(image_info);
3887 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3888 quantize_info=DestroyQuantizeInfo(quantize_info);
3890 *backup_filename=
'\0';
3892 GetPathComponent(filename,MagickPath,magic);
3896 name[MagickPathExtent];
3898 if (format != (
char *) NULL)
3899 (void) CopyMagickString(magic,format,MagickPathExtent);
3900 (void) FormatLocaleString(name,MagickPathExtent,
"%s:%s",magic,
3902 (void) CopyMagickString(image->filename,name,MagickPathExtent);
3904 if ((LocaleCompare(image->filename,
"-") != 0) &&
3905 (IsPathWritable(image->filename) != MagickFalse))
3916 random_info=AcquireRandomInfo();
3917 (void) CopyMagickString(backup_filename,image->filename,
3919 for (j=0; j < TMP_MAX; j++)
3927 key_info=GetRandomKey(random_info,4);
3928 if (key_info == (StringInfo *) NULL)
3930 key_bytes=GetStringInfoDatum(key_info);
3931 (void) FormatLocaleString(backup_filename,MagickPathExtent,
3932 "%s-%02x%02x%02x%02x~",image->filename,key_bytes[0],
3933 key_bytes[1],key_bytes[2],key_bytes[3]);
3934 key_info=DestroyStringInfo(key_info);
3935 file=open_utf8(backup_filename,O_RDWR | O_CLOEXEC | O_CREAT | O_EXCL |
3936 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)
3954 status&=(MagickStatusType) WriteImages(image_info,clone_image,
3955 (*backup_filename !=
'\0') ? backup_filename :
3956 clone_image->filename,exception);
3957 clone_image=DestroyImageList(clone_image);
3960 if (status != MagickFalse)
3966 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3967 "preserve-timestamp"));
3968 if (preserve_timestamp != MagickFalse)
3969 (void) set_file_timestamp(image->filename,&properties);
3971 if (*backup_filename !=
'\0')
3973 if (rename_utf8(backup_filename,image->filename) != 0)
3978 if (*backup_filename !=
'\0')
3979 (void) remove_utf8(backup_filename);
3980 RemoveAllImageStack();
3983 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3984 switch (*(option+1))
3988 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
3991 if (i == (ssize_t) argc)
3992 ThrowMogrifyException(OptionError,
"MissingArgument",option);
3993 if (IsGeometry(argv[i]) == MagickFalse)
3994 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3997 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
4000 if (i == (ssize_t) argc)
4001 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4002 if (IsGeometry(argv[i]) == MagickFalse)
4003 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4006 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
4009 if (i == (ssize_t) argc)
4010 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4011 if (IsGeometry(argv[i]) == MagickFalse)
4012 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4015 if (LocaleCompare(
"affine",option+1) == 0)
4020 if (i == (ssize_t) argc)
4021 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4024 if (LocaleCompare(
"alpha",option+1) == 0)
4032 if (i == (ssize_t) argc)
4033 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4034 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
4037 ThrowMogrifyException(OptionError,
4038 "UnrecognizedAlphaChannelOption",argv[i]);
4041 if (LocaleCompare(
"annotate",option+1) == 0)
4046 if (i == (ssize_t) argc)
4047 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4048 if (IsGeometry(argv[i]) == MagickFalse)
4049 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4050 if (i == (ssize_t) argc)
4051 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4055 if (LocaleCompare(
"antialias",option+1) == 0)
4057 if (LocaleCompare(
"append",option+1) == 0)
4059 if (LocaleCompare(
"attenuate",option+1) == 0)
4064 if (i == (ssize_t) argc)
4065 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4066 if (IsGeometry(argv[i]) == MagickFalse)
4067 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4070 if (LocaleCompare(
"authenticate",option+1) == 0)
4075 if (i == (ssize_t) argc)
4076 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4079 if (LocaleCompare(
"auto-gamma",option+1) == 0)
4081 if (LocaleCompare(
"auto-level",option+1) == 0)
4083 if (LocaleCompare(
"auto-orient",option+1) == 0)
4085 if (LocaleCompare(
"auto-threshold",option+1) == 0)
4093 if (i == (ssize_t) argc)
4094 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4095 method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
4098 ThrowMogrifyException(OptionError,
"UnrecognizedThresholdMethod",
4102 if (LocaleCompare(
"average",option+1) == 0)
4104 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4108 if (LocaleCompare(
"background",option+1) == 0)
4113 if (i == (ssize_t) argc)
4114 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4117 if (LocaleCompare(
"bias",option+1) == 0)
4122 if (i == (ssize_t) argc)
4123 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4124 if (IsGeometry(argv[i]) == MagickFalse)
4125 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4128 if (LocaleCompare(
"bilateral-blur",option+1) == 0)
4133 if (i == (ssize_t) argc)
4134 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4135 if (IsGeometry(argv[i]) == MagickFalse)
4136 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4139 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
4141 if (LocaleCompare(
"black-threshold",option+1) == 0)
4146 if (i == (ssize_t) argc)
4147 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4148 if (IsGeometry(argv[i]) == MagickFalse)
4149 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4152 if (LocaleCompare(
"blue-primary",option+1) == 0)
4157 if (i == (ssize_t) argc)
4158 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4159 if (IsGeometry(argv[i]) == MagickFalse)
4160 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4163 if (LocaleCompare(
"blue-shift",option+1) == 0)
4166 if (i == (ssize_t) argc)
4167 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4168 if (IsGeometry(argv[i]) == MagickFalse)
4169 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4172 if (LocaleCompare(
"blur",option+1) == 0)
4175 if (i == (ssize_t) argc)
4176 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4177 if (IsGeometry(argv[i]) == MagickFalse)
4178 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4181 if (LocaleCompare(
"border",option+1) == 0)
4186 if (i == (ssize_t) argc)
4187 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4188 if (IsGeometry(argv[i]) == MagickFalse)
4189 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4192 if (LocaleCompare(
"bordercolor",option+1) == 0)
4197 if (i == (ssize_t) argc)
4198 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4201 if (LocaleCompare(
"box",option+1) == 0)
4206 if (i == (ssize_t) argc)
4207 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4210 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
4213 if (i == (ssize_t) argc)
4214 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4215 if (IsGeometry(argv[i]) == MagickFalse)
4216 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4219 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4223 if (LocaleCompare(
"cache",option+1) == 0)
4228 if (i == (ssize_t) argc)
4229 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4230 if (IsGeometry(argv[i]) == MagickFalse)
4231 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4234 if (LocaleCompare(
"canny",option+1) == 0)
4239 if (i == (ssize_t) argc)
4240 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4241 if (IsGeometry(argv[i]) == MagickFalse)
4242 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4245 if (LocaleCompare(
"caption",option+1) == 0)
4250 if (i == (ssize_t) argc)
4251 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4254 if (LocaleCompare(
"channel",option+1) == 0)
4262 if (i == (ssize_t) argc)
4263 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4264 channel=ParseChannelOption(argv[i]);
4266 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4270 if (LocaleCompare(
"channel-fx",option+1) == 0)
4278 if (i == (ssize_t) argc)
4279 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4280 channel=ParsePixelChannelOption(argv[i]);
4282 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4286 if (LocaleCompare(
"cdl",option+1) == 0)
4291 if (i == (ssize_t) argc)
4292 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4295 if (LocaleCompare(
"charcoal",option+1) == 0)
4300 if (i == (ssize_t) argc)
4301 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4302 if (IsGeometry(argv[i]) == MagickFalse)
4303 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4306 if (LocaleCompare(
"chop",option+1) == 0)
4311 if (i == (ssize_t) argc)
4312 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4313 if (IsGeometry(argv[i]) == MagickFalse)
4314 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4317 if (LocaleCompare(
"clahe",option+1) == 0)
4322 if (i == (ssize_t) argc)
4323 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4324 if (IsGeometry(argv[i]) == MagickFalse)
4325 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4328 if (LocaleCompare(
"clamp",option+1) == 0)
4330 if (LocaleCompare(
"clip",option+1) == 0)
4332 if (LocaleCompare(
"clip-mask",option+1) == 0)
4337 if (i == (ssize_t) argc)
4338 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4341 if (LocaleCompare(
"clut",option+1) == 0)
4343 if (LocaleCompare(
"coalesce",option+1) == 0)
4345 if (LocaleCompare(
"colorize",option+1) == 0)
4350 if (i == (ssize_t) argc)
4351 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4352 if (IsGeometry(argv[i]) == MagickFalse)
4353 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4356 if (LocaleCompare(
"color-matrix",option+1) == 0)
4364 if (i == (ssize_t) argc)
4365 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4366 kernel_info=AcquireKernelInfo(argv[i],exception);
4367 if (kernel_info == (KernelInfo *) NULL)
4368 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4369 kernel_info=DestroyKernelInfo(kernel_info);
4372 if (LocaleCompare(
"colors",option+1) == 0)
4377 if (i == (ssize_t) argc)
4378 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4379 if (IsGeometry(argv[i]) == MagickFalse)
4380 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4383 if (LocaleCompare(
"colorspace",option+1) == 0)
4391 if (i == (ssize_t) argc)
4392 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4393 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4396 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4400 if (LocaleCompare(
"color-threshold",option+1) == 0)
4405 if (i == (ssize_t) argc)
4406 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4409 if (LocaleCompare(
"combine",option+1) == 0)
4417 if (i == (ssize_t) argc)
4418 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4419 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4422 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4426 if (LocaleCompare(
"comment",option+1) == 0)
4431 if (i == (ssize_t) argc)
4432 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4435 if (LocaleCompare(
"compare",option+1) == 0)
4437 if (LocaleCompare(
"compose",option+1) == 0)
4445 if (i == (ssize_t) argc)
4446 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4447 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4450 ThrowMogrifyException(OptionError,
"UnrecognizedComposeOperator",
4454 if (LocaleCompare(
"composite",option+1) == 0)
4456 if (LocaleCompare(
"compress",option+1) == 0)
4464 if (i == (ssize_t) argc)
4465 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4466 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4469 ThrowMogrifyException(OptionError,
"UnrecognizedImageCompression",
4473 if (LocaleCompare(
"concurrent",option+1) == 0)
4475 if (LocaleCompare(
"connected-components",option+1) == 0)
4478 if (i == (ssize_t) argc)
4479 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4480 if (IsGeometry(argv[i]) == MagickFalse)
4481 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4484 if (LocaleCompare(
"contrast",option+1) == 0)
4486 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
4489 if (i == (ssize_t) argc)
4490 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4491 if (IsGeometry(argv[i]) == MagickFalse)
4492 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4495 if (LocaleCompare(
"convolve",option+1) == 0)
4503 if (i == (ssize_t) argc)
4504 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4505 kernel_info=AcquireKernelInfo(argv[i],exception);
4506 if (kernel_info == (KernelInfo *) NULL)
4507 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4508 kernel_info=DestroyKernelInfo(kernel_info);
4511 if (LocaleCompare(
"copy",option+1) == 0)
4516 if (i == (ssize_t) argc)
4517 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4518 if (IsGeometry(argv[i]) == MagickFalse)
4519 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4521 if (i == (ssize_t) argc)
4522 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4523 if (IsGeometry(argv[i]) == MagickFalse)
4524 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4527 if (LocaleCompare(
"crop",option+1) == 0)
4532 if (i == (ssize_t) argc)
4533 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4534 if (IsGeometry(argv[i]) == MagickFalse)
4535 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4538 if (LocaleCompare(
"cycle",option+1) == 0)
4543 if (i == (ssize_t) argc)
4544 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4545 if (IsGeometry(argv[i]) == MagickFalse)
4546 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4549 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4553 if (LocaleCompare(
"decipher",option+1) == 0)
4558 if (i == (ssize_t) argc)
4559 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4562 if (LocaleCompare(
"deconstruct",option+1) == 0)
4564 if (LocaleCompare(
"debug",option+1) == 0)
4572 if (i == (ssize_t) argc)
4573 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4574 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4576 ThrowMogrifyException(OptionError,
"UnrecognizedEventType",
4578 (void) SetLogEventMask(argv[i]);
4581 if (LocaleCompare(
"define",option+1) == 0)
4584 if (i == (ssize_t) argc)
4585 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4591 define=GetImageOption(image_info,argv[i]);
4592 if (define == (
const char *) NULL)
4593 ThrowMogrifyException(OptionError,
"NoSuchOption",argv[i]);
4598 if (LocaleCompare(
"delay",option+1) == 0)
4603 if (i == (ssize_t) argc)
4604 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4605 if (IsGeometry(argv[i]) == MagickFalse)
4606 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4609 if (LocaleCompare(
"delete",option+1) == 0)
4614 if (i == (ssize_t) argc)
4615 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4616 if (LocaleNCompare(argv[i],
"registry:",9) == 0)
4618 (void) DeleteImageRegistry(argv[i]+9);
4621 if (IsGeometry(argv[i]) == MagickFalse)
4622 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4625 if (LocaleCompare(
"density",option+1) == 0)
4630 if (i == (ssize_t) argc)
4631 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4632 if (IsGeometry(argv[i]) == MagickFalse)
4633 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4636 if (LocaleCompare(
"depth",option+1) == 0)
4641 if (i == (ssize_t) argc)
4642 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4643 if (IsGeometry(argv[i]) == MagickFalse)
4644 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4647 if (LocaleCompare(
"deskew",option+1) == 0)
4652 if (i == (ssize_t) argc)
4653 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4654 if (IsGeometry(argv[i]) == MagickFalse)
4655 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4658 if (LocaleCompare(
"despeckle",option+1) == 0)
4660 if (LocaleCompare(
"dft",option+1) == 0)
4662 if (LocaleCompare(
"direction",option+1) == 0)
4670 if (i == (ssize_t) argc)
4671 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4672 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4675 ThrowMogrifyException(OptionError,
"UnrecognizedDirectionType",
4679 if (LocaleCompare(
"display",option+1) == 0)
4684 if (i == (ssize_t) argc)
4685 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4688 if (LocaleCompare(
"dispose",option+1) == 0)
4696 if (i == (ssize_t) argc)
4697 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4698 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4701 ThrowMogrifyException(OptionError,
"UnrecognizedDisposeMethod",
4705 if (LocaleCompare(
"distort",option+1) == 0)
4711 if (i == (ssize_t) argc)
4712 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4713 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4715 ThrowMogrifyException(OptionError,
"UnrecognizedDistortMethod",
4718 if (i == (ssize_t) argc)
4719 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4722 if (LocaleCompare(
"dither",option+1) == 0)
4730 if (i == (ssize_t) argc)
4731 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4732 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4734 ThrowMogrifyException(OptionError,
"UnrecognizedDitherMethod",
4738 if (LocaleCompare(
"draw",option+1) == 0)
4743 if (i == (ssize_t) argc)
4744 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4747 if (LocaleCompare(
"duplicate",option+1) == 0)
4752 if (i == (ssize_t) argc)
4753 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4754 if (IsGeometry(argv[i]) == MagickFalse)
4755 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4758 if (LocaleCompare(
"duration",option+1) == 0)
4763 if (i == (ssize_t) argc)
4764 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4765 if (IsGeometry(argv[i]) == MagickFalse)
4766 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4769 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4773 if (LocaleCompare(
"edge",option+1) == 0)
4778 if (i == (ssize_t) argc)
4779 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4780 if (IsGeometry(argv[i]) == MagickFalse)
4781 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4784 if (LocaleCompare(
"emboss",option+1) == 0)
4789 if (i == (ssize_t) argc)
4790 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4791 if (IsGeometry(argv[i]) == MagickFalse)
4792 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4795 if (LocaleCompare(
"encipher",option+1) == 0)
4800 if (i == (ssize_t) argc)
4801 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4804 if (LocaleCompare(
"encoding",option+1) == 0)
4809 if (i == (ssize_t) argc)
4810 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4813 if (LocaleCompare(
"endian",option+1) == 0)
4821 if (i == (ssize_t) argc)
4822 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4823 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4825 ThrowMogrifyException(OptionError,
"UnrecognizedEndianType",
4829 if (LocaleCompare(
"enhance",option+1) == 0)
4831 if (LocaleCompare(
"equalize",option+1) == 0)
4833 if (LocaleCompare(
"evaluate",option+1) == 0)
4841 if (i == (ssize_t) argc)
4842 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4843 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4845 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4848 if (i == (ssize_t) argc)
4849 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4850 if (IsGeometry(argv[i]) == MagickFalse)
4851 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4854 if (LocaleCompare(
"evaluate-sequence",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",
4870 if (LocaleCompare(
"extent",option+1) == 0)
4875 if (i == (ssize_t) argc)
4876 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4877 if (IsGeometry(argv[i]) == MagickFalse)
4878 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4881 if (LocaleCompare(
"extract",option+1) == 0)
4886 if (i == (ssize_t) argc)
4887 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4888 if (IsGeometry(argv[i]) == MagickFalse)
4889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4892 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4896 if (LocaleCompare(
"family",option+1) == 0)
4901 if (i == (ssize_t) argc)
4902 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4905 if (LocaleCompare(
"features",option+1) == 0)
4910 if (i == (ssize_t) argc)
4911 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4912 if (IsGeometry(argv[i]) == MagickFalse)
4913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4916 if (LocaleCompare(
"fill",option+1) == 0)
4921 if (i == (ssize_t) argc)
4922 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4925 if (LocaleCompare(
"filter",option+1) == 0)
4933 if (i == (ssize_t) argc)
4934 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4935 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4937 ThrowMogrifyException(OptionError,
"UnrecognizedImageFilter",
4941 if (LocaleCompare(
"flatten",option+1) == 0)
4943 if (LocaleCompare(
"flip",option+1) == 0)
4945 if (LocaleCompare(
"flop",option+1) == 0)
4947 if (LocaleCompare(
"floodfill",option+1) == 0)
4952 if (i == (ssize_t) argc)
4953 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4954 if (IsGeometry(argv[i]) == MagickFalse)
4955 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4957 if (i == (ssize_t) argc)
4958 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4961 if (LocaleCompare(
"font",option+1) == 0)
4966 if (i == (ssize_t) argc)
4967 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4970 if (LocaleCompare(
"format",option+1) == 0)
4972 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
4973 (void) CloneString(&format,(
char *) NULL);
4977 if (i == (ssize_t) argc)
4978 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4979 (void) CloneString(&format,argv[i]);
4980 (void) CopyMagickString(image_info->filename,format,
4982 (void) ConcatenateMagickString(image_info->filename,
":",
4984 (void) SetImageInfo(image_info,0,exception);
4985 if (*image_info->magick ==
'\0')
4986 ThrowMogrifyException(OptionError,
"UnrecognizedImageFormat",
4990 if (LocaleCompare(
"frame",option+1) == 0)
4995 if (i == (ssize_t) argc)
4996 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4997 if (IsGeometry(argv[i]) == MagickFalse)
4998 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5001 if (LocaleCompare(
"function",option+1) == 0)
5009 if (i == (ssize_t) argc)
5010 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5011 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
5013 ThrowMogrifyException(OptionError,
"UnrecognizedFunction",argv[i]);
5015 if (i == (ssize_t) argc)
5016 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5019 if (LocaleCompare(
"fuzz",option+1) == 0)
5024 if (i == (ssize_t) argc)
5025 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5026 if (IsGeometry(argv[i]) == MagickFalse)
5027 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5030 if (LocaleCompare(
"fx",option+1) == 0)
5033 if (i == (ssize_t) argc)
5034 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5037 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5041 if (LocaleCompare(
"gamma",option+1) == 0)
5044 if (i == (ssize_t) argc)
5045 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5046 if (IsGeometry(argv[i]) == MagickFalse)
5047 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5050 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
5051 (LocaleCompare(
"gaussian",option+1) == 0))
5054 if (i == (ssize_t) argc)
5055 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5056 if (IsGeometry(argv[i]) == MagickFalse)
5057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5060 if (LocaleCompare(
"geometry",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(
"gravity",option+1) == 0)
5079 if (i == (ssize_t) argc)
5080 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5081 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5084 ThrowMogrifyException(OptionError,
"UnrecognizedGravityType",
5088 if (LocaleCompare(
"grayscale",option+1) == 0)
5096 if (i == (ssize_t) argc)
5097 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5098 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5101 ThrowMogrifyException(OptionError,
"UnrecognizedIntensityMethod",
5105 if (LocaleCompare(
"green-primary",option+1) == 0)
5110 if (i == (ssize_t) argc)
5111 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5112 if (IsGeometry(argv[i]) == MagickFalse)
5113 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5116 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5120 if (LocaleCompare(
"hald-clut",option+1) == 0)
5122 if ((LocaleCompare(
"help",option+1) == 0) ||
5123 (LocaleCompare(
"-help",option+1) == 0))
5126 return(MogrifyUsage());
5128 if (LocaleCompare(
"hough-lines",option+1) == 0)
5133 if (i == (ssize_t) argc)
5134 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5135 if (IsGeometry(argv[i]) == MagickFalse)
5136 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5139 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5143 if (LocaleCompare(
"identify",option+1) == 0)
5145 if (LocaleCompare(
"idft",option+1) == 0)
5147 if (LocaleCompare(
"illuminant",option+1) == 0)
5155 if (i == (ssize_t) argc)
5156 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5157 type=ParseCommandOption(MagickIlluminantOptions,MagickFalse,
5160 ThrowMogrifyException(OptionError,
"UnrecognizedIlluminantMethod",
5164 if (LocaleCompare(
"implode",option+1) == 0)
5169 if (i == (ssize_t) argc)
5170 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5171 if (IsGeometry(argv[i]) == MagickFalse)
5172 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5175 if (LocaleCompare(
"intensity",option+1) == 0)
5183 if (i == (ssize_t) argc)
5184 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5185 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5186 MagickFalse,argv[i]);
5188 ThrowMogrifyException(OptionError,
5189 "UnrecognizedPixelIntensityMethod",argv[i]);
5192 if (LocaleCompare(
"integral",option+1) == 0)
5194 if (LocaleCompare(
"intent",option+1) == 0)
5202 if (i == (ssize_t) argc)
5203 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5204 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5206 ThrowMogrifyException(OptionError,
"UnrecognizedIntentType",
5210 if (LocaleCompare(
"interlace",option+1) == 0)
5218 if (i == (ssize_t) argc)
5219 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5220 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5223 ThrowMogrifyException(OptionError,
"UnrecognizedInterlaceType",
5227 if (LocaleCompare(
"interline-spacing",option+1) == 0)
5232 if (i == (ssize_t) argc)
5233 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5234 if (IsGeometry(argv[i]) == MagickFalse)
5235 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5238 if (LocaleCompare(
"interpolate",option+1) == 0)
5246 if (i == (ssize_t) argc)
5247 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5248 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5250 if (interpolate < 0)
5251 ThrowMogrifyException(OptionError,
"UnrecognizedInterpolateMethod",
5255 if (LocaleCompare(
"interword-spacing",option+1) == 0)
5260 if (i == (ssize_t) argc)
5261 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5262 if (IsGeometry(argv[i]) == MagickFalse)
5263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5266 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5270 if (LocaleCompare(
"kerning",option+1) == 0)
5275 if (i == (ssize_t) argc)
5276 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5277 if (IsGeometry(argv[i]) == MagickFalse)
5278 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5281 if (LocaleCompare(
"kmeans",option+1) == 0)
5284 if (i == (ssize_t) argc)
5285 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5286 if (IsGeometry(argv[i]) == MagickFalse)
5287 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5290 if (LocaleCompare(
"kuwahara",option+1) == 0)
5293 if (i == (ssize_t) argc)
5294 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5295 if (IsGeometry(argv[i]) == MagickFalse)
5296 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5299 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5303 if (LocaleCompare(
"label",option+1) == 0)
5308 if (i == (ssize_t) argc)
5309 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5312 if (LocaleCompare(
"lat",option+1) == 0)
5317 if (i == (ssize_t) argc)
5318 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5319 if (IsGeometry(argv[i]) == MagickFalse)
5320 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5323 if (LocaleCompare(
"layers",option+1) == 0)
5331 if (i == (ssize_t) argc)
5332 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5333 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5335 ThrowMogrifyException(OptionError,
"UnrecognizedLayerMethod",
5339 if (LocaleCompare(
"level",option+1) == 0)
5342 if (i == (ssize_t) argc)
5343 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5344 if (IsGeometry(argv[i]) == MagickFalse)
5345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5348 if (LocaleCompare(
"level-colors",option+1) == 0)
5351 if (i == (ssize_t) argc)
5352 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5355 if (LocaleCompare(
"limit",option+1) == 0)
5369 if (i == (ssize_t) argc)
5370 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5371 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5374 ThrowMogrifyException(OptionError,
"UnrecognizedResourceType",
5377 if (i == (ssize_t) argc)
5378 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5379 value=StringToDouble(argv[i],&p);
5381 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
5382 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5385 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
5388 if (i == (ssize_t) argc)
5389 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5390 if (IsGeometry(argv[i]) == MagickFalse)
5391 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5394 if (LocaleCompare(
"list",option+1) == 0)
5402 if (i == (ssize_t) argc)
5403 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5404 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5406 ThrowMogrifyException(OptionError,
"UnrecognizedListType",argv[i]);
5407 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
5409 return(status == 0 ? MagickFalse : MagickTrue);
5411 if (LocaleCompare(
"log",option+1) == 0)
5416 if ((i == (ssize_t) argc) ||
5417 (strchr(argv[i],
'%') == (
char *) NULL))
5418 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5421 if (LocaleCompare(
"loop",option+1) == 0)
5426 if (i == (ssize_t) argc)
5427 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5428 if (IsGeometry(argv[i]) == MagickFalse)
5429 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5432 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5436 if (LocaleCompare(
"magnify",option+1) == 0)
5438 if (LocaleCompare(
"map",option+1) == 0)
5440 global_colormap=(*option ==
'+') ? MagickTrue : MagickFalse;
5444 if (i == (ssize_t) argc)
5445 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5448 if (LocaleCompare(
"mask",option+1) == 0)
5453 if (i == (ssize_t) argc)
5454 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5457 if (LocaleCompare(
"matte",option+1) == 0)
5459 if (LocaleCompare(
"mattecolor",option+1) == 0)
5464 if (i == (ssize_t) argc)
5465 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5468 if (LocaleCompare(
"maximum",option+1) == 0)
5470 if (LocaleCompare(
"mean-shift",option+1) == 0)
5475 if (i == (ssize_t) argc)
5476 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5477 if (IsGeometry(argv[i]) == MagickFalse)
5478 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5481 if (LocaleCompare(
"median",option+1) == 0)
5486 if (i == (ssize_t) argc)
5487 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5488 if (IsGeometry(argv[i]) == MagickFalse)
5489 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5492 if (LocaleCompare(
"metric",option+1) == 0)
5500 if (i == (ssize_t) argc)
5501 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5502 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5504 ThrowMogrifyException(OptionError,
"UnrecognizedMetricType",
5508 if (LocaleCompare(
"minimum",option+1) == 0)
5510 if (LocaleCompare(
"modulate",option+1) == 0)
5515 if (i == (ssize_t) argc)
5516 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5517 if (IsGeometry(argv[i]) == MagickFalse)
5518 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5521 if (LocaleCompare(
"mode",option+1) == 0)
5526 if (i == (ssize_t) argc)
5527 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5528 if (IsGeometry(argv[i]) == MagickFalse)
5529 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5532 if (LocaleCompare(
"monitor",option+1) == 0)
5534 if (LocaleCompare(
"monochrome",option+1) == 0)
5536 if (LocaleCompare(
"morph",option+1) == 0)
5541 if (i == (ssize_t) argc)
5542 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5543 if (IsGeometry(argv[i]) == MagickFalse)
5544 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5547 if (LocaleCompare(
"morphology",option+1) == 0)
5550 token[MagickPathExtent];
5559 if (i == (ssize_t) argc)
5560 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5561 (void) GetNextToken(argv[i],(
const char **) NULL,MagickPathExtent,
5563 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5565 ThrowMogrifyException(OptionError,
"UnrecognizedMorphologyMethod",
5568 if (i == (ssize_t) argc)
5569 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5570 kernel_info=AcquireKernelInfo(argv[i],exception);
5571 if (kernel_info == (KernelInfo *) NULL)
5572 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5573 kernel_info=DestroyKernelInfo(kernel_info);
5576 if (LocaleCompare(
"mosaic",option+1) == 0)
5578 if (LocaleCompare(
"motion-blur",option+1) == 0)
5583 if (i == (ssize_t) argc)
5584 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5585 if (IsGeometry(argv[i]) == MagickFalse)
5586 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5589 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5593 if (LocaleCompare(
"negate",option+1) == 0)
5595 if (LocaleCompare(
"noise",option+1) == 0)
5598 if (i == (ssize_t) argc)
5599 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5605 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
5608 ThrowMogrifyException(OptionError,
"UnrecognizedNoiseType",
5612 if (IsGeometry(argv[i]) == MagickFalse)
5613 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5616 if (LocaleCompare(
"noop",option+1) == 0)
5618 if (LocaleCompare(
"normalize",option+1) == 0)
5620 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5624 if (LocaleCompare(
"opaque",option+1) == 0)
5627 if (i == (ssize_t) argc)
5628 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5631 if (LocaleCompare(
"ordered-dither",option+1) == 0)
5636 if (i == (ssize_t) argc)
5637 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5640 if (LocaleCompare(
"orient",option+1) == 0)
5645 orientation=UndefinedOrientation;
5649 if (i == (ssize_t) argc)
5650 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5651 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5653 if (orientation < 0)
5654 ThrowMogrifyException(OptionError,
"UnrecognizedImageOrientation",
5658 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5662 if (LocaleCompare(
"page",option+1) == 0)
5667 if (i == (ssize_t) argc)
5668 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5671 if (LocaleCompare(
"paint",option+1) == 0)
5676 if (i == (ssize_t) argc)
5677 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5678 if (IsGeometry(argv[i]) == MagickFalse)
5679 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5682 if (LocaleCompare(
"path",option+1) == 0)
5684 (void) CloneString(&path,(
char *) NULL);
5688 if (i == (ssize_t) argc)
5689 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5690 (void) CloneString(&path,argv[i]);
5693 if (LocaleCompare(
"perceptible",option+1) == 0)
5698 if (i == (ssize_t) argc)
5699 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5700 if (IsGeometry(argv[i]) == MagickFalse)
5701 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5704 if (LocaleCompare(
"pointsize",option+1) == 0)
5709 if (i == (ssize_t) argc)
5710 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5711 if (IsGeometry(argv[i]) == MagickFalse)
5712 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5715 if (LocaleCompare(
"polaroid",option+1) == 0)
5720 if (i == (ssize_t) argc)
5721 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5722 if (IsGeometry(argv[i]) == MagickFalse)
5723 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5726 if (LocaleCompare(
"poly",option+1) == 0)
5731 if (i == (ssize_t) argc)
5732 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5733 if (IsGeometry(argv[i]) == MagickFalse)
5734 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5737 if (LocaleCompare(
"posterize",option+1) == 0)
5742 if (i == (ssize_t) argc)
5743 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5744 if (IsGeometry(argv[i]) == MagickFalse)
5745 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5748 if (LocaleCompare(
"precision",option+1) == 0)
5753 if (i == (ssize_t) argc)
5754 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5755 if (IsGeometry(argv[i]) == MagickFalse)
5756 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5759 if (LocaleCompare(
"print",option+1) == 0)
5764 if (i == (ssize_t) argc)
5765 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5768 if (LocaleCompare(
"process",option+1) == 0)
5773 if (i == (ssize_t) argc)
5774 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5777 if (LocaleCompare(
"profile",option+1) == 0)
5780 if (i == (ssize_t) argc)
5781 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5784 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5788 if (LocaleCompare(
"quality",option+1) == 0)
5793 if (i == (ssize_t) argc)
5794 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5795 if (IsGeometry(argv[i]) == MagickFalse)
5796 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5799 if (LocaleCompare(
"quantize",option+1) == 0)
5807 if (i == (ssize_t) argc)
5808 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5809 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5812 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
5816 if (LocaleCompare(
"quiet",option+1) == 0)
5818 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5822 if (LocaleCompare(
"rotational-blur",option+1) == 0)
5825 if (i == (ssize_t) argc)
5826 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5827 if (IsGeometry(argv[i]) == MagickFalse)
5828 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5831 if (LocaleCompare(
"raise",option+1) == 0)
5834 if (i == (ssize_t) argc)
5835 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5836 if (IsGeometry(argv[i]) == MagickFalse)
5837 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5840 if (LocaleCompare(
"random-threshold",option+1) == 0)
5845 if (i == (ssize_t) argc)
5846 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5847 if (IsGeometry(argv[i]) == MagickFalse)
5848 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5851 if (LocaleCompare(
"range-threshold",option+1) == 0)
5856 if (i == (ssize_t) argc)
5857 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5858 if (IsGeometry(argv[i]) == MagickFalse)
5859 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5862 if (LocaleCompare(
"read-mask",option+1) == 0)
5867 if (i == (ssize_t) argc)
5868 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5871 if (LocaleCompare(
"red-primary",option+1) == 0)
5876 if (i == (ssize_t) argc)
5877 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5878 if (IsGeometry(argv[i]) == MagickFalse)
5879 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5881 if (LocaleCompare(
"regard-warnings",option+1) == 0)
5883 if (LocaleCompare(
"region",option+1) == 0)
5888 if (i == (ssize_t) argc)
5889 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5890 if (IsGeometry(argv[i]) == MagickFalse)
5891 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5894 if (LocaleCompare(
"remap",option+1) == 0)
5899 if (i == (ssize_t) argc)
5900 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5903 if (LocaleCompare(
"render",option+1) == 0)
5905 if (LocaleCompare(
"repage",option+1) == 0)
5910 if (i == (ssize_t) argc)
5911 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5912 if (IsGeometry(argv[i]) == MagickFalse)
5913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5916 if (LocaleCompare(
"resample",option+1) == 0)
5921 if (i == (ssize_t) argc)
5922 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5923 if (IsGeometry(argv[i]) == MagickFalse)
5924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5927 if (LocaleCompare(
"reshape",option+1) == 0)
5932 if (i == (ssize_t) argc)
5933 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5934 if (IsGeometry(argv[i]) == MagickFalse)
5935 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5938 if (LocaleCompare(
"resize",option+1) == 0)
5943 if (i == (ssize_t) argc)
5944 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5945 if (IsGeometry(argv[i]) == MagickFalse)
5946 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5949 if ((LocaleNCompare(
"respect-parentheses",option+1,17) == 0) ||
5950 (LocaleNCompare(
"respect-parenthesis",option+1,17) == 0))
5952 respect_parentheses=(*option ==
'-') ? MagickTrue : MagickFalse;
5955 if (LocaleCompare(
"reverse",option+1) == 0)
5957 if (LocaleCompare(
"roll",option+1) == 0)
5962 if (i == (ssize_t) argc)
5963 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5964 if (IsGeometry(argv[i]) == MagickFalse)
5965 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5968 if (LocaleCompare(
"rotate",option+1) == 0)
5971 if (i == (ssize_t) argc)
5972 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5973 if (IsGeometry(argv[i]) == MagickFalse)
5974 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5977 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5981 if (LocaleCompare(
"sample",option+1) == 0)
5986 if (i == (ssize_t) argc)
5987 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5988 if (IsGeometry(argv[i]) == MagickFalse)
5989 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5992 if (LocaleCompare(
"sampling-factor",option+1) == 0)
5997 if (i == (ssize_t) argc)
5998 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5999 if (IsGeometry(argv[i]) == MagickFalse)
6000 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6003 if (LocaleCompare(
"scale",option+1) == 0)
6008 if (i == (ssize_t) argc)
6009 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6010 if (IsGeometry(argv[i]) == MagickFalse)
6011 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6014 if (LocaleCompare(
"scene",option+1) == 0)
6019 if (i == (ssize_t) argc)
6020 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6021 if (IsGeometry(argv[i]) == MagickFalse)
6022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6025 if (LocaleCompare(
"seed",option+1) == 0)
6030 if (i == (ssize_t) argc)
6031 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6032 if (IsGeometry(argv[i]) == MagickFalse)
6033 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6036 if (LocaleCompare(
"segment",option+1) == 0)
6041 if (i == (ssize_t) argc)
6042 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6043 if (IsGeometry(argv[i]) == MagickFalse)
6044 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6047 if (LocaleCompare(
"selective-blur",option+1) == 0)
6050 if (i == (ssize_t) argc)
6051 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6052 if (IsGeometry(argv[i]) == MagickFalse)
6053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6056 if (LocaleCompare(
"separate",option+1) == 0)
6058 if (LocaleCompare(
"sepia-tone",option+1) == 0)
6063 if (i == (ssize_t) argc)
6064 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6065 if (IsGeometry(argv[i]) == MagickFalse)
6066 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6069 if (LocaleCompare(
"set",option+1) == 0)
6072 if (i == (ssize_t) argc)
6073 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6077 if (i == (ssize_t) argc)
6078 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6081 if (LocaleCompare(
"shade",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(
"shadow",option+1) == 0)
6095 if (i == (ssize_t) argc)
6096 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6097 if (IsGeometry(argv[i]) == MagickFalse)
6098 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6101 if (LocaleCompare(
"sharpen",option+1) == 0)
6104 if (i == (ssize_t) argc)
6105 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6106 if (IsGeometry(argv[i]) == MagickFalse)
6107 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6110 if (LocaleCompare(
"shave",option+1) == 0)
6115 if (i == (ssize_t) argc)
6116 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6117 if (IsGeometry(argv[i]) == MagickFalse)
6118 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6121 if (LocaleCompare(
"shear",option+1) == 0)
6124 if (i == (ssize_t) argc)
6125 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6126 if (IsGeometry(argv[i]) == MagickFalse)
6127 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6130 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
6133 if (i == (ssize_t) argc)
6134 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6135 if (IsGeometry(argv[i]) == MagickFalse)
6136 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6139 if (LocaleCompare(
"size",option+1) == 0)
6144 if (i == (ssize_t) argc)
6145 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6146 if (IsGeometry(argv[i]) == MagickFalse)
6147 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6150 if (LocaleCompare(
"sketch",option+1) == 0)
6155 if (i == (ssize_t) argc)
6156 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6157 if (IsGeometry(argv[i]) == MagickFalse)
6158 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6161 if (LocaleCompare(
"smush",option+1) == 0)
6164 if (i == (ssize_t) argc)
6165 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6166 if (IsGeometry(argv[i]) == MagickFalse)
6167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6171 if (LocaleCompare(
"solarize",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(
"sort",option+1) == 0)
6184 if (LocaleCompare(
"sparse-color",option+1) == 0)
6190 if (i == (ssize_t) argc)
6191 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6192 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6194 ThrowMogrifyException(OptionError,
"UnrecognizedSparseColorMethod",
6197 if (i == (ssize_t) argc)
6198 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6201 if (LocaleCompare(
"splice",option+1) == 0)
6206 if (i == (ssize_t) argc)
6207 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6208 if (IsGeometry(argv[i]) == MagickFalse)
6209 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6212 if (LocaleCompare(
"spread",option+1) == 0)
6217 if (i == (ssize_t) argc)
6218 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6219 if (IsGeometry(argv[i]) == MagickFalse)
6220 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6223 if (LocaleCompare(
"statistic",option+1) == 0)
6231 if (i == (ssize_t) argc)
6232 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6233 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6235 ThrowMogrifyException(OptionError,
"UnrecognizedStatisticType",
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(
"stretch",option+1) == 0)
6252 if (i == (ssize_t) argc)
6253 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6254 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
6257 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6261 if (LocaleCompare(
"strip",option+1) == 0)
6263 if (LocaleCompare(
"stroke",option+1) == 0)
6268 if (i == (ssize_t) argc)
6269 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6272 if (LocaleCompare(
"strokewidth",option+1) == 0)
6277 if (i == (ssize_t) argc)
6278 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6279 if (IsGeometry(argv[i]) == MagickFalse)
6280 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6283 if (LocaleCompare(
"style",option+1) == 0)
6291 if (i == (ssize_t) argc)
6292 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6293 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6295 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6299 if (LocaleCompare(
"swap",option+1) == 0)
6304 if (i == (ssize_t) argc)
6305 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6306 if (IsGeometry(argv[i]) == MagickFalse)
6307 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6310 if (LocaleCompare(
"swirl",option+1) == 0)
6315 if (i == (ssize_t) argc)
6316 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6317 if (IsGeometry(argv[i]) == MagickFalse)
6318 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6321 if (LocaleCompare(
"synchronize",option+1) == 0)
6323 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6327 if (LocaleCompare(
"taint",option+1) == 0)
6329 if (LocaleCompare(
"texture",option+1) == 0)
6334 if (i == (ssize_t) argc)
6335 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6338 if (LocaleCompare(
"tile",option+1) == 0)
6343 if (i == (ssize_t) argc)
6344 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6347 if (LocaleCompare(
"tile-offset",option+1) == 0)
6352 if (i == (ssize_t) argc)
6353 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6354 if (IsGeometry(argv[i]) == MagickFalse)
6355 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6358 if (LocaleCompare(
"tint",option+1) == 0)
6363 if (i == (ssize_t) argc)
6364 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6365 if (IsGeometry(argv[i]) == MagickFalse)
6366 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6369 if (LocaleCompare(
"transform",option+1) == 0)
6371 if (LocaleCompare(
"transpose",option+1) == 0)
6373 if (LocaleCompare(
"transverse",option+1) == 0)
6375 if (LocaleCompare(
"threshold",option+1) == 0)
6380 if (i == (ssize_t) argc)
6381 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6382 if (IsGeometry(argv[i]) == MagickFalse)
6383 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6386 if (LocaleCompare(
"thumbnail",option+1) == 0)
6391 if (i == (ssize_t) argc)
6392 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6393 if (IsGeometry(argv[i]) == MagickFalse)
6394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6397 if (LocaleCompare(
"transparent",option+1) == 0)
6400 if (i == (ssize_t) argc)
6401 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6404 if (LocaleCompare(
"transparent-color",option+1) == 0)
6409 if (i == (ssize_t) argc)
6410 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6413 if (LocaleCompare(
"treedepth",option+1) == 0)
6418 if (i == (ssize_t) argc)
6419 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6420 if (IsGeometry(argv[i]) == MagickFalse)
6421 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6424 if (LocaleCompare(
"trim",option+1) == 0)
6426 if (LocaleCompare(
"type",option+1) == 0)
6434 if (i == (ssize_t) argc)
6435 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6436 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6438 ThrowMogrifyException(OptionError,
"UnrecognizedImageType",
6442 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6446 if (LocaleCompare(
"undercolor",option+1) == 0)
6451 if (i == (ssize_t) argc)
6452 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6455 if (LocaleCompare(
"unique-colors",option+1) == 0)
6457 if (LocaleCompare(
"units",option+1) == 0)
6465 if (i == (ssize_t) argc)
6466 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6467 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6470 ThrowMogrifyException(OptionError,
"UnrecognizedUnitsType",
6474 if (LocaleCompare(
"unsharp",option+1) == 0)
6477 if (i == (ssize_t) argc)
6478 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6479 if (IsGeometry(argv[i]) == MagickFalse)
6480 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6483 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6487 if (LocaleCompare(
"verbose",option+1) == 0)
6489 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
6492 if ((LocaleCompare(
"version",option+1) == 0) ||
6493 (LocaleCompare(
"-version",option+1) == 0))
6495 ListMagickVersion(stdout);
6498 if (LocaleCompare(
"vignette",option+1) == 0)
6503 if (i == (ssize_t) argc)
6504 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6505 if (IsGeometry(argv[i]) == MagickFalse)
6506 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6509 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
6517 if (i == (ssize_t) argc)
6518 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6519 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6522 ThrowMogrifyException(OptionError,
6523 "UnrecognizedVirtualPixelMethod",argv[i]);
6526 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6530 if (LocaleCompare(
"wave",option+1) == 0)
6533 if (i == (ssize_t) argc)
6534 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6535 if (IsGeometry(argv[i]) == MagickFalse)
6536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6539 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
6542 if (i == (ssize_t) argc)
6543 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6544 if (IsGeometry(argv[i]) == MagickFalse)
6545 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6548 if (LocaleCompare(
"weight",option+1) == 0)
6553 if (i == (ssize_t) argc)
6554 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6557 if (LocaleCompare(
"word-break",option+1) == 0)
6565 if (i == (ssize_t) argc)
6566 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6567 word_break=ParseCommandOption(MagickWordBreakOptions,MagickFalse,
6570 ThrowMogrifyException(OptionError,
"UnrecognizedArgument",argv[i]);
6573 if (LocaleCompare(
"white-balance",option+1) == 0)
6575 if (LocaleCompare(
"white-point",option+1) == 0)
6580 if (i == (ssize_t) argc)
6581 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6582 if (IsGeometry(argv[i]) == MagickFalse)
6583 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6586 if (LocaleCompare(
"white-threshold",option+1) == 0)
6591 if (i == (ssize_t) argc)
6592 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6593 if (IsGeometry(argv[i]) == MagickFalse)
6594 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6597 if (LocaleCompare(
"write",option+1) == 0)
6600 if (i == (ssize_t) argc)
6601 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6604 if (LocaleCompare(
"write-mask",option+1) == 0)
6609 if (i == (ssize_t) argc)
6610 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6613 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6618 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6620 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6621 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6622 if (fire != MagickFalse)
6623 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6626 ThrowMogrifyException(OptionError,
"UnbalancedParenthesis",argv[i]);
6627 if (i != (ssize_t) argc)
6628 ThrowMogrifyException(OptionError,
"MissingAnImageFilename",argv[i]);
6630 return(status != 0 ? MagickTrue : MagickFalse);
6665WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6666 const int argc,
const char **argv,ExceptionInfo *exception)
6683 assert(image_info != (ImageInfo *) NULL);
6684 assert(image_info->signature == MagickCoreSignature);
6685 if (IsEventLogging() != MagickFalse)
6686 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
6687 image_info->filename);
6693 for (i=0; i < (ssize_t) argc; i++)
6696 if (IsCommandOption(option) == MagickFalse)
6698 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6699 count=MagickMax(count,0L);
6700 if ((i+count) >= (ssize_t) argc)
6702 switch (*(option+1))
6706 if (LocaleCompare(
"adjoin",option+1) == 0)
6708 image_info->adjoin=(*option ==
'-') ? MagickTrue : MagickFalse;
6711 if (LocaleCompare(
"antialias",option+1) == 0)
6713 image_info->antialias=(*option ==
'-') ? MagickTrue : MagickFalse;
6716 if (LocaleCompare(
"authenticate",option+1) == 0)
6719 (void) DeleteImageOption(image_info,option+1);
6721 (
void) SetImageOption(image_info,option+1,argv[i+1]);
6728 if (LocaleCompare(
"background",option+1) == 0)
6732 (void) DeleteImageOption(image_info,option+1);
6733 (void) QueryColorCompliance(MogrifyBackgroundColor,
6734 AllCompliance,&image_info->background_color,exception);
6737 (void) SetImageOption(image_info,option+1,argv[i+1]);
6738 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6739 &image_info->background_color,exception);
6742 if (LocaleCompare(
"bias",option+1) == 0)
6746 (void) SetImageOption(image_info,
"convolve:bias",
"0.0");
6749 (void) SetImageOption(image_info,
"convolve:bias",argv[i+1]);
6752 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
6756 (void) SetImageOption(image_info,option+1,
"false");
6759 (void) SetImageOption(image_info,option+1,
"true");
6762 if (LocaleCompare(
"blue-primary",option+1) == 0)
6766 (void) SetImageOption(image_info,option+1,
"0.0");
6769 (void) SetImageOption(image_info,option+1,argv[i+1]);
6772 if (LocaleCompare(
"bordercolor",option+1) == 0)
6776 (void) DeleteImageOption(image_info,option+1);
6777 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6778 &image_info->border_color,exception);
6781 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6782 &image_info->border_color,exception);
6783 (void) SetImageOption(image_info,option+1,argv[i+1]);
6786 if (LocaleCompare(
"box",option+1) == 0)
6790 (void) SetImageOption(image_info,
"undercolor",
"none");
6793 (void) SetImageOption(image_info,
"undercolor",argv[i+1]);
6800 if (LocaleCompare(
"cache",option+1) == 0)
6805 limit=MagickResourceInfinity;
6806 if (LocaleCompare(
"unlimited",argv[i+1]) != 0)
6807 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6809 (void) SetMagickResourceLimit(MemoryResource,limit);
6810 (void) SetMagickResourceLimit(MapResource,2*limit);
6813 if (LocaleCompare(
"caption",option+1) == 0)
6817 (void) DeleteImageOption(image_info,option+1);
6820 (void) SetImageOption(image_info,option+1,argv[i+1]);
6823 if (LocaleCompare(
"colorspace",option+1) == 0)
6827 image_info->colorspace=UndefinedColorspace;
6828 (void) SetImageOption(image_info,option+1,
"undefined");
6831 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6832 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6833 (void) SetImageOption(image_info,option+1,argv[i+1]);
6836 if (LocaleCompare(
"comment",option+1) == 0)
6840 (void) DeleteImageOption(image_info,option+1);
6843 (void) SetImageOption(image_info,option+1,argv[i+1]);
6846 if (LocaleCompare(
"compose",option+1) == 0)
6850 (void) SetImageOption(image_info,option+1,
"undefined");
6853 (void) SetImageOption(image_info,option+1,argv[i+1]);
6856 if (LocaleCompare(
"compress",option+1) == 0)
6860 image_info->compression=UndefinedCompression;
6861 (void) SetImageOption(image_info,option+1,
"undefined");
6864 image_info->compression=(CompressionType) ParseCommandOption(
6865 MagickCompressOptions,MagickFalse,argv[i+1]);
6866 (void) SetImageOption(image_info,option+1,argv[i+1]);
6873 if (LocaleCompare(
"debug",option+1) == 0)
6876 (void) SetLogEventMask(
"none");
6878 (
void) SetLogEventMask(argv[i+1]);
6879 image_info->debug=IsEventLogging();
6882 if (LocaleCompare(
"define",option+1) == 0)
6886 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6887 (void) DeleteImageRegistry(argv[i+1]+9);
6889 (
void) DeleteImageOption(image_info,argv[i+1]);
6892 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6894 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6898 (void) DefineImageOption(image_info,argv[i+1]);
6901 if (LocaleCompare(
"delay",option+1) == 0)
6905 (void) SetImageOption(image_info,option+1,
"0");
6908 (void) SetImageOption(image_info,option+1,argv[i+1]);
6911 if (LocaleCompare(
"density",option+1) == 0)
6918 if (image_info->density != (
char *) NULL)
6919 image_info->density=DestroyString(image_info->density);
6920 (void) SetImageOption(image_info,option+1,
"72");
6923 (void) CloneString(&image_info->density,argv[i+1]);
6924 (void) SetImageOption(image_info,option+1,argv[i+1]);
6927 if (LocaleCompare(
"depth",option+1) == 0)
6931 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6934 image_info->depth=StringToUnsignedLong(argv[i+1]);
6937 if (LocaleCompare(
"direction",option+1) == 0)
6941 (void) SetImageOption(image_info,option+1,
"undefined");
6944 (void) SetImageOption(image_info,option+1,argv[i+1]);
6947 if (LocaleCompare(
"display",option+1) == 0)
6951 if (image_info->server_name != (
char *) NULL)
6952 image_info->server_name=DestroyString(
6953 image_info->server_name);
6956 (void) CloneString(&image_info->server_name,argv[i+1]);
6959 if (LocaleCompare(
"dispose",option+1) == 0)
6963 (void) SetImageOption(image_info,option+1,
"undefined");
6966 (void) SetImageOption(image_info,option+1,argv[i+1]);
6969 if (LocaleCompare(
"dither",option+1) == 0)
6973 image_info->dither=MagickFalse;
6974 (void) SetImageOption(image_info,option+1,
"none");
6977 (void) SetImageOption(image_info,option+1,argv[i+1]);
6978 image_info->dither=MagickTrue;
6985 if (LocaleCompare(
"encoding",option+1) == 0)
6989 (void) SetImageOption(image_info,option+1,
"undefined");
6992 (void) SetImageOption(image_info,option+1,argv[i+1]);
6995 if (LocaleCompare(
"endian",option+1) == 0)
6999 image_info->endian=UndefinedEndian;
7000 (void) SetImageOption(image_info,option+1,
"undefined");
7003 image_info->endian=(EndianType) ParseCommandOption(
7004 MagickEndianOptions,MagickFalse,argv[i+1]);
7005 (void) SetImageOption(image_info,option+1,argv[i+1]);
7008 if (LocaleCompare(
"extract",option+1) == 0)
7015 if (image_info->extract != (
char *) NULL)
7016 image_info->extract=DestroyString(image_info->extract);
7019 (void) CloneString(&image_info->extract,argv[i+1]);
7026 if (LocaleCompare(
"family",option+1) == 0)
7029 (void) SetImageOption(image_info,option+1,argv[i+1]);
7032 if (LocaleCompare(
"fill",option+1) == 0)
7036 (void) SetImageOption(image_info,option+1,
"none");
7039 (void) SetImageOption(image_info,option+1,argv[i+1]);
7042 if (LocaleCompare(
"filter",option+1) == 0)
7046 (void) SetImageOption(image_info,option+1,
"undefined");
7049 (void) SetImageOption(image_info,option+1,argv[i+1]);
7052 if (LocaleCompare(
"font",option+1) == 0)
7056 if (image_info->font != (
char *) NULL)
7057 image_info->font=DestroyString(image_info->font);
7060 (void) CloneString(&image_info->font,argv[i+1]);
7063 if (LocaleCompare(
"format",option+1) == 0)
7065 (void) SetImageOption(image_info,option+1,argv[i+1]);
7068 if (LocaleCompare(
"fuzz",option+1) == 0)
7072 image_info->fuzz=0.0;
7073 (void) SetImageOption(image_info,option+1,
"0");
7076 image_info->fuzz=StringToDoubleInterval(argv[i+1],(
double)
7078 (void) SetImageOption(image_info,option+1,argv[i+1]);
7085 if (LocaleCompare(
"gravity",option+1) == 0)
7089 (void) SetImageOption(image_info,option+1,
"undefined");
7092 (void) SetImageOption(image_info,option+1,argv[i+1]);
7095 if (LocaleCompare(
"green-primary",option+1) == 0)
7099 (void) SetImageOption(image_info,option+1,
"0.0");
7102 (void) SetImageOption(image_info,option+1,argv[i+1]);
7109 if (LocaleCompare(
"intensity",option+1) == 0)
7113 (void) SetImageOption(image_info,option+1,
"undefined");
7116 (void) SetImageOption(image_info,option+1,argv[i+1]);
7119 if (LocaleCompare(
"intent",option+1) == 0)
7123 (void) SetImageOption(image_info,option+1,
"undefined");
7126 (void) SetImageOption(image_info,option+1,argv[i+1]);
7129 if (LocaleCompare(
"interlace",option+1) == 0)
7133 image_info->interlace=UndefinedInterlace;
7134 (void) SetImageOption(image_info,option+1,
"undefined");
7137 image_info->interlace=(InterlaceType) ParseCommandOption(
7138 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7139 (void) SetImageOption(image_info,option+1,argv[i+1]);
7142 if (LocaleCompare(
"interline-spacing",option+1) == 0)
7146 (void) SetImageOption(image_info,option+1,
"undefined");
7149 (void) SetImageOption(image_info,option+1,argv[i+1]);
7152 if (LocaleCompare(
"interpolate",option+1) == 0)
7156 (void) SetImageOption(image_info,option+1,
"undefined");
7159 (void) SetImageOption(image_info,option+1,argv[i+1]);
7162 if (LocaleCompare(
"interword-spacing",option+1) == 0)
7166 (void) SetImageOption(image_info,option+1,
"undefined");
7169 (void) SetImageOption(image_info,option+1,argv[i+1]);
7176 if (LocaleCompare(
"kerning",option+1) == 0)
7180 (void) SetImageOption(image_info,option+1,
"undefined");
7183 (void) SetImageOption(image_info,option+1,argv[i+1]);
7190 if (LocaleCompare(
"label",option+1) == 0)
7194 (void) DeleteImageOption(image_info,option+1);
7197 (void) SetImageOption(image_info,option+1,argv[i+1]);
7200 if (LocaleCompare(
"limit",option+1) == 0)
7210 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7211 MagickFalse,argv[i+1]);
7212 limit=MagickResourceInfinity;
7213 if (LocaleCompare(
"unlimited",argv[i+2]) != 0)
7214 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7215 if (type == TimeResource)
7216 limit=(MagickSizeType) ParseMagickTimeToLive(argv[i+2]);
7217 (void) SetMagickResourceLimit(type,limit);
7220 if (LocaleCompare(
"list",option+1) == 0)
7228 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7231 case MagickCoderOptions:
7233 (void) ListCoderInfo((FILE *) NULL,exception);
7236 case MagickColorOptions:
7238 (void) ListColorInfo((FILE *) NULL,exception);
7241 case MagickConfigureOptions:
7243 (void) ListConfigureInfo((FILE *) NULL,exception);
7246 case MagickDelegateOptions:
7248 (void) ListDelegateInfo((FILE *) NULL,exception);
7251 case MagickFontOptions:
7253 (void) ListTypeInfo((FILE *) NULL,exception);
7256 case MagickFormatOptions:
7258 (void) ListMagickInfo((FILE *) NULL,exception);
7261 case MagickLocaleOptions:
7263 (void) ListLocaleInfo((FILE *) NULL,exception);
7266 case MagickLogOptions:
7268 (void) ListLogInfo((FILE *) NULL,exception);
7271 case MagickMagicOptions:
7273 (void) ListMagicInfo((FILE *) NULL,exception);
7276 case MagickMimeOptions:
7278 (void) ListMimeInfo((FILE *) NULL,exception);
7281 case MagickModuleOptions:
7283 (void) ListModuleInfo((FILE *) NULL,exception);
7286 case MagickPagesizeOptions:
7288 (void) ListPagesizes((FILE *) NULL,exception);
7291 case MagickPolicyOptions:
7293 (void) ListPolicyInfo((FILE *) NULL,exception);
7296 case MagickResourceOptions:
7298 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7301 case MagickThresholdOptions:
7303 (void) ListThresholdMaps((FILE *) NULL,exception);
7308 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7315 if (LocaleCompare(
"log",option+1) == 0)
7319 (void) SetLogFormat(argv[i+1]);
7322 if (LocaleCompare(
"loop",option+1) == 0)
7326 (void) SetImageOption(image_info,option+1,
"0");
7329 (void) SetImageOption(image_info,option+1,argv[i+1]);
7336 if (LocaleCompare(
"matte",option+1) == 0)
7340 (void) SetImageOption(image_info,option+1,
"false");
7343 (void) SetImageOption(image_info,option+1,
"true");
7346 if (LocaleCompare(
"mattecolor",option+1) == 0)
7350 (void) SetImageOption(image_info,option+1,argv[i+1]);
7351 (void) QueryColorCompliance(MogrifyAlphaColor,AllCompliance,
7352 &image_info->matte_color,exception);
7355 (void) SetImageOption(image_info,option+1,argv[i+1]);
7356 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7357 &image_info->matte_color,exception);
7360 if (LocaleCompare(
"metric",option+1) == 0)
7363 (void) DeleteImageOption(image_info,option+1);
7365 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7368 if (LocaleCompare(
"monitor",option+1) == 0)
7370 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7374 if (LocaleCompare(
"monochrome",option+1) == 0)
7376 image_info->monochrome=(*option ==
'-') ? MagickTrue : MagickFalse;
7383 if (LocaleCompare(
"orient",option+1) == 0)
7387 image_info->orientation=UndefinedOrientation;
7388 (void) SetImageOption(image_info,option+1,
"undefined");
7391 image_info->orientation=(OrientationType) ParseCommandOption(
7392 MagickOrientationOptions,MagickFalse,argv[i+1]);
7393 (void) SetImageOption(image_info,option+1,argv[i+1]);
7400 if (LocaleCompare(
"page",option+1) == 0)
7404 page[MagickPathExtent];
7417 (void) DeleteImageOption(image_info,option+1);
7418 (void) CloneString(&image_info->page,(
char *) NULL);
7421 (void) memset(&geometry,0,
sizeof(geometry));
7422 image_option=GetImageOption(image_info,
"page");
7423 if (image_option != (
const char *) NULL)
7424 flags=ParseAbsoluteGeometry(image_option,&geometry);
7425 canonical_page=GetPageGeometry(argv[i+1]);
7426 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7427 canonical_page=DestroyString(canonical_page);
7428 (void) FormatLocaleString(page,MagickPathExtent,
"%lux%lu",
7429 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
7430 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7431 (void) FormatLocaleString(page,MagickPathExtent,
"%lux%lu%+ld%+ld",
7432 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
7433 (
long) geometry.x,(
long) geometry.y);
7434 (void) SetImageOption(image_info,option+1,page);
7435 (void) CloneString(&image_info->page,page);
7438 if (LocaleCompare(
"ping",option+1) == 0)
7440 image_info->ping=(*option ==
'-') ? MagickTrue : MagickFalse;
7443 if (LocaleCompare(
"pointsize",option+1) == 0)
7446 geometry_info.rho=0.0;
7448 (
void) ParseGeometry(argv[i+1],&geometry_info);
7449 image_info->pointsize=geometry_info.rho;
7452 if (LocaleCompare(
"precision",option+1) == 0)
7454 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7461 if (LocaleCompare(
"quality",option+1) == 0)
7468 image_info->quality=UndefinedCompressionQuality;
7469 (void) SetImageOption(image_info,option+1,
"0");
7472 image_info->quality=StringToUnsignedLong(argv[i+1]);
7473 (void) SetImageOption(image_info,option+1,argv[i+1]);
7476 if (LocaleCompare(
"quiet",option+1) == 0)
7478 static WarningHandler
7479 warning_handler = (WarningHandler) NULL;
7486 warning_handler=SetWarningHandler(warning_handler);
7492 warning_handler=SetWarningHandler((WarningHandler) NULL);
7499 if (LocaleCompare(
"red-primary",option+1) == 0)
7503 (void) SetImageOption(image_info,option+1,
"0.0");
7506 (void) SetImageOption(image_info,option+1,argv[i+1]);
7513 if (LocaleCompare(
"sampling-factor",option+1) == 0)
7520 if (image_info->sampling_factor != (
char *) NULL)
7521 image_info->sampling_factor=DestroyString(
7522 image_info->sampling_factor);
7525 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7528 if (LocaleCompare(
"scene",option+1) == 0)
7535 image_info->scene=0;
7536 (void) SetImageOption(image_info,option+1,
"0");
7539 image_info->scene=StringToUnsignedLong(argv[i+1]);
7540 (void) SetImageOption(image_info,option+1,argv[i+1]);
7543 if (LocaleCompare(
"seed",option+1) == 0)
7550 seed=(
unsigned long) time((time_t *) NULL);
7551 SetRandomSecretKey(seed);
7554 seed=StringToUnsignedLong(argv[i+1]);
7555 SetRandomSecretKey(seed);
7558 if (LocaleCompare(
"size",option+1) == 0)
7562 if (image_info->size != (
char *) NULL)
7563 image_info->size=DestroyString(image_info->size);
7566 (void) CloneString(&image_info->size,argv[i+1]);
7569 if (LocaleCompare(
"stroke",option+1) == 0)
7573 (void) SetImageOption(image_info,option+1,
"none");
7576 (void) SetImageOption(image_info,option+1,argv[i+1]);
7579 if (LocaleCompare(
"strokewidth",option+1) == 0)
7582 (void) SetImageOption(image_info,option+1,
"0");
7584 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7587 if (LocaleCompare(
"style",option+1) == 0)
7591 (void) SetImageOption(image_info,option+1,
"none");
7594 (void) SetImageOption(image_info,option+1,argv[i+1]);
7597 if (LocaleCompare(
"synchronize",option+1) == 0)
7601 image_info->synchronize=MagickFalse;
7604 image_info->synchronize=MagickTrue;
7611 if (LocaleCompare(
"taint",option+1) == 0)
7615 (void) SetImageOption(image_info,option+1,
"false");
7618 (void) SetImageOption(image_info,option+1,
"true");
7621 if (LocaleCompare(
"texture",option+1) == 0)
7625 if (image_info->texture != (
char *) NULL)
7626 image_info->texture=DestroyString(image_info->texture);
7629 (void) CloneString(&image_info->texture,argv[i+1]);
7632 if (LocaleCompare(
"tile-offset",option+1) == 0)
7635 (void) SetImageOption(image_info,option+1,
"0");
7637 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7640 if (LocaleCompare(
"transparent-color",option+1) == 0)
7644 (void) QueryColorCompliance(
"none",AllCompliance,
7645 &image_info->transparent_color,exception);
7646 (void) SetImageOption(image_info,option+1,
"none");
7649 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7650 &image_info->transparent_color,exception);
7651 (void) SetImageOption(image_info,option+1,argv[i+1]);
7654 if (LocaleCompare(
"type",option+1) == 0)
7658 image_info->type=UndefinedType;
7659 (void) SetImageOption(image_info,option+1,
"undefined");
7662 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7663 MagickFalse,argv[i+1]);
7664 (void) SetImageOption(image_info,option+1,argv[i+1]);
7671 if (LocaleCompare(
"undercolor",option+1) == 0)
7674 (void) DeleteImageOption(image_info,option+1);
7676 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7679 if (LocaleCompare(
"units",option+1) == 0)
7683 image_info->units=UndefinedResolution;
7684 (void) SetImageOption(image_info,option+1,
"undefined");
7687 image_info->units=(ResolutionType) ParseCommandOption(
7688 MagickResolutionOptions,MagickFalse,argv[i+1]);
7689 (void) SetImageOption(image_info,option+1,argv[i+1]);
7696 if (LocaleCompare(
"verbose",option+1) == 0)
7700 image_info->verbose=MagickFalse;
7703 image_info->verbose=MagickTrue;
7704 image_info->ping=MagickFalse;
7707 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
7710 (void) SetImageOption(image_info,option+1,
"undefined");
7712 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7719 if (LocaleCompare(
"weight",option+1) == 0)
7722 (void) SetImageOption(image_info,option+1,
"0");
7724 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7727 if (LocaleCompare(
"white-point",option+1) == 0)
7730 (void) SetImageOption(image_info,option+1,
"0.0");
7732 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7735 if (LocaleCompare(
"word-break",option+1) == 0)
7739 (void) SetImageOption(image_info,option+1,
"undefined");
7742 (void) SetImageOption(image_info,option+1,argv[i+1]);
7789WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7790 const int argc,
const char **argv,Image **images,ExceptionInfo *exception)
7801 PixelInterpolateMethod
7817 assert(image_info != (ImageInfo *) NULL);
7818 assert(image_info->signature == MagickCoreSignature);
7819 assert(images != (Image **) NULL);
7820 assert((*images)->previous == (Image *) NULL);
7821 assert((*images)->signature == MagickCoreSignature);
7822 if (IsEventLogging() != MagickFalse)
7823 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
7824 (*images)->filename);
7825 if ((argc <= 0) || (*argv == (
char *) NULL))
7827 interpolate_method=UndefinedInterpolatePixel;
7828 mogrify_info=CloneImageInfo(image_info);
7829 quantize_info=AcquireQuantizeInfo(mogrify_info);
7831 for (i=0; i < (ssize_t) argc; i++)
7833 if (*images == (Image *) NULL)
7836 if (IsCommandOption(option) == MagickFalse)
7838 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7839 count=MagickMax(count,0L);
7840 if ((i+count) >= (ssize_t) argc)
7842 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
7843 switch (*(option+1))
7847 if (LocaleCompare(
"affinity",option+1) == 0)
7849 (void) SyncImagesSettings(mogrify_info,*images,exception);
7852 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7859 if (LocaleCompare(
"append",option+1) == 0)
7864 (void) SyncImagesSettings(mogrify_info,*images,exception);
7865 append_image=AppendImages(*images,*option ==
'-' ? MagickTrue :
7866 MagickFalse,exception);
7867 if (append_image == (Image *) NULL)
7872 *images=DestroyImageList(*images);
7873 *images=append_image;
7876 if (LocaleCompare(
"average",option+1) == 0)
7884 (void) SyncImagesSettings(mogrify_info,*images,exception);
7885 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7887 if (average_image == (Image *) NULL)
7892 *images=DestroyImageList(*images);
7893 *images=average_image;
7900 if (LocaleCompare(
"channel-fx",option+1) == 0)
7905 (void) SyncImagesSettings(mogrify_info,*images,exception);
7906 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7907 if (channel_image == (Image *) NULL)
7912 *images=DestroyImageList(*images);
7913 *images=channel_image;
7916 if (LocaleCompare(
"clut",option+1) == 0)
7922 (void) SyncImagesSettings(mogrify_info,*images,exception);
7923 image=RemoveFirstImageFromList(images);
7924 clut_image=RemoveFirstImageFromList(images);
7925 if (clut_image == (Image *) NULL)
7927 (void) ThrowMagickException(exception,GetMagickModule(),
7928 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7929 image=DestroyImage(image);
7933 (void) ClutImage(image,clut_image,interpolate_method,exception);
7934 clut_image=DestroyImage(clut_image);
7935 *images=DestroyImageList(*images);
7939 if (LocaleCompare(
"coalesce",option+1) == 0)
7944 (void) SyncImagesSettings(mogrify_info,*images,exception);
7945 coalesce_image=CoalesceImages(*images,exception);
7946 if (coalesce_image == (Image *) NULL)
7951 *images=DestroyImageList(*images);
7952 *images=coalesce_image;
7955 if (LocaleCompare(
"combine",option+1) == 0)
7963 (void) SyncImagesSettings(mogrify_info,*images,exception);
7964 colorspace=(*images)->colorspace;
7965 if ((*images)->number_channels < GetImageListLength(*images))
7966 colorspace=sRGBColorspace;
7968 colorspace=(ColorspaceType) ParseCommandOption(
7969 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7970 combine_image=CombineImages(*images,colorspace,exception);
7971 if (combine_image == (Image *) NULL)
7976 *images=DestroyImageList(*images);
7977 *images=combine_image;
7980 if (LocaleCompare(
"compare",option+1) == 0)
7997 (void) SyncImagesSettings(mogrify_info,*images,exception);
7998 image=RemoveFirstImageFromList(images);
7999 reconstruct_image=RemoveFirstImageFromList(images);
8000 if (reconstruct_image == (Image *) NULL)
8002 (void) ThrowMagickException(exception,GetMagickModule(),
8003 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8004 image=DestroyImage(image);
8008 metric=UndefinedErrorMetric;
8009 option=GetImageOption(mogrify_info,
"metric");
8010 if (option != (
const char *) NULL)
8011 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
8012 MagickFalse,option);
8013 difference_image=CompareImages(image,reconstruct_image,metric,
8014 &distortion,exception);
8015 if (difference_image == (Image *) NULL)
8017 reconstruct_image=DestroyImage(reconstruct_image);
8018 image=DestroyImage(image);
8019 if (*images != (Image *) NULL)
8020 *images=DestroyImageList(*images);
8021 *images=difference_image;
8024 if (LocaleCompare(
"complex",option+1) == 0)
8032 (void) SyncImageSettings(mogrify_info,*images,exception);
8033 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
8034 MagickFalse,argv[i+1]);
8035 complex_images=ComplexImages(*images,op,exception);
8036 if (complex_images == (Image *) NULL)
8041 *images=DestroyImageList(*images);
8042 *images=complex_images;
8045 if (LocaleCompare(
"composite",option+1) == 0)
8065 (void) SyncImageSettings(mogrify_info,*images,exception);
8066 value=GetImageOption(mogrify_info,
"compose");
8067 if (value == (
const char *) NULL)
8068 compose=OverCompositeOp;
8070 compose=(CompositeOperator) ParseCommandOption(
8071 MagickComposeOptions,MagickFalse,value);
8074 clip_to_self=GetCompositeClipToSelf(compose);
8075 value=GetImageOption(mogrify_info,
"compose:clip-to-self");
8076 if (value != (
const char *) NULL)
8077 clip_to_self=IsStringTrue(value);
8078 value=GetImageOption(mogrify_info,
"compose:outside-overlay");
8079 if (value != (
const char *) NULL)
8080 clip_to_self=IsStringFalse(value);
8082 new_images=RemoveFirstImageFromList(images);
8083 source_image=RemoveFirstImageFromList(images);
8084 if (source_image == (Image *) NULL)
8086 (void) ThrowMagickException(exception,GetMagickModule(),
8087 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8088 new_images=DestroyImage(new_images);
8094 if (source_image->geometry != (
char *) NULL)
8099 (void) ParseRegionGeometry(source_image,source_image->geometry,
8100 &resize_geometry,exception);
8101 if ((source_image->columns != resize_geometry.width) ||
8102 (source_image->rows != resize_geometry.height))
8107 resize_image=ResizeImage(source_image,resize_geometry.width,
8108 resize_geometry.height,source_image->filter,exception);
8109 if (resize_image != (Image *) NULL)
8111 source_image=DestroyImage(source_image);
8112 source_image=resize_image;
8116 SetGeometry(source_image,&geometry);
8117 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
8118 GravityAdjustGeometry(new_images->columns,new_images->rows,
8119 new_images->gravity,&geometry);
8120 mask_image=RemoveFirstImageFromList(images);
8121 if (mask_image == (Image *) NULL)
8122 status&=(MagickStatusType) CompositeImage(new_images,source_image,
8123 compose,clip_to_self,geometry.x,geometry.y,exception);
8129 canvas_image=CloneImage(new_images,0,0,MagickTrue,exception);
8130 if (canvas_image == (Image *) NULL)
8134 case BlendCompositeOp:
8136 status&=(MagickStatusType) CompositeImage(new_images,
8137 source_image,compose,clip_to_self,geometry.x,geometry.y,
8139 status&=(MagickStatusType) CompositeImage(new_images,
8140 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8143 case DisplaceCompositeOp:
8144 case DistortCompositeOp:
8146 status&=(MagickStatusType) CompositeImage(source_image,
8147 mask_image,CopyGreenCompositeOp,MagickTrue,0,0,exception);
8148 (void) SetImageColorspace(source_image,sRGBColorspace,
8150 status&=(MagickStatusType) CompositeImage(new_images,
8151 source_image,compose,clip_to_self,geometry.x,geometry.y,
8155 case SaliencyBlendCompositeOp:
8156 case SeamlessBlendCompositeOp:
8158 status&=(MagickStatusType) CompositeImage(source_image,
8159 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8160 status&=(MagickStatusType) CompositeImage(new_images,
8161 source_image,compose,clip_to_self,geometry.x,geometry.y,
8170 clone_image=CloneImage(new_images,0,0,MagickTrue,exception);
8171 if (clone_image == (Image *) NULL)
8173 status&=(MagickStatusType) CompositeImage(new_images,
8174 source_image,compose,clip_to_self,geometry.x,geometry.y,
8176 status&=(MagickStatusType) CompositeImage(new_images,
8177 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8178 status&=(MagickStatusType) CompositeImage(clone_image,
8179 new_images,OverCompositeOp,clip_to_self,0,0,exception);
8180 new_images=DestroyImageList(new_images);
8181 new_images=clone_image;
8187 case DisplaceCompositeOp:
8188 case DistortCompositeOp:
8190 status&=(MagickStatusType) CompositeImage(canvas_image,
8191 new_images,CopyCompositeOp,clip_to_self,0,0,exception);
8196 status&=(MagickStatusType) CompositeImage(canvas_image,
8197 new_images,OverCompositeOp,clip_to_self,0,0,exception);
8201 new_images=DestroyImageList(new_images);
8202 new_images=canvas_image;
8203 mask_image=DestroyImage(mask_image);
8205 source_image=DestroyImage(source_image);
8206 *images=DestroyImageList(*images);
8210 if (LocaleCompare(
"copy",option+1) == 0)
8224 (void) SyncImageSettings(mogrify_info,*images,exception);
8225 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8226 offset.x=geometry.x;
8227 offset.y=geometry.y;
8228 source_image=(*images);
8229 if (source_image->next != (Image *) NULL)
8230 source_image=source_image->next;
8231 (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8233 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8241 if (LocaleCompare(
"deconstruct",option+1) == 0)
8246 (void) SyncImagesSettings(mogrify_info,*images,exception);
8247 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
8249 if (deconstruct_image == (Image *) NULL)
8254 *images=DestroyImageList(*images);
8255 *images=deconstruct_image;
8258 if (LocaleCompare(
"delete",option+1) == 0)
8261 DeleteImages(images,
"-1",exception);
8263 DeleteImages(images,argv[i+1],exception);
8266 if (LocaleCompare(
"dither",option+1) == 0)
8270 quantize_info->dither_method=NoDitherMethod;
8273 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8274 MagickDitherOptions,MagickFalse,argv[i+1]);
8277 if (LocaleCompare(
"duplicate",option+1) == 0)
8283 duplicate_images=DuplicateImages(*images,1,
"-1",exception);
8292 number_duplicates=(size_t) StringToLong(argv[i+1]);
8293 p=strchr(argv[i+1],
',');
8294 if (p == (
const char *) NULL)
8295 duplicate_images=DuplicateImages(*images,number_duplicates,
8298 duplicate_images=DuplicateImages(*images,number_duplicates,
8301 AppendImageToList(images, duplicate_images);
8302 (void) SyncImagesSettings(mogrify_info,*images,exception);
8309 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
8314 MagickEvaluateOperator
8317 (void) SyncImageSettings(mogrify_info,*images,exception);
8318 op=(MagickEvaluateOperator) ParseCommandOption(
8319 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8320 evaluate_image=EvaluateImages(*images,op,exception);
8321 if (evaluate_image == (Image *) NULL)
8326 *images=DestroyImageList(*images);
8327 *images=evaluate_image;
8334 if (LocaleCompare(
"fft",option+1) == 0)
8342 (void) SyncImageSettings(mogrify_info,*images,exception);
8343 fourier_image=ForwardFourierTransformImage(*images,*option ==
'-' ?
8344 MagickTrue : MagickFalse,exception);
8345 if (fourier_image == (Image *) NULL)
8347 *images=DestroyImageList(*images);
8348 *images=fourier_image;
8351 if (LocaleCompare(
"flatten",option+1) == 0)
8356 (void) SyncImagesSettings(mogrify_info,*images,exception);
8357 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8358 if (flatten_image == (Image *) NULL)
8360 *images=DestroyImageList(*images);
8361 *images=flatten_image;
8364 if (LocaleCompare(
"fx",option+1) == 0)
8369 (void) SyncImagesSettings(mogrify_info,*images,exception);
8370 fx_image=FxImage(*images,argv[i+1],exception);
8371 if (fx_image == (Image *) NULL)
8376 *images=DestroyImageList(*images);
8384 if (LocaleCompare(
"hald-clut",option+1) == 0)
8390 (void) SyncImagesSettings(mogrify_info,*images,exception);
8391 image=RemoveFirstImageFromList(images);
8392 hald_image=RemoveFirstImageFromList(images);
8393 if (hald_image == (Image *) NULL)
8395 (void) ThrowMagickException(exception,GetMagickModule(),
8396 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8397 image=DestroyImage(image);
8401 (void) HaldClutImage(image,hald_image,exception);
8402 hald_image=DestroyImage(hald_image);
8403 if (*images != (Image *) NULL)
8404 *images=DestroyImageList(*images);
8412 if (LocaleCompare(
"ift",option+1) == 0)
8422 (void) SyncImagesSettings(mogrify_info,*images,exception);
8423 magnitude_image=RemoveFirstImageFromList(images);
8424 phase_image=RemoveFirstImageFromList(images);
8425 if (phase_image == (Image *) NULL)
8427 (void) ThrowMagickException(exception,GetMagickModule(),
8428 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8429 magnitude_image=DestroyImage(magnitude_image);
8433 fourier_image=InverseFourierTransformImage(magnitude_image,
8434 phase_image,*option ==
'-' ? MagickTrue : MagickFalse,exception);
8435 magnitude_image=DestroyImage(magnitude_image);
8436 phase_image=DestroyImage(phase_image);
8437 if (fourier_image == (Image *) NULL)
8439 if (*images != (Image *) NULL)
8440 *images=DestroyImageList(*images);
8441 *images=fourier_image;
8444 if (LocaleCompare(
"insert",option+1) == 0)
8452 index=(ssize_t) StringToLong(argv[i+1]);
8453 p=RemoveLastImageFromList(images);
8454 if (p == (Image *) NULL)
8456 (void) ThrowMagickException(exception,GetMagickModule(),
8457 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8463 PrependImageToList(images,q);
8465 if (index == (ssize_t) GetImageListLength(*images))
8466 AppendImageToList(images,q);
8469 q=GetImageFromList(*images,index-1);
8470 if (q == (Image *) NULL)
8473 (void) ThrowMagickException(exception,GetMagickModule(),
8474 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8478 InsertImageInList(&q,p);
8480 *images=GetFirstImageInList(q);
8483 if (LocaleCompare(
"interpolate",option+1) == 0)
8485 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8486 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8493 if (LocaleCompare(
"layers",option+1) == 0)
8501 (void) SyncImagesSettings(mogrify_info,*images,exception);
8502 layers=(Image *) NULL;
8503 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8504 MagickFalse,argv[i+1]);
8509 layers=CoalesceImages(*images,exception);
8512 case CompareAnyLayer:
8513 case CompareClearLayer:
8514 case CompareOverlayLayer:
8517 layers=CompareImagesLayers(*images,method,exception);
8523 case TrimBoundsLayer:
8525 layers=MergeImageLayers(*images,method,exception);
8530 layers=DisposeImages(*images,exception);
8533 case OptimizeImageLayer:
8535 layers=OptimizeImageLayers(*images,exception);
8538 case OptimizePlusLayer:
8540 layers=OptimizePlusImageLayers(*images,exception);
8543 case OptimizeTransLayer:
8545 OptimizeImageTransparency(*images,exception);
8548 case RemoveDupsLayer:
8550 RemoveDuplicateLayers(images,exception);
8553 case RemoveZeroLayer:
8555 RemoveZeroDelayLayers(images,exception);
8563 layers=CoalesceImages(*images,exception);
8564 if (layers == (Image *) NULL)
8569 *images=DestroyImageList(*images);
8571 layers=OptimizeImageLayers(*images,exception);
8572 if (layers == (Image *) NULL)
8577 *images=DestroyImageList(*images);
8579 layers=(Image *) NULL;
8580 OptimizeImageTransparency(*images,exception);
8581 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8585 case CompositeLayer:
8600 while (source != (Image *) NULL)
8602 source=GetNextImageInList(source);
8603 if ((source != (Image *) NULL) &&
8604 (LocaleCompare(source->magick,
"NULL") == 0))
8607 if (source != (Image *) NULL)
8609 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8610 (GetNextImageInList(source) == (Image *) NULL))
8611 source=(Image *) NULL;
8617 source=SplitImageList(source->previous);
8618 DeleteImageFromList(&source);
8621 if (source == (Image *) NULL)
8623 (void) ThrowMagickException(exception,GetMagickModule(),
8624 OptionError,
"MissingNullSeparator",
"layers Composite");
8631 SetGeometry(*images,&geometry);
8632 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8633 geometry.width=source->page.width != 0 ?
8634 source->page.width : source->columns;
8635 geometry.height=source->page.height != 0 ?
8636 source->page.height : source->rows;
8637 GravityAdjustGeometry((*images)->page.width != 0 ?
8638 (*images)->page.width : (*images)->columns,
8639 (*images)->page.height != 0 ? (*images)->page.height :
8640 (*images)->rows,(*images)->gravity,&geometry);
8641 compose=OverCompositeOp;
8642 option=GetImageOption(mogrify_info,
"compose");
8643 if (option != (
const char *) NULL)
8644 compose=(CompositeOperator) ParseCommandOption(
8645 MagickComposeOptions,MagickFalse,option);
8646 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8648 source=DestroyImageList(source);
8652 if (layers == (Image *) NULL)
8654 *images=DestroyImageList(*images);
8662 if (LocaleCompare(
"map",option+1) == 0)
8664 (void) SyncImagesSettings(mogrify_info,*images,exception);
8667 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8674 if (LocaleCompare(
"maximum",option+1) == 0)
8682 (void) SyncImagesSettings(mogrify_info,*images,exception);
8683 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8684 if (maximum_image == (Image *) NULL)
8689 *images=DestroyImageList(*images);
8690 *images=maximum_image;
8693 if (LocaleCompare(
"minimum",option+1) == 0)
8701 (void) SyncImagesSettings(mogrify_info,*images,exception);
8702 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8703 if (minimum_image == (Image *) NULL)
8708 *images=DestroyImageList(*images);
8709 *images=minimum_image;
8712 if (LocaleCompare(
"morph",option+1) == 0)
8717 (void) SyncImagesSettings(mogrify_info,*images,exception);
8718 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8720 if (morph_image == (Image *) NULL)
8725 *images=DestroyImageList(*images);
8726 *images=morph_image;
8729 if (LocaleCompare(
"mosaic",option+1) == 0)
8734 (void) SyncImagesSettings(mogrify_info,*images,exception);
8735 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8736 if (mosaic_image == (Image *) NULL)
8741 *images=DestroyImageList(*images);
8742 *images=mosaic_image;
8749 if (LocaleCompare(
"poly",option+1) == 0)
8753 token[MagickPathExtent];
8773 (void) SyncImageSettings(mogrify_info,*images,exception);
8774 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8776 if (args == (
char *) NULL)
8779 for (x=0; *p !=
'\0'; x++)
8781 (void) GetNextToken(p,&p,MagickPathExtent,token);
8783 (void) GetNextToken(p,&p,MagickPathExtent,token);
8785 number_arguments=(size_t) x;
8786 arguments=(
double *) AcquireQuantumMemory(number_arguments,
8787 sizeof(*arguments));
8788 if (arguments == (
double *) NULL)
8789 ThrowWandFatalException(ResourceLimitFatalError,
8790 "MemoryAllocationFailed",(*images)->filename);
8791 (void) memset(arguments,0,number_arguments*
8792 sizeof(*arguments));
8794 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
8796 (void) GetNextToken(p,&p,MagickPathExtent,token);
8798 (void) GetNextToken(p,&p,MagickPathExtent,token);
8799 arguments[x]=StringToDouble(token,(
char **) NULL);
8801 args=DestroyString(args);
8802 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8803 arguments,exception);
8804 arguments=(
double *) RelinquishMagickMemory(arguments);
8805 if (polynomial_image == (Image *) NULL)
8810 *images=DestroyImageList(*images);
8811 *images=polynomial_image;
8813 if (LocaleCompare(
"print",option+1) == 0)
8818 (void) SyncImagesSettings(mogrify_info,*images,exception);
8819 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8821 if (
string == (
char *) NULL)
8823 (void) FormatLocaleFile(stdout,
"%s",
string);
8824 string=DestroyString(
string);
8826 if (LocaleCompare(
"process",option+1) == 0)
8835 (void) SyncImagesSettings(mogrify_info,*images,exception);
8836 arguments=StringToArgv(argv[i+1],&number_arguments);
8837 if ((arguments == (
char **) NULL) || (number_arguments == 1))
8839 if ((argc > 1) && (strchr(arguments[1],
'=') != (
char *) NULL))
8862 length=strlen(argv[i+1]);
8863 token=(
char *) NULL;
8864 if (~length >= (MagickPathExtent-1))
8865 token=(
char *) AcquireQuantumMemory(length+MagickPathExtent,
8867 if (token == (
char *) NULL)
8871 token_info=AcquireTokenInfo();
8872 token_status=Tokenizer(token_info,0,token,length,argument,
"",
8873 "=",
"\"",
'\0',&breaker,&next,"e);
8874 token_info=DestroyTokenInfo(token_info);
8875 if (token_status == 0)
8880 arg=(&(argument[next]));
8881 (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
8884 token=DestroyString(token);
8887 (void) SubstituteString(&arguments[1],
"-",
"");
8888 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8889 number_arguments-2,(
const char **) arguments+2,exception);
8890 for (j=0; j < number_arguments; j++)
8891 arguments[j]=DestroyString(arguments[j]);
8892 arguments=(
char **) RelinquishMagickMemory(arguments);
8899 if (LocaleCompare(
"reverse",option+1) == 0)
8901 ReverseImageList(images);
8908 if (LocaleCompare(
"smush",option+1) == 0)
8916 (void) SyncImagesSettings(mogrify_info,*images,exception);
8917 offset=(ssize_t) StringToLong(argv[i+1]);
8918 smush_image=SmushImages(*images,*option ==
'-' ? MagickTrue :
8919 MagickFalse,offset,exception);
8920 if (smush_image == (Image *) NULL)
8925 *images=DestroyImageList(*images);
8926 *images=smush_image;
8929 if (LocaleCompare(
"swap",option+1) == 0)
8951 flags=ParseGeometry(argv[i+1],&geometry_info);
8952 index=(ssize_t) geometry_info.rho;
8953 if ((flags & SigmaValue) != 0)
8954 swap_index=(ssize_t) geometry_info.sigma;
8956 p=GetImageFromList(*images,index);
8957 q=GetImageFromList(*images,swap_index);
8958 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8960 (void) ThrowMagickException(exception,GetMagickModule(),
8961 OptionError,
"NoSuchImage",
"`%s'",(*images)->filename);
8967 u=CloneImage(p,0,0,MagickTrue,exception);
8968 if (u == (Image *) NULL)
8970 v=CloneImage(q,0,0,MagickTrue,exception);
8971 if (v == (Image *) NULL)
8976 ReplaceImageInList(&p,v);
8977 ReplaceImageInList(&q,u);
8978 *images=GetFirstImageInList(q);
8985 if (LocaleCompare(
"write",option+1) == 0)
8988 key[MagickPathExtent];
8996 (void) SyncImagesSettings(mogrify_info,*images,exception);
8997 (void) FormatLocaleString(key,MagickPathExtent,
"cache:%s",
8999 (void) DeleteImageRegistry(key);
9000 write_images=CloneImageList(*images,exception);
9001 write_info=CloneImageInfo(mogrify_info);
9002 status&=(MagickStatusType) WriteImages(write_info,write_images,
9003 argv[i+1],exception);
9004 write_info=DestroyImageInfo(write_info);
9005 write_images=DestroyImageList(write_images);
9015 quantize_info=DestroyQuantizeInfo(quantize_info);
9016 mogrify_info=DestroyImageInfo(mogrify_info);
9017 status&=(MagickStatusType) MogrifyImageInfo(image_info,argc,argv,exception);
9018 return(status != 0 ? MagickTrue : MagickFalse);
9058WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
9059 const MagickBooleanType post,
const int argc,
const char **argv,
9060 Image **images,ExceptionInfo *exception)
9062#define MogrifyImageTag "Mogrify/Image"
9076 assert(image_info != (ImageInfo *) NULL);
9077 assert(image_info->signature == MagickCoreSignature);
9078 if (images == (Image **) NULL)
9079 return(MogrifyImage(image_info,argc,argv,images,exception));
9080 assert((*images)->previous == (Image *) NULL);
9081 assert((*images)->signature == MagickCoreSignature);
9082 if (IsEventLogging() != MagickFalse)
9083 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
9084 (*images)->filename);
9085 if ((argc <= 0) || (*argv == (
char *) NULL))
9087 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
9091 (void) FormatLocaleFile(stderr,
"mogrify start %s %d (%s)\n",argv[0],argc,
9097 if (post == MagickFalse)
9098 status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9104 n=GetImageListLength(*images);
9108 (void) FormatLocaleFile(stderr,
"mogrify %ld of %ld\n",(
long)
9109 GetImageIndexInList(*images),(
long)GetImageListLength(*images));
9111 status&=(MagickStatusType) MogrifyImage(image_info,argc,argv,images,
9113 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
9114 if (proceed == MagickFalse)
9116 if ( (*images)->next == (Image *) NULL )
9118 *images=(*images)->next;
9121 assert( *images != (Image *) NULL );
9123 (void) FormatLocaleFile(stderr,
"mogrify end %ld of %ld\n",(
long)
9124 GetImageIndexInList(*images),(
long)GetImageListLength(*images));
9129 *images=GetFirstImageInList(*images);
9130 if (post != MagickFalse)
9131 status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9133 return(status != 0 ? MagickTrue : MagickFalse);