47#include "wand/studio.h"
48#include "wand/MagickWand.h"
49#include "wand/magick-wand-private.h"
50#include "wand/mogrify-private.h"
51#include "magick/blob-private.h"
52#include "magick/color-private.h"
53#include "magick/geometry-private.h"
54#include "magick/image-private.h"
55#include "magick/monitor-private.h"
56#include "magick/pixel-private.h"
57#include "magick/thread-private.h"
58#include "magick/string-private.h"
59#include "magick/timer-private.h"
60#include "magick/utility-private.h"
61#if defined(MAGICKCORE_HAVE_UTIME_H)
68#define UndefinedCompressionQuality 0UL
74 MogrifyBackgroundColor[] =
"#fff",
75 MogrifyBorderColor[] =
"#dfdfdf",
76 MogrifyMatteColor[] =
"#bdbdbd";
118WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
119 MagickCommand command,
int argc,
char **argv,
char **metadata,
120 ExceptionInfo *exception)
144 (void) setlocale(LC_ALL,
"");
145 (void) setlocale(LC_NUMERIC,
"C");
146 concurrent=MagickFalse;
150 regard_warnings=MagickFalse;
151 for (i=1; i < (ssize_t) (argc-1); i++)
154 if ((strlen(option) == 1) || ((*option !=
'-') && (*option !=
'+')))
156 if (LocaleCompare(
"bench",option+1) == 0)
157 iterations=StringToUnsignedLong(argv[++i]);
158 if (LocaleCompare(
"concurrent",option+1) == 0)
159 concurrent=MagickTrue;
160 if (LocaleCompare(
"debug",option+1) == 0)
161 (
void) SetLogEventMask(argv[++i]);
162 if (LocaleCompare(
"distribute-cache",option+1) == 0)
164 DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
167 if (LocaleCompare(
"duration",option+1) == 0)
168 duration=StringToDouble(argv[++i],(
char **) NULL);
169 if (LocaleCompare(
"regard-warnings",option+1) == 0)
170 regard_warnings=MagickTrue;
174 status=command(image_info,argc,argv,metadata,exception);
175 if (exception->severity != UndefinedException)
177 if ((exception->severity > ErrorException) ||
178 (regard_warnings != MagickFalse))
180 CatchException(exception);
182 if ((metadata != (
char **) NULL) && (*metadata != (
char *) NULL))
184 (void) fputs(*metadata,stdout);
185 *metadata=DestroyString(*metadata);
189 number_threads=GetOpenMPMaximumThreads();
191 for (n=1; n <= (ssize_t) number_threads; n++)
201 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
202 timer=AcquireTimerInfo();
203 if (concurrent == MagickFalse)
205 for (i=0; i < (ssize_t) iterations; i++)
207 if (status == MagickFalse)
211 if (GetElapsedTime(timer) > duration)
213 (void) ContinueTimer(timer);
215 status=command(image_info,argc,argv,metadata,exception);
216 if (exception->severity != UndefinedException)
218 if ((exception->severity > ErrorException) ||
219 (regard_warnings != MagickFalse))
221 CatchException(exception);
223 if ((metadata != (
char **) NULL) && (*metadata != (
char *) NULL))
225 (void) fputs(*metadata,stdout);
226 *metadata=DestroyString(*metadata);
233#if defined(MAGICKCORE_OPENMP_SUPPORT)
234 # pragma omp parallel for shared(status)
236 for (i=0; i < (ssize_t) iterations; i++)
238 if (status == MagickFalse)
242 if (GetElapsedTime(timer) > duration)
244 (void) ContinueTimer(timer);
246 status=command(image_info,argc,argv,metadata,exception);
247#if defined(MAGICKCORE_OPENMP_SUPPORT)
248 # pragma omp critical (MagickCore_MagickCommandGenesis)
251 if (exception->severity != UndefinedException)
253 if ((exception->severity > ErrorException) ||
254 (regard_warnings != MagickFalse))
256 CatchException(exception);
258 if ((metadata != (
char **) NULL) && (*metadata != (
char *) NULL))
260 (void) fputs(*metadata,stdout);
261 *metadata=DestroyString(*metadata);
266 user_time=GetUserTime(timer);
267 parallel=GetElapsedTime(timer);
272 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
273 (
double) n)))-(1.0/(
double) n))/(1.0-1.0/(double) n);
274 (void) FormatLocaleFile(stderr,
275 " Performance[%.20g]: %.20gi %0.3fips %0.6fe %0.6fu %lu:%02lu.%03lu\n",
276 (
double) n,(double) iterations,(
double) iterations/parallel,e,user_time,
277 (
unsigned long) (parallel/60.0),(
unsigned long) floor(fmod(parallel,
278 60.0)),(
unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
279 timer=DestroyTimerInfo(timer);
343static inline Image *GetImageCache(
const ImageInfo *image_info,
const char *path,
344 ExceptionInfo *exception)
362 (void) FormatLocaleString(key,MaxTextExtent,
"cache:%s",path);
363 sans_exception=AcquireExceptionInfo();
364 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
365 sans_exception=DestroyExceptionInfo(sans_exception);
366 if (image != (Image *) NULL)
368 read_info=CloneImageInfo(image_info);
369 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
370 image=ReadImage(read_info,exception);
371 read_info=DestroyImageInfo(read_info);
372 if (image != (Image *) NULL)
373 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
377static inline MagickBooleanType IsPathWritable(
const char *path)
379 if (IsPathAccessible(path) == MagickFalse)
381 if (access_utf8(path,W_OK) != 0)
386static MagickBooleanType MonitorProgress(
const char *text,
387 const MagickOffsetType offset,
const MagickSizeType extent,
388 void *wand_unused(client_data))
391 message[MaxTextExtent],
400 wand_unreferenced(client_data);
402 (void) CopyMagickString(tag,text == (
const char *) NULL ?
"null" : text,
405 if (p != (
char *) NULL)
407 (void) FormatLocaleString(message,MaxTextExtent,
"Monitor/%s",tag);
408 locale_message=GetLocaleMessage(message);
409 if (locale_message == message)
411 if (p == (
char *) NULL)
412 (void) FormatLocaleFile(stderr,
"%s: %ld of %lu, %02ld%% complete\r",
413 locale_message,(
long) offset,(
unsigned long) extent,(
long)
414 (100.0*offset*PerceptibleReciprocal(extent-1.0)));
416 (
void) FormatLocaleFile(stderr,
"%s[%s]: %ld of %lu, %02ld%% complete\r",
417 locale_message,p+1,(
long) offset,(
unsigned long) extent,(
long)
418 (100.0*offset*PerceptibleReciprocal(extent-1.0)));
419 if (offset == (MagickOffsetType) (extent-1))
420 (void) FormatLocaleFile(stderr,
"\n");
421 (void) fflush(stderr);
425static Image *SparseColorOption(
const Image *image,
const ChannelType channel,
426 const SparseColorMethod method,
const char *arguments,
427 const MagickBooleanType color_from_image,ExceptionInfo *exception)
433 token[MaxTextExtent];
464 assert(image != (Image *) NULL);
465 assert(image->signature == MagickCoreSignature);
466 assert(exception != (ExceptionInfo *) NULL);
467 assert(exception->signature == MagickCoreSignature);
468 if (IsEventLogging() != MagickFalse)
469 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
474 if (image->colorspace != CMYKColorspace)
475 channels=(ChannelType) (channels & ~IndexChannel);
476 if (image->matte == MagickFalse)
477 channels=(ChannelType) (channels & ~OpacityChannel);
479 if ((channels & RedChannel) != 0)
481 if ((channels & GreenChannel) != 0)
483 if ((channels & BlueChannel) != 0)
485 if ((channels & IndexChannel) != 0)
487 if ((channels & OpacityChannel) != 0)
497 (void) GetNextToken(p,&p,MaxTextExtent,token);
498 if ( *token ==
',' )
continue;
499 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
500 if ( color_from_image ) {
501 (void) ThrowMagickException(exception,GetMagickModule(),
502 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
503 "Color arg given, when colors are coming from image");
504 return( (Image *) NULL);
513 if ( color_from_image ) {
515 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
516 number_arguments=(x/2)*(2+number_colors);
520 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
524 (void) ThrowMagickException(exception,GetMagickModule(),
525 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
526 "Invalid number of Arguments");
527 return( (Image *) NULL);
531 sparse_arguments=(
double *) AcquireQuantumMemory(number_arguments,
532 sizeof(*sparse_arguments));
533 if (sparse_arguments == (
double *) NULL) {
534 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
535 " MemoryAllocationFailed\n""%s",
"SparseColorOption");
536 return( (Image *) NULL);
538 (void) memset(sparse_arguments,0,number_arguments*
539 sizeof(*sparse_arguments));
542 while( *p !=
'\0' && x < number_arguments ) {
545 while ( *token ==
',' )
546 (void) GetNextToken(p,&p,MaxTextExtent,token);
547 if ( *token ==
'\0' )
break;
548 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
549 (void) ThrowMagickException(exception,GetMagickModule(),
550 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
551 "Color found, instead of X-coord");
555 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
557 *token=
',';
while ( *token ==
',' ) GetNextToken(p,&p,MaxTextExtent,token);
558 if ( *token ==
'\0' )
break;
559 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
560 (void) ThrowMagickException(exception,GetMagickModule(),
561 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
562 "Color found, instead of Y-coord");
566 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
569 if ( (color_from_image ) {
578 while ( *token ==
',' )
579 (
void) GetNextToken(p,&p,MaxTextExtent,token);
580 if ( *token ==
'\0' )
break;
581 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
583 (void) QueryMagickColor(token,&color,exception);
584 if ( channels & RedChannel )
585 sparse_arguments[x++] = QuantumScale*color.red;
586 if ( channels & GreenChannel )
587 sparse_arguments[x++] = QuantumScale*color.green;
588 if ( channels & BlueChannel )
589 sparse_arguments[x++] = QuantumScale*color.blue;
590 if ( channels & IndexChannel )
591 sparse_arguments[x++] = QuantumScale*color.index;
592 if ( channels & OpacityChannel )
593 sparse_arguments[x++] = QuantumScale*color.opacity;
598 if ( channels & RedChannel ) {
599 while ( *token ==
',' )
600 (void) GetNextToken(p,&p,MaxTextExtent,token);
601 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
603 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
606 if ( channels & GreenChannel ) {
607 while ( *token ==
',' )
608 (void) GetNextToken(p,&p,MaxTextExtent,token);
609 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
611 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
614 if ( channels & BlueChannel ) {
615 while ( *token ==
',' )
616 (void) GetNextToken(p,&p,MaxTextExtent,token);
617 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
619 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
622 if ( channels & IndexChannel ) {
623 while ( *token ==
',' )
624 (void) GetNextToken(p,&p,MaxTextExtent,token);
625 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
627 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
630 if ( channels & OpacityChannel ) {
631 while ( *token ==
',' )
632 (void) GetNextToken(p,&p,MaxTextExtent,token);
633 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
635 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
641 if ( number_arguments != x && !error ) {
642 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
643 " InvalidArgument",
"`%s': %s",
"sparse-color",
"Argument Parsing Error");
644 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
645 return( (Image *) NULL);
648 return( (Image *) NULL);
651 sparse_image=SparseColorImage(image,channels,method,number_arguments,
652 sparse_arguments,exception);
653 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
654 return( sparse_image );
657WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,
const int argc,
658 const char **argv,Image **image,ExceptionInfo *exception)
701 assert(image_info != (
const ImageInfo *) NULL);
702 assert(image_info->signature == MagickCoreSignature);
703 assert(image != (Image **) NULL);
704 assert((*image)->signature == MagickCoreSignature);
705 if (IsEventLogging() != MagickFalse)
706 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
709 mogrify_info=CloneImageInfo(image_info);
710 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
711 quantize_info=AcquireQuantizeInfo(mogrify_info);
712 SetGeometryInfo(&geometry_info);
713 GetMagickPixelPacket(*image,&fill);
714 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
716 channel=mogrify_info->channel;
717 format=GetImageOption(mogrify_info,
"format");
718 SetGeometry(*image,®ion_geometry);
719 region_image=NewImageList();
723 for (i=0; i < (ssize_t) argc; i++)
732 if (IsCommandOption(option) == MagickFalse)
734 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
736 if ((i+count) >= (ssize_t) argc)
738 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
739 mogrify_image=(Image *) NULL;
744 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
749 (void) SyncImageSettings(mogrify_info,*image);
750 flags=ParseGeometry(argv[i+1],&geometry_info);
751 if ((flags & SigmaValue) == 0)
752 geometry_info.sigma=1.0;
753 mogrify_image=AdaptiveBlurImageChannel(*image,channel,
754 geometry_info.rho,geometry_info.sigma,exception);
757 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
762 (void) SyncImageSettings(mogrify_info,*image);
763 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
764 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
765 geometry.height,exception);
768 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
773 (void) SyncImageSettings(mogrify_info,*image);
774 flags=ParseGeometry(argv[i+1],&geometry_info);
775 if ((flags & SigmaValue) == 0)
776 geometry_info.sigma=1.0;
777 mogrify_image=AdaptiveSharpenImageChannel(*image,channel,
778 geometry_info.rho,geometry_info.sigma,exception);
781 if (LocaleCompare(
"affine",option+1) == 0)
788 GetAffineMatrix(&draw_info->affine);
791 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
794 if (LocaleCompare(
"alpha",option+1) == 0)
799 (void) SyncImageSettings(mogrify_info,*image);
800 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
801 MagickFalse,argv[i+1]);
802 (void) SetImageAlphaChannel(*image,alpha_type);
803 InheritException(exception,&(*image)->exception);
806 if (LocaleCompare(
"annotate",option+1) == 0)
810 geometry[MaxTextExtent];
815 (void) SyncImageSettings(mogrify_info,*image);
816 SetGeometryInfo(&geometry_info);
817 flags=ParseGeometry(argv[i+1],&geometry_info);
818 if ((flags & SigmaValue) == 0)
819 geometry_info.sigma=geometry_info.rho;
820 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
821 InheritException(exception,&(*image)->exception);
822 if (text == (
char *) NULL)
824 (void) CloneString(&draw_info->text,text);
825 text=DestroyString(text);
826 (void) FormatLocaleString(geometry,MaxTextExtent,
"%+f%+f",
827 geometry_info.xi,geometry_info.psi);
828 (void) CloneString(&draw_info->geometry,geometry);
829 draw_info->affine.sx=cos(DegreesToRadians(
830 fmod(geometry_info.rho,360.0)));
831 draw_info->affine.rx=sin(DegreesToRadians(
832 fmod(geometry_info.rho,360.0)));
833 draw_info->affine.ry=(-sin(DegreesToRadians(
834 fmod(geometry_info.sigma,360.0))));
835 draw_info->affine.sy=cos(DegreesToRadians(
836 fmod(geometry_info.sigma,360.0)));
837 (void) AnnotateImage(*image,draw_info);
838 InheritException(exception,&(*image)->exception);
841 if (LocaleCompare(
"antialias",option+1) == 0)
843 draw_info->stroke_antialias=(*option ==
'-') ? MagickTrue :
845 draw_info->text_antialias=(*option ==
'-') ? MagickTrue :
849 if (LocaleCompare(
"auto-gamma",option+1) == 0)
854 (void) SyncImageSettings(mogrify_info,*image);
855 (void) AutoGammaImageChannel(*image,channel);
858 if (LocaleCompare(
"auto-level",option+1) == 0)
863 (void) SyncImageSettings(mogrify_info,*image);
864 (void) AutoLevelImageChannel(*image,channel);
867 if (LocaleCompare(
"auto-orient",option+1) == 0)
869 (void) SyncImageSettings(mogrify_info,*image);
870 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
878 if (LocaleCompare(
"black-threshold",option+1) == 0)
883 (void) SyncImageSettings(mogrify_info,*image);
884 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
886 InheritException(exception,&(*image)->exception);
889 if (LocaleCompare(
"blue-shift",option+1) == 0)
894 (void) SyncImageSettings(mogrify_info,*image);
895 geometry_info.rho=1.5;
897 flags=ParseGeometry(argv[i+1],&geometry_info);
898 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
901 if (LocaleCompare(
"blur",option+1) == 0)
906 (void) SyncImageSettings(mogrify_info,*image);
907 flags=ParseGeometry(argv[i+1],&geometry_info);
908 if ((flags & SigmaValue) == 0)
909 geometry_info.sigma=1.0;
910 mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho,
911 geometry_info.sigma,exception);
914 if (LocaleCompare(
"border",option+1) == 0)
919 (void) SyncImageSettings(mogrify_info,*image);
920 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
921 mogrify_image=BorderImage(*image,&geometry,exception);
924 if (LocaleCompare(
"bordercolor",option+1) == 0)
928 (void) QueryColorDatabase(MogrifyBorderColor,
929 &draw_info->border_color,exception);
932 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
936 if (LocaleCompare(
"box",option+1) == 0)
938 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
942 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
957 (void) SyncImageSettings(mogrify_info,*image);
958 flags=ParseGeometry(argv[i+1],&geometry_info);
959 brightness=geometry_info.rho;
961 if ((flags & SigmaValue) != 0)
962 contrast=geometry_info.sigma;
963 (void) BrightnessContrastImageChannel(*image,channel,brightness,
965 InheritException(exception,&(*image)->exception);
972 if (LocaleCompare(
"canny",option+1) == 0)
977 (void) SyncImageSettings(mogrify_info,*image);
978 flags=ParseGeometry(argv[i+1],&geometry_info);
979 if ((flags & SigmaValue) == 0)
980 geometry_info.sigma=1.0;
981 if ((flags & XiValue) == 0)
982 geometry_info.xi=0.10;
983 if ((flags & PsiValue) == 0)
984 geometry_info.psi=0.30;
985 if ((flags & PercentValue) != 0)
987 geometry_info.xi/=100.0;
988 geometry_info.psi/=100.0;
990 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
991 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
994 if (LocaleCompare(
"cdl",option+1) == 0)
997 *color_correction_collection;
1002 (void) SyncImageSettings(mogrify_info,*image);
1003 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
1004 if (color_correction_collection == (
char *) NULL)
1006 (void) ColorDecisionListImage(*image,color_correction_collection);
1007 InheritException(exception,&(*image)->exception);
1010 if (LocaleCompare(
"channel",option+1) == 0)
1013 channel=DefaultChannels;
1015 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1018 if (LocaleCompare(
"charcoal",option+1) == 0)
1023 (void) SyncImageSettings(mogrify_info,*image);
1024 flags=ParseGeometry(argv[i+1],&geometry_info);
1025 if ((flags & SigmaValue) == 0)
1026 geometry_info.sigma=1.0;
1027 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1028 geometry_info.sigma,exception);
1031 if (LocaleCompare(
"chop",option+1) == 0)
1036 (void) SyncImageSettings(mogrify_info,*image);
1037 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1038 mogrify_image=ChopImage(*image,&geometry,exception);
1041 if (LocaleCompare(
"clamp",option+1) == 0)
1046 (void) SyncImageSettings(mogrify_info,*image);
1047 (void) ClampImageChannel(*image,channel);
1048 InheritException(exception,&(*image)->exception);
1051 if (LocaleCompare(
"clip",option+1) == 0)
1053 (void) SyncImageSettings(mogrify_info,*image);
1056 (void) SetImageClipMask(*image,(Image *) NULL);
1057 InheritException(exception,&(*image)->exception);
1060 (void) ClipImage(*image);
1061 InheritException(exception,&(*image)->exception);
1064 if (LocaleCompare(
"clip-mask",option+1) == 0)
1081 (void) SyncImageSettings(mogrify_info,*image);
1087 (void) SetImageMask(*image,(Image *) NULL);
1088 InheritException(exception,&(*image)->exception);
1095 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1096 if (mask_image == (Image *) NULL)
1098 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1099 return(MagickFalse);
1100 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1101 for (y=0; y < (ssize_t) mask_image->rows; y++)
1103 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1105 if (q == (PixelPacket *) NULL)
1107 for (x=0; x < (ssize_t) mask_image->columns; x++)
1109 if (mask_image->matte == MagickFalse)
1110 SetPixelOpacity(q,ClampToQuantum(GetPixelIntensity(mask_image,
1112 SetPixelRed(q,GetPixelOpacity(q));
1113 SetPixelGreen(q,GetPixelOpacity(q));
1114 SetPixelBlue(q,GetPixelOpacity(q));
1117 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1120 mask_view=DestroyCacheView(mask_view);
1121 mask_image->matte=MagickTrue;
1122 (void) SetImageClipMask(*image,mask_image);
1123 mask_image=DestroyImage(mask_image);
1124 InheritException(exception,&(*image)->exception);
1127 if (LocaleCompare(
"clip-path",option+1) == 0)
1129 (void) SyncImageSettings(mogrify_info,*image);
1130 (void) ClipImagePath(*image,argv[i+1],*option ==
'-' ? MagickTrue :
1132 InheritException(exception,&(*image)->exception);
1135 if (LocaleCompare(
"colorize",option+1) == 0)
1140 (void) SyncImageSettings(mogrify_info,*image);
1141 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1145 if (LocaleCompare(
"color-matrix",option+1) == 0)
1150 (void) SyncImageSettings(mogrify_info,*image);
1151 kernel=AcquireKernelInfo(argv[i+1]);
1152 if (kernel == (KernelInfo *) NULL)
1154 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1155 kernel=DestroyKernelInfo(kernel);
1158 if (LocaleCompare(
"colors",option+1) == 0)
1163 (void) SyncImageSettings(mogrify_info,*image);
1164 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1165 if (quantize_info->number_colors == 0)
1167 if (((*image)->storage_class == DirectClass) ||
1168 (*image)->colors > quantize_info->number_colors)
1169 (void) QuantizeImage(quantize_info,*image);
1171 (
void) CompressImageColormap(*image);
1172 InheritException(exception,&(*image)->exception);
1175 if (LocaleCompare(
"colorspace",option+1) == 0)
1180 (void) SyncImageSettings(mogrify_info,*image);
1183 (void) TransformImageColorspace(*image,sRGBColorspace);
1184 InheritException(exception,&(*image)->exception);
1187 colorspace=(ColorspaceType) ParseCommandOption(
1188 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1189 (void) TransformImageColorspace(*image,colorspace);
1190 InheritException(exception,&(*image)->exception);
1193 if (LocaleCompare(
"connected-components",option+1) == 0)
1195 (void) SyncImageSettings(mogrify_info,*image);
1196 mogrify_image=ConnectedComponentsImage(*image,
1197 (
size_t) StringToInteger(argv[i+1]),exception);
1200 if (LocaleCompare(
"contrast",option+1) == 0)
1202 (void) SyncImageSettings(mogrify_info,*image);
1203 (void) ContrastImage(*image,(*option ==
'-') ? MagickTrue :
1205 InheritException(exception,&(*image)->exception);
1208 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
1220 (void) SyncImageSettings(mogrify_info,*image);
1221 flags=ParseGeometry(argv[i+1],&geometry_info);
1222 black_point=geometry_info.rho;
1223 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1225 if ((flags & PercentValue) != 0)
1227 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1228 white_point*=(
double) (*image)->columns*(*image)->rows/100.0;
1230 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1232 (
void) ContrastStretchImageChannel(*image,channel,black_point,
1234 InheritException(exception,&(*image)->exception);
1237 if (LocaleCompare(
"convolve",option+1) == 0)
1251 (void) SyncImageSettings(mogrify_info,*image);
1252 kernel_info=AcquireKernelInfo(argv[i+1]);
1253 if (kernel_info == (KernelInfo *) NULL)
1255 extent=kernel_info->width*kernel_info->height;
1257 for (j=0; j < (ssize_t) extent; j++)
1258 gamma+=kernel_info->values[j];
1259 gamma=1.0/(fabs((
double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1260 for (j=0; j < (ssize_t) extent; j++)
1261 kernel_info->values[j]*=gamma;
1262 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1263 kernel_info,exception);
1264 kernel_info=DestroyKernelInfo(kernel_info);
1267 if (LocaleCompare(
"crop",option+1) == 0)
1272 (void) SyncImageSettings(mogrify_info,*image);
1274 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1275 if (((geometry.width != 0) || (geometry.height != 0)) &&
1276 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1280 mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
1281 mogrify_image->next = mogrify_image->previous = (Image *) NULL;
1282 (void) TransformImage(&mogrify_image,argv[i+1],(
char *) NULL);
1283 InheritException(exception,&mogrify_image->exception);
1285 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1289 if (LocaleCompare(
"cycle",option+1) == 0)
1294 (void) SyncImageSettings(mogrify_info,*image);
1295 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]));
1296 InheritException(exception,&(*image)->exception);
1303 if (LocaleCompare(
"decipher",option+1) == 0)
1311 (void) SyncImageSettings(mogrify_info,*image);
1312 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1313 if (passkey != (StringInfo *) NULL)
1315 (void) PasskeyDecipherImage(*image,passkey,exception);
1316 passkey=DestroyStringInfo(passkey);
1320 if (LocaleCompare(
"density",option+1) == 0)
1325 (void) CloneString(&draw_info->density,argv[i+1]);
1328 if (LocaleCompare(
"depth",option+1) == 0)
1330 (void) SyncImageSettings(mogrify_info,*image);
1333 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1336 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1339 if (LocaleCompare(
"deskew",option+1) == 0)
1347 (void) SyncImageSettings(mogrify_info,*image);
1349 threshold=40.0*(double) QuantumRange/100.0;
1351 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
1353 mogrify_image=DeskewImage(*image,threshold,exception);
1356 if (LocaleCompare(
"despeckle",option+1) == 0)
1361 (void) SyncImageSettings(mogrify_info,*image);
1362 mogrify_image=DespeckleImage(*image,exception);
1365 if (LocaleCompare(
"display",option+1) == 0)
1367 (void) CloneString(&draw_info->server_name,argv[i+1]);
1370 if (LocaleCompare(
"distort",option+1) == 0)
1374 token[MaxTextExtent];
1394 (void) SyncImageSettings(mogrify_info,*image);
1395 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1396 MagickFalse,argv[i+1]);
1397 if (method == ResizeDistortion)
1405 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1407 resize_args[0]=(double) geometry.width;
1408 resize_args[1]=(
double) geometry.height;
1409 mogrify_image=DistortImage(*image,method,(
size_t) 2,
1410 resize_args,MagickTrue,exception);
1413 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1414 InheritException(exception,&(*image)->exception);
1415 if (args == (
char *) NULL)
1418 for (x=0; *p !=
'\0'; x++)
1420 (void) GetNextToken(p,&p,MaxTextExtent,token);
1422 (void) GetNextToken(p,&p,MaxTextExtent,token);
1424 number_arguments=(size_t) x;
1425 arguments=(
double *) AcquireQuantumMemory(number_arguments,
1426 sizeof(*arguments));
1427 if (arguments == (
double *) NULL)
1428 ThrowWandFatalException(ResourceLimitFatalError,
1429 "MemoryAllocationFailed",(*image)->filename);
1430 (void) memset(arguments,0,number_arguments*
sizeof(*arguments));
1432 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
1434 (void) GetNextToken(p,&p,MaxTextExtent,token);
1436 (void) GetNextToken(p,&p,MaxTextExtent,token);
1437 arguments[x]=StringToDouble(token,(
char **) NULL);
1439 args=DestroyString(args);
1440 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1441 (*option ==
'+') ? MagickTrue : MagickFalse,exception);
1442 arguments=(
double *) RelinquishMagickMemory(arguments);
1445 if (LocaleCompare(
"dither",option+1) == 0)
1449 quantize_info->dither=MagickFalse;
1452 quantize_info->dither=MagickTrue;
1453 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1454 MagickDitherOptions,MagickFalse,argv[i+1]);
1455 if (quantize_info->dither_method == NoDitherMethod)
1456 quantize_info->dither=MagickFalse;
1459 if (LocaleCompare(
"draw",option+1) == 0)
1464 (void) SyncImageSettings(mogrify_info,*image);
1465 (void) CloneString(&draw_info->primitive,argv[i+1]);
1466 (void) DrawImage(*image,draw_info);
1467 InheritException(exception,&(*image)->exception);
1474 if (LocaleCompare(
"edge",option+1) == 0)
1479 (void) SyncImageSettings(mogrify_info,*image);
1480 flags=ParseGeometry(argv[i+1],&geometry_info);
1481 if ((flags & SigmaValue) == 0)
1482 geometry_info.sigma=1.0;
1483 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1486 if (LocaleCompare(
"emboss",option+1) == 0)
1491 (void) SyncImageSettings(mogrify_info,*image);
1492 flags=ParseGeometry(argv[i+1],&geometry_info);
1493 if ((flags & SigmaValue) == 0)
1494 geometry_info.sigma=1.0;
1495 mogrify_image=EmbossImage(*image,geometry_info.rho,
1496 geometry_info.sigma,exception);
1499 if (LocaleCompare(
"encipher",option+1) == 0)
1507 (void) SyncImageSettings(mogrify_info,*image);
1508 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1509 if (passkey != (StringInfo *) NULL)
1511 (void) PasskeyEncipherImage(*image,passkey,exception);
1512 passkey=DestroyStringInfo(passkey);
1516 if (LocaleCompare(
"encoding",option+1) == 0)
1518 (void) CloneString(&draw_info->encoding,argv[i+1]);
1521 if (LocaleCompare(
"enhance",option+1) == 0)
1526 (void) SyncImageSettings(mogrify_info,*image);
1527 mogrify_image=EnhanceImage(*image,exception);
1530 if (LocaleCompare(
"equalize",option+1) == 0)
1535 (void) SyncImageSettings(mogrify_info,*image);
1536 (void) EqualizeImageChannel(*image,channel);
1537 InheritException(exception,&(*image)->exception);
1540 if (LocaleCompare(
"evaluate",option+1) == 0)
1545 MagickEvaluateOperator
1548 (void) SyncImageSettings(mogrify_info,*image);
1549 op=(MagickEvaluateOperator) ParseCommandOption(
1550 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1551 constant=StringToDoubleInterval(argv[i+2],(
double) QuantumRange+
1553 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1556 if (LocaleCompare(
"extent",option+1) == 0)
1561 (void) SyncImageSettings(mogrify_info,*image);
1562 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1563 if (geometry.width == 0)
1564 geometry.width=(*image)->columns;
1565 if (geometry.height == 0)
1566 geometry.height=(*image)->rows;
1567 mogrify_image=ExtentImage(*image,&geometry,exception);
1574 if (LocaleCompare(
"family",option+1) == 0)
1578 if (draw_info->family != (
char *) NULL)
1579 draw_info->family=DestroyString(draw_info->family);
1582 (void) SetImageOption(image_info,option+1,argv[i+1]);
1583 (void) CloneString(&draw_info->family,argv[i+1]);
1586 if (LocaleCompare(
"features",option+1) == 0)
1590 (void) DeleteImageArtifact(*image,
"identify:features");
1593 (void) SetImageArtifact(*image,
"identify:features",argv[i+1]);
1594 (void) SetImageArtifact(*image,
"verbose",
"true");
1597 if (LocaleCompare(
"fill",option+1) == 0)
1602 GetMagickPixelPacket(*image,&fill);
1605 (void) QueryMagickColor(
"none",&fill,exception);
1606 (void) QueryColorDatabase(
"none",&draw_info->fill,exception);
1607 if (draw_info->fill_pattern != (Image *) NULL)
1608 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1611 sans=AcquireExceptionInfo();
1612 (void) QueryMagickColor(argv[i+1],&fill,sans);
1613 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1614 sans=DestroyExceptionInfo(sans);
1615 if (status == MagickFalse)
1616 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1620 if (LocaleCompare(
"flip",option+1) == 0)
1625 (void) SyncImageSettings(mogrify_info,*image);
1626 mogrify_image=FlipImage(*image,exception);
1629 if (LocaleCompare(
"floodfill",option+1) == 0)
1637 (void) SyncImageSettings(mogrify_info,*image);
1638 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1639 (void) QueryMagickColor(argv[i+2],&target,exception);
1640 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1641 geometry.x,geometry.y,*option ==
'-' ? MagickFalse : MagickTrue);
1642 InheritException(exception,&(*image)->exception);
1645 if (LocaleCompare(
"flop",option+1) == 0)
1650 (void) SyncImageSettings(mogrify_info,*image);
1651 mogrify_image=FlopImage(*image,exception);
1654 if (LocaleCompare(
"font",option+1) == 0)
1658 if (draw_info->font != (
char *) NULL)
1659 draw_info->font=DestroyString(draw_info->font);
1662 (void) CloneString(&draw_info->font,argv[i+1]);
1665 if (LocaleCompare(
"format",option+1) == 0)
1670 if (LocaleCompare(
"frame",option+1) == 0)
1678 (void) SyncImageSettings(mogrify_info,*image);
1679 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1680 frame_info.width=geometry.width;
1681 frame_info.height=geometry.height;
1682 frame_info.outer_bevel=geometry.x;
1683 frame_info.inner_bevel=geometry.y;
1684 frame_info.x=(ssize_t) frame_info.width;
1685 frame_info.y=(ssize_t) frame_info.height;
1686 frame_info.width=(*image)->columns+2*frame_info.width;
1687 frame_info.height=(*image)->rows+2*frame_info.height;
1688 mogrify_image=FrameImage(*image,&frame_info,exception);
1691 if (LocaleCompare(
"function",option+1) == 0)
1695 token[MaxTextExtent];
1715 (void) SyncImageSettings(mogrify_info,*image);
1716 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1717 MagickFalse,argv[i+1]);
1718 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1719 InheritException(exception,&(*image)->exception);
1720 if (arguments == (
char *) NULL)
1722 p=(
char *) arguments;
1723 for (x=0; *p !=
'\0'; x++)
1725 (void) GetNextToken(p,&p,MaxTextExtent,token);
1727 (void) GetNextToken(p,&p,MaxTextExtent,token);
1729 number_parameters=(size_t) x;
1730 parameters=(
double *) AcquireQuantumMemory(number_parameters,
1731 sizeof(*parameters));
1732 if (parameters == (
double *) NULL)
1733 ThrowWandFatalException(ResourceLimitFatalError,
1734 "MemoryAllocationFailed",(*image)->filename);
1735 (void) memset(parameters,0,number_parameters*
1736 sizeof(*parameters));
1737 p=(
char *) arguments;
1738 for (x=0; (x < (ssize_t) number_parameters) && (*p !=
'\0'); x++)
1740 (void) GetNextToken(p,&p,MaxTextExtent,token);
1742 (void) GetNextToken(p,&p,MaxTextExtent,token);
1743 parameters[x]=StringToDouble(token,(
char **) NULL);
1745 arguments=DestroyString(arguments);
1746 (void) FunctionImageChannel(*image,channel,function,
1747 number_parameters,parameters,exception);
1748 parameters=(
double *) RelinquishMagickMemory(parameters);
1755 if (LocaleCompare(
"gamma",option+1) == 0)
1760 (void) SyncImageSettings(mogrify_info,*image);
1762 (*image)->gamma=StringToDouble(argv[i+1],(
char **) NULL);
1765 if (strchr(argv[i+1],
',') != (
char *) NULL)
1766 (void) GammaImage(*image,argv[i+1]);
1768 (
void) GammaImageChannel(*image,channel,
1769 StringToDouble(argv[i+1],(
char **) NULL));
1770 InheritException(exception,&(*image)->exception);
1774 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
1775 (LocaleCompare(
"gaussian",option+1) == 0))
1780 (void) SyncImageSettings(mogrify_info,*image);
1781 flags=ParseGeometry(argv[i+1],&geometry_info);
1782 if ((flags & SigmaValue) == 0)
1783 geometry_info.sigma=1.0;
1784 mogrify_image=GaussianBlurImageChannel(*image,channel,
1785 geometry_info.rho,geometry_info.sigma,exception);
1788 if (LocaleCompare(
"geometry",option+1) == 0)
1793 (void) SyncImageSettings(mogrify_info,*image);
1796 if ((*image)->geometry != (
char *) NULL)
1797 (*image)->geometry=DestroyString((*image)->geometry);
1800 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1801 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1802 (void) CloneString(&(*image)->geometry,argv[i+1]);
1804 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1805 (*image)->filter,(*image)->blur,exception);
1808 if (LocaleCompare(
"gravity",option+1) == 0)
1812 draw_info->gravity=UndefinedGravity;
1815 draw_info->gravity=(GravityType) ParseCommandOption(
1816 MagickGravityOptions,MagickFalse,argv[i+1]);
1819 if (LocaleCompare(
"grayscale",option+1) == 0)
1821 PixelIntensityMethod
1824 (void) SyncImagesSettings(mogrify_info,*image);
1825 method=(PixelIntensityMethod) ParseCommandOption(
1826 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1827 (void) GrayscaleImage(*image,method);
1828 InheritException(exception,&(*image)->exception);
1835 if (LocaleCompare(
"highlight-color",option+1) == 0)
1837 (void) SetImageArtifact(*image,
"compare:highlight-color",argv[i+1]);
1840 if (LocaleCompare(
"hough-lines",option+1) == 0)
1845 (void) SyncImageSettings(mogrify_info,*image);
1846 flags=ParseGeometry(argv[i+1],&geometry_info);
1847 if ((flags & SigmaValue) == 0)
1848 geometry_info.sigma=geometry_info.rho;
1849 if ((flags & XiValue) == 0)
1850 geometry_info.xi=40;
1851 mogrify_image=HoughLineImage(*image,(
size_t) geometry_info.rho,
1852 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,exception);
1859 if (LocaleCompare(
"identify",option+1) == 0)
1864 (void) SyncImageSettings(mogrify_info,*image);
1865 if (format == (
char *) NULL)
1867 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1868 InheritException(exception,&(*image)->exception);
1871 text=InterpretImageProperties(mogrify_info,*image,format);
1872 InheritException(exception,&(*image)->exception);
1873 if (text == (
char *) NULL)
1875 (void) fputs(text,stdout);
1876 text=DestroyString(text);
1879 if (LocaleCompare(
"implode",option+1) == 0)
1884 (void) SyncImageSettings(mogrify_info,*image);
1885 (void) ParseGeometry(argv[i+1],&geometry_info);
1886 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1889 if (LocaleCompare(
"interline-spacing",option+1) == 0)
1892 (void) ParseGeometry(
"0",&geometry_info);
1894 (
void) ParseGeometry(argv[i+1],&geometry_info);
1895 draw_info->interline_spacing=geometry_info.rho;
1898 if (LocaleCompare(
"interword-spacing",option+1) == 0)
1901 (void) ParseGeometry(
"0",&geometry_info);
1903 (
void) ParseGeometry(argv[i+1],&geometry_info);
1904 draw_info->interword_spacing=geometry_info.rho;
1907 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
1912 (void) SyncImageSettings(mogrify_info,*image);
1913 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1914 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1915 geometry.height,(*image)->interpolate,exception);
1922 if (LocaleCompare(
"kerning",option+1) == 0)
1925 (void) ParseGeometry(
"0",&geometry_info);
1927 (
void) ParseGeometry(argv[i+1],&geometry_info);
1928 draw_info->kerning=geometry_info.rho;
1931 if (LocaleCompare(
"kuwahara",option+1) == 0)
1936 (void) SyncImageSettings(mogrify_info,*image);
1937 flags=ParseGeometry(argv[i+1],&geometry_info);
1938 if ((flags & SigmaValue) == 0)
1939 geometry_info.sigma=geometry_info.rho-0.5;
1940 mogrify_image=KuwaharaImageChannel(*image,channel,geometry_info.rho,
1941 geometry_info.sigma,exception);
1948 if (LocaleCompare(
"lat",option+1) == 0)
1953 (void) SyncImageSettings(mogrify_info,*image);
1954 flags=ParseGeometry(argv[i+1],&geometry_info);
1955 if ((flags & SigmaValue) == 0)
1956 geometry_info.sigma=1.0;
1957 if ((flags & PercentValue) != 0)
1958 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1959 mogrify_image=AdaptiveThresholdImage(*image,(
size_t)
1960 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1961 geometry_info.xi,exception);
1964 if (LocaleCompare(
"level",option+1) == 0)
1977 (void) SyncImageSettings(mogrify_info,*image);
1978 flags=ParseGeometry(argv[i+1],&geometry_info);
1979 black_point=geometry_info.rho;
1980 white_point=(MagickRealType) QuantumRange;
1981 if ((flags & SigmaValue) != 0)
1982 white_point=geometry_info.sigma;
1984 if ((flags & XiValue) != 0)
1985 gamma=geometry_info.xi;
1986 if ((flags & PercentValue) != 0)
1988 black_point*=(double) QuantumRange/100.0;
1989 white_point*=(double) QuantumRange/100.0;
1991 if ((flags & SigmaValue) == 0)
1992 white_point=(MagickRealType) QuantumRange-black_point;
1993 if ((*option ==
'+') || ((flags & AspectValue) != 0))
1994 (
void) LevelizeImageChannel(*image,channel,black_point,
1997 (
void) LevelImageChannel(*image,channel,black_point,white_point,
1999 InheritException(exception,&(*image)->exception);
2002 if (LocaleCompare(
"level-colors",option+1) == 0)
2005 token[MaxTextExtent];
2014 p=(
const char *) argv[i+1];
2015 (void) GetNextToken(p,&p,MaxTextExtent,token);
2016 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2017 (void) QueryMagickColor(token,&black_point,exception);
2019 (
void) QueryMagickColor(
"#000000",&black_point,exception);
2020 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
2021 (void) GetNextToken(p,&p,MaxTextExtent,token);
2023 white_point=black_point;
2026 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
2027 (
void) GetNextToken(p,&p,MaxTextExtent,token);
2028 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2029 (void) QueryMagickColor(token,&white_point,exception);
2031 (
void) QueryMagickColor(
"#ffffff",&white_point,exception);
2033 (void) LevelColorsImageChannel(*image,channel,&black_point,
2034 &white_point,*option ==
'+' ? MagickTrue : MagickFalse);
2037 if (LocaleCompare(
"linear-stretch",option+1) == 0)
2046 (void) SyncImageSettings(mogrify_info,*image);
2047 flags=ParseGeometry(argv[i+1],&geometry_info);
2048 black_point=geometry_info.rho;
2049 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2050 if ((flags & SigmaValue) != 0)
2051 white_point=geometry_info.sigma;
2052 if ((flags & PercentValue) != 0)
2054 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2055 white_point*=(
double) (*image)->columns*(*image)->rows/100.0;
2057 if ((flags & SigmaValue) == 0)
2058 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2060 (void) LinearStretchImage(*image,black_point,white_point);
2061 InheritException(exception,&(*image)->exception);
2064 if (LocaleCompare(
"linewidth",option+1) == 0)
2066 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
2069 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
2074 (void) SyncImageSettings(mogrify_info,*image);
2075 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2076 if ((flags & XValue) == 0)
2078 if ((flags & YValue) == 0)
2080 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2081 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2084 if (LocaleCompare(
"local-contrast",option+1) == 0)
2089 (void) SyncImageSettings(mogrify_info,*image);
2090 flags=ParseGeometry(argv[i+1],&geometry_info);
2091 if ((flags & RhoValue) == 0)
2092 geometry_info.rho=10;
2093 if ((flags & SigmaValue) == 0)
2094 geometry_info.sigma=12.5;
2095 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
2096 geometry_info.sigma,exception);
2099 if (LocaleCompare(
"lowlight-color",option+1) == 0)
2101 (void) SetImageArtifact(*image,
"compare:lowlight-color",argv[i+1]);
2108 if (LocaleCompare(
"magnify",option+1) == 0)
2113 (void) SyncImageSettings(mogrify_info,*image);
2114 mogrify_image=MagnifyImage(*image,exception);
2117 if (LocaleCompare(
"map",option+1) == 0)
2125 (void) SyncImageSettings(mogrify_info,*image);
2128 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2129 if (remap_image == (Image *) NULL)
2131 (void) RemapImage(quantize_info,*image,remap_image);
2132 InheritException(exception,&(*image)->exception);
2133 remap_image=DestroyImage(remap_image);
2136 if (LocaleCompare(
"mask",option+1) == 0)
2141 (void) SyncImageSettings(mogrify_info,*image);
2147 (void) SetImageMask(*image,(Image *) NULL);
2148 InheritException(exception,&(*image)->exception);
2154 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2155 if (mask == (Image *) NULL)
2157 (void) SetImageMask(*image,mask);
2158 mask=DestroyImage(mask);
2159 InheritException(exception,&(*image)->exception);
2162 if (LocaleCompare(
"matte",option+1) == 0)
2164 (void) SetImageAlphaChannel(*image,(*option ==
'-') ?
2165 SetAlphaChannel : DeactivateAlphaChannel );
2166 InheritException(exception,&(*image)->exception);
2169 if (LocaleCompare(
"mean-shift",option+1) == 0)
2174 (void) SyncImageSettings(mogrify_info,*image);
2175 flags=ParseGeometry(argv[i+1],&geometry_info);
2176 if ((flags & SigmaValue) == 0)
2177 geometry_info.sigma=geometry_info.rho;
2178 if ((flags & XiValue) == 0)
2179 geometry_info.xi=0.10*(double) QuantumRange;
2180 if ((flags & PercentValue) != 0)
2181 geometry_info.xi=(
double) QuantumRange*geometry_info.xi/100.0;
2182 mogrify_image=MeanShiftImage(*image,(
size_t) geometry_info.rho,
2183 (
size_t) geometry_info.sigma,geometry_info.xi,exception);
2186 if (LocaleCompare(
"median",option+1) == 0)
2191 (void) SyncImageSettings(mogrify_info,*image);
2192 (void) ParseGeometry(argv[i+1],&geometry_info);
2193 mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic,
2194 (
size_t) geometry_info.rho,(
size_t) geometry_info.rho,exception);
2197 if (LocaleCompare(
"mode",option+1) == 0)
2202 (void) SyncImageSettings(mogrify_info,*image);
2203 (void) ParseGeometry(argv[i+1],&geometry_info);
2204 mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic,
2205 (
size_t) geometry_info.rho,(
size_t) geometry_info.rho,exception);
2208 if (LocaleCompare(
"modulate",option+1) == 0)
2210 (void) SyncImageSettings(mogrify_info,*image);
2211 (void) ModulateImage(*image,argv[i+1]);
2212 InheritException(exception,&(*image)->exception);
2215 if (LocaleCompare(
"moments",option+1) == 0)
2219 (void) DeleteImageArtifact(*image,
"identify:moments");
2222 (void) SetImageArtifact(*image,
"identify:moments",argv[i+1]);
2223 (void) SetImageArtifact(*image,
"verbose",
"true");
2226 if (LocaleCompare(
"monitor",option+1) == 0)
2230 (void) SetImageProgressMonitor(*image,
2231 (MagickProgressMonitor) NULL,(
void *) NULL);
2234 (void) SetImageProgressMonitor(*image,MonitorProgress,
2238 if (LocaleCompare(
"monochrome",option+1) == 0)
2240 (void) SyncImageSettings(mogrify_info,*image);
2241 (void) SetImageType(*image,BilevelType);
2242 InheritException(exception,&(*image)->exception);
2245 if (LocaleCompare(
"morphology",option+1) == 0)
2248 token[MaxTextExtent];
2265 (void) SyncImageSettings(mogrify_info,*image);
2267 (void) GetNextToken(p,&p,MaxTextExtent,token);
2268 method=(MorphologyMethod) ParseCommandOption(
2269 MagickMorphologyOptions,MagickFalse,token);
2271 (void) GetNextToken(p,&p,MaxTextExtent,token);
2272 if ((*p ==
':') || (*p ==
','))
2273 (void) GetNextToken(p,&p,MaxTextExtent,token);
2275 iterations=(ssize_t) StringToLong(p);
2276 kernel=AcquireKernelInfo(argv[i+2]);
2277 if (kernel == (KernelInfo *) NULL)
2279 (void) ThrowMagickException(exception,GetMagickModule(),
2280 OptionError,
"UnabletoParseKernel",
"morphology");
2284 mogrify_image=MorphologyImageChannel(*image,channel,method,
2285 iterations,kernel,exception);
2286 kernel=DestroyKernelInfo(kernel);
2289 if (LocaleCompare(
"motion-blur",option+1) == 0)
2294 (void) SyncImageSettings(mogrify_info,*image);
2295 flags=ParseGeometry(argv[i+1],&geometry_info);
2296 if ((flags & SigmaValue) == 0)
2297 geometry_info.sigma=1.0;
2298 mogrify_image=MotionBlurImageChannel(*image,channel,
2299 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2306 if (LocaleCompare(
"negate",option+1) == 0)
2308 (void) SyncImageSettings(mogrify_info,*image);
2309 (void) NegateImageChannel(*image,channel,*option ==
'+' ?
2310 MagickTrue : MagickFalse);
2311 InheritException(exception,&(*image)->exception);
2314 if (LocaleCompare(
"noise",option+1) == 0)
2316 (void) SyncImageSettings(mogrify_info,*image);
2319 flags=ParseGeometry(argv[i+1],&geometry_info);
2320 if ((flags & SigmaValue) == 0)
2321 geometry_info.sigma=geometry_info.rho;
2322 mogrify_image=StatisticImageChannel(*image,channel,
2323 NonpeakStatistic,(
size_t) geometry_info.rho,(
size_t)
2324 geometry_info.sigma,exception);
2331 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2332 MagickFalse,argv[i+1]);
2333 mogrify_image=AddNoiseImageChannel(*image,channel,noise,
2338 if (LocaleCompare(
"normalize",option+1) == 0)
2340 (void) SyncImageSettings(mogrify_info,*image);
2341 (void) NormalizeImageChannel(*image,channel);
2342 InheritException(exception,&(*image)->exception);
2349 if (LocaleCompare(
"opaque",option+1) == 0)
2354 (void) SyncImageSettings(mogrify_info,*image);
2355 (void) QueryMagickColor(argv[i+1],&target,exception);
2356 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2357 *option ==
'-' ? MagickFalse : MagickTrue);
2360 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2362 (void) SyncImageSettings(mogrify_info,*image);
2363 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2371 if (LocaleCompare(
"paint",option+1) == 0)
2373 (void) SyncImageSettings(mogrify_info,*image);
2374 (void) ParseGeometry(argv[i+1],&geometry_info);
2375 mogrify_image=OilPaintImage(*image,geometry_info.rho,exception);
2378 if (LocaleCompare(
"pen",option+1) == 0)
2382 (void) QueryColorDatabase(
"none",&draw_info->fill,exception);
2385 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2388 if (LocaleCompare(
"perceptible",option+1) == 0)
2393 (void) SyncImageSettings(mogrify_info,*image);
2394 (void) PerceptibleImageChannel(*image,channel,StringToDouble(
2395 argv[i+1],(
char **) NULL));
2396 InheritException(exception,&(*image)->exception);
2399 if (LocaleCompare(
"pointsize",option+1) == 0)
2402 (void) ParseGeometry(
"12",&geometry_info);
2404 (
void) ParseGeometry(argv[i+1],&geometry_info);
2405 draw_info->pointsize=geometry_info.rho;
2408 if (LocaleCompare(
"polaroid",option+1) == 0)
2419 (void) SyncImageSettings(mogrify_info,*image);
2420 random_info=AcquireRandomInfo();
2421 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2422 random_info=DestroyRandomInfo(random_info);
2425 SetGeometryInfo(&geometry_info);
2426 flags=ParseGeometry(argv[i+1],&geometry_info);
2427 angle=geometry_info.rho;
2429 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2432 if (LocaleCompare(
"posterize",option+1) == 0)
2437 (void) SyncImageSettings(mogrify_info,*image);
2438 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2439 quantize_info->dither);
2440 InheritException(exception,&(*image)->exception);
2443 if (LocaleCompare(
"preview",option+1) == 0)
2451 (void) SyncImageSettings(mogrify_info,*image);
2453 preview_type=UndefinedPreview;
2455 preview_type=(PreviewType) ParseCommandOption(
2456 MagickPreviewOptions,MagickFalse,argv[i+1]);
2457 mogrify_image=PreviewImage(*image,preview_type,exception);
2460 if (LocaleCompare(
"profile",option+1) == 0)
2477 (void) SyncImageSettings(mogrify_info,*image);
2483 (void) ProfileImage(*image,argv[i+1],(
const unsigned char *)
2485 InheritException(exception,&(*image)->exception);
2491 profile_info=CloneImageInfo(mogrify_info);
2492 profile=GetImageProfile(*image,
"iptc");
2493 if (profile != (StringInfo *) NULL)
2494 profile_info->profile=(
void *) CloneStringInfo(profile);
2495 sans_exception=AcquireExceptionInfo();
2496 profile_image=GetImageCache(profile_info,argv[i+1],sans_exception);
2497 sans_exception=DestroyExceptionInfo(sans_exception);
2498 profile_info=DestroyImageInfo(profile_info);
2499 if (profile_image == (Image *) NULL)
2504 profile_info=CloneImageInfo(mogrify_info);
2505 (void) CopyMagickString(profile_info->filename,argv[i+1],
2507 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2508 if (profile != (StringInfo *) NULL)
2510 (void) SetImageInfo(profile_info,0,exception);
2511 (void) ProfileImage(*image,profile_info->magick,
2512 GetStringInfoDatum(profile),(size_t)
2513 GetStringInfoLength(profile),MagickFalse);
2514 profile=DestroyStringInfo(profile);
2516 profile_info=DestroyImageInfo(profile_info);
2519 ResetImageProfileIterator(profile_image);
2520 name=GetNextImageProfile(profile_image);
2521 while (name != (
const char *) NULL)
2523 profile=GetImageProfile(profile_image,name);
2524 if (profile != (StringInfo *) NULL)
2525 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2526 (size_t) GetStringInfoLength(profile),MagickFalse);
2527 name=GetNextImageProfile(profile_image);
2529 profile_image=DestroyImage(profile_image);
2536 if (LocaleCompare(
"quantize",option+1) == 0)
2540 quantize_info->colorspace=UndefinedColorspace;
2543 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2544 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2551 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
2552 LocaleCompare(
"rotational-blur",option+1) == 0)
2557 (void) SyncImageSettings(mogrify_info,*image);
2558 mogrify_image=RotationalBlurImageChannel(*image,channel,
2559 StringToDouble(argv[i+1],(
char **) NULL),exception);
2562 if (LocaleCompare(
"raise",option+1) == 0)
2567 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2568 (void) RaiseImage(*image,&geometry,*option ==
'-' ? MagickTrue :
2570 InheritException(exception,&(*image)->exception);
2573 if (LocaleCompare(
"random-threshold",option+1) == 0)
2578 (void) SyncImageSettings(mogrify_info,*image);
2579 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2583 if (LocaleCompare(
"recolor",option+1) == 0)
2588 (void) SyncImageSettings(mogrify_info,*image);
2589 kernel=AcquireKernelInfo(argv[i+1]);
2590 if (kernel == (KernelInfo *) NULL)
2592 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2593 kernel=DestroyKernelInfo(kernel);
2596 if (LocaleCompare(
"region",option+1) == 0)
2598 (void) SyncImageSettings(mogrify_info,*image);
2599 if (region_image != (Image *) NULL)
2604 (void) CompositeImage(region_image,region_image->matte !=
2605 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2606 region_geometry.x,region_geometry.y);
2607 InheritException(exception,®ion_image->exception);
2608 *image=DestroyImage(*image);
2609 *image=region_image;
2610 region_image=(Image *) NULL;
2617 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2619 mogrify_image=CropImage(*image,®ion_geometry,exception);
2620 if (mogrify_image == (Image *) NULL)
2622 region_image=(*image);
2623 *image=mogrify_image;
2624 mogrify_image=(Image *) NULL;
2627 if (LocaleCompare(
"render",option+1) == 0)
2629 (void) SyncImageSettings(mogrify_info,*image);
2630 draw_info->render=(*option ==
'+') ? MagickTrue : MagickFalse;
2633 if (LocaleCompare(
"remap",option+1) == 0)
2641 (void) SyncImageSettings(mogrify_info,*image);
2644 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2645 if (remap_image == (Image *) NULL)
2647 (void) RemapImage(quantize_info,*image,remap_image);
2648 InheritException(exception,&(*image)->exception);
2649 remap_image=DestroyImage(remap_image);
2652 if (LocaleCompare(
"repage",option+1) == 0)
2656 (void) ParseAbsoluteGeometry(
"0x0+0+0",&(*image)->page);
2659 (void) ResetImagePage(*image,argv[i+1]);
2660 InheritException(exception,&(*image)->exception);
2663 if (LocaleCompare(
"resample",option+1) == 0)
2668 (void) SyncImageSettings(mogrify_info,*image);
2669 flags=ParseGeometry(argv[i+1],&geometry_info);
2670 if ((flags & SigmaValue) == 0)
2671 geometry_info.sigma=geometry_info.rho;
2672 mogrify_image=ResampleImage(*image,geometry_info.rho,
2673 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2676 if (LocaleCompare(
"resize",option+1) == 0)
2681 (void) SyncImageSettings(mogrify_info,*image);
2682 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2683 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2684 (*image)->filter,(*image)->blur,exception);
2687 if (LocaleCompare(
"roll",option+1) == 0)
2692 (void) SyncImageSettings(mogrify_info,*image);
2693 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2694 if ((flags & PercentValue) != 0)
2696 geometry.x*=(double) (*image)->columns/100.0;
2697 geometry.y*=(
double) (*image)->rows/100.0;
2699 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2702 if (LocaleCompare(
"rotate",option+1) == 0)
2710 (void) SyncImageSettings(mogrify_info,*image);
2711 if (strchr(argv[i+1],
'>') != (
char *) NULL)
2712 if ((*image)->columns <= (*image)->rows)
2714 if (strchr(argv[i+1],
'<') != (
char *) NULL)
2715 if ((*image)->columns >= (*image)->rows)
2720 geometry=ConstantString(argv[i+1]);
2721 (void) SubstituteString(&geometry,
">",
"");
2722 (void) SubstituteString(&geometry,
"<",
"");
2723 (void) ParseGeometry(geometry,&geometry_info);
2724 geometry=DestroyString(geometry);
2725 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2732 if (LocaleCompare(
"sample",option+1) == 0)
2737 (void) SyncImageSettings(mogrify_info,*image);
2738 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2739 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2743 if (LocaleCompare(
"scale",option+1) == 0)
2748 (void) SyncImageSettings(mogrify_info,*image);
2749 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2750 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2754 if (LocaleCompare(
"selective-blur",option+1) == 0)
2759 (void) SyncImageSettings(mogrify_info,*image);
2760 flags=ParseGeometry(argv[i+1],&geometry_info);
2761 if ((flags & PercentValue) != 0)
2762 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2763 mogrify_image=SelectiveBlurImageChannel(*image,channel,
2764 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2767 if (LocaleCompare(
"separate",option+1) == 0)
2773 (void) SyncImageSettings(mogrify_info,*image);
2774 mogrify_image=SeparateImages(*image,channel,exception);
2777 if (LocaleCompare(
"sepia-tone",option+1) == 0)
2785 (void) SyncImageSettings(mogrify_info,*image);
2786 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2788 mogrify_image=SepiaToneImage(*image,threshold,exception);
2791 if (LocaleCompare(
"segment",option+1) == 0)
2796 (void) SyncImageSettings(mogrify_info,*image);
2797 flags=ParseGeometry(argv[i+1],&geometry_info);
2798 if ((flags & SigmaValue) == 0)
2799 geometry_info.sigma=1.0;
2800 (void) SegmentImage(*image,(*image)->colorspace,
2801 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2802 InheritException(exception,&(*image)->exception);
2805 if (LocaleCompare(
"set",option+1) == 0)
2815 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2816 (void) DeleteImageRegistry(argv[i+1]+9);
2818 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2820 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2821 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2824 (
void) DeleteImageProperty(*image,argv[i+1]);
2827 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2828 InheritException(exception,&(*image)->exception);
2829 if (value == (
char *) NULL)
2831 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2832 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2835 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2837 (void) SetImageOption(image_info,argv[i+1]+7,value);
2838 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2839 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2842 if (LocaleCompare(argv[i+1],
"profile") == 0)
2845 *profile = (StringInfo *) NULL;
2847 (void) CopyMagickString(image_info->filename,value,
2849 (void) SetImageInfo(image_info,1,exception);
2850 if (LocaleCompare(image_info->filename,
"-") != 0)
2851 profile=FileToStringInfo(image_info->filename,~0UL,
2853 if (profile != (StringInfo *) NULL)
2855 status=SetImageProfile(*image,image_info->magick,
2857 profile=DestroyStringInfo(profile);
2861 (
void) SetImageProperty(*image,argv[i+1],value);
2862 value=DestroyString(value);
2865 if (LocaleCompare(
"shade",option+1) == 0)
2870 (void) SyncImageSettings(mogrify_info,*image);
2871 flags=ParseGeometry(argv[i+1],&geometry_info);
2872 if ((flags & SigmaValue) == 0)
2873 geometry_info.sigma=1.0;
2874 mogrify_image=ShadeImage(*image,(*option ==
'-') ? MagickTrue :
2875 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2878 if (LocaleCompare(
"shadow",option+1) == 0)
2883 (void) SyncImageSettings(mogrify_info,*image);
2884 flags=ParseGeometry(argv[i+1],&geometry_info);
2885 if ((flags & SigmaValue) == 0)
2886 geometry_info.sigma=1.0;
2887 if ((flags & XiValue) == 0)
2888 geometry_info.xi=4.0;
2889 if ((flags & PsiValue) == 0)
2890 geometry_info.psi=4.0;
2891 mogrify_image=ShadowImage(*image,geometry_info.rho,
2892 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2893 ceil(geometry_info.psi-0.5),exception);
2896 if (LocaleCompare(
"sharpen",option+1) == 0)
2901 (void) SyncImageSettings(mogrify_info,*image);
2902 flags=ParseGeometry(argv[i+1],&geometry_info);
2903 if ((flags & SigmaValue) == 0)
2904 geometry_info.sigma=1.0;
2905 mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2906 geometry_info.sigma,exception);
2909 if (LocaleCompare(
"shave",option+1) == 0)
2914 (void) SyncImageSettings(mogrify_info,*image);
2915 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2916 mogrify_image=ShaveImage(*image,&geometry,exception);
2919 if (LocaleCompare(
"shear",option+1) == 0)
2924 (void) SyncImageSettings(mogrify_info,*image);
2925 flags=ParseGeometry(argv[i+1],&geometry_info);
2926 if ((flags & SigmaValue) == 0)
2927 geometry_info.sigma=geometry_info.rho;
2928 mogrify_image=ShearImage(*image,geometry_info.rho,
2929 geometry_info.sigma,exception);
2932 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
2937 (void) SyncImageSettings(mogrify_info,*image);
2938 flags=ParseGeometry(argv[i+1],&geometry_info);
2939 if ((flags & SigmaValue) == 0)
2940 geometry_info.sigma=(double) QuantumRange/2.0;
2941 if ((flags & PercentValue) != 0)
2942 geometry_info.sigma=(
double) QuantumRange*geometry_info.sigma/
2944 (void) SigmoidalContrastImageChannel(*image,channel,
2945 (*option ==
'-') ? MagickTrue : MagickFalse,geometry_info.rho,
2946 geometry_info.sigma);
2947 InheritException(exception,&(*image)->exception);
2950 if (LocaleCompare(
"sketch",option+1) == 0)
2955 (void) SyncImageSettings(mogrify_info,*image);
2956 flags=ParseGeometry(argv[i+1],&geometry_info);
2957 if ((flags & SigmaValue) == 0)
2958 geometry_info.sigma=1.0;
2959 mogrify_image=SketchImage(*image,geometry_info.rho,
2960 geometry_info.sigma,geometry_info.xi,exception);
2963 if (LocaleCompare(
"solarize",option+1) == 0)
2968 (void) SyncImageSettings(mogrify_info,*image);
2969 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2971 (void) SolarizeImageChannel(*image,channel,threshold,exception);
2974 if (LocaleCompare(
"sparse-color",option+1) == 0)
2985 (void) SyncImageSettings(mogrify_info,*image);
2986 method=(SparseColorMethod) ParseCommandOption(
2987 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2988 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2989 InheritException(exception,&(*image)->exception);
2990 if (arguments == (
char *) NULL)
2992 mogrify_image=SparseColorOption(*image,channel,method,arguments,
2993 option[0] ==
'+' ? MagickTrue : MagickFalse,exception);
2994 arguments=DestroyString(arguments);
2997 if (LocaleCompare(
"splice",option+1) == 0)
3002 (void) SyncImageSettings(mogrify_info,*image);
3003 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
3004 mogrify_image=SpliceImage(*image,&geometry,exception);
3007 if (LocaleCompare(
"spread",option+1) == 0)
3012 (void) SyncImageSettings(mogrify_info,*image);
3013 (void) ParseGeometry(argv[i+1],&geometry_info);
3014 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
3017 if (LocaleCompare(
"statistic",option+1) == 0)
3022 (void) SyncImageSettings(mogrify_info,*image);
3023 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
3024 MagickFalse,argv[i+1]);
3025 (void) ParseGeometry(argv[i+2],&geometry_info);
3026 mogrify_image=StatisticImageChannel(*image,channel,type,(
size_t)
3027 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
3030 if (LocaleCompare(
"stretch",option+1) == 0)
3034 draw_info->stretch=UndefinedStretch;
3037 draw_info->stretch=(StretchType) ParseCommandOption(
3038 MagickStretchOptions,MagickFalse,argv[i+1]);
3041 if (LocaleCompare(
"strip",option+1) == 0)
3046 (void) SyncImageSettings(mogrify_info,*image);
3047 (void) StripImage(*image);
3048 InheritException(exception,&(*image)->exception);
3051 if (LocaleCompare(
"stroke",option+1) == 0)
3058 (void) QueryColorDatabase(
"none",&draw_info->stroke,exception);
3059 if (draw_info->stroke_pattern != (Image *) NULL)
3060 draw_info->stroke_pattern=DestroyImage(
3061 draw_info->stroke_pattern);
3064 sans=AcquireExceptionInfo();
3065 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3066 sans=DestroyExceptionInfo(sans);
3067 if (status == MagickFalse)
3068 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3072 if (LocaleCompare(
"strokewidth",option+1) == 0)
3074 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
3077 if (LocaleCompare(
"style",option+1) == 0)
3081 draw_info->style=UndefinedStyle;
3084 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3085 MagickFalse,argv[i+1]);
3088 if (LocaleCompare(
"swirl",option+1) == 0)
3093 (void) SyncImageSettings(mogrify_info,*image);
3094 (void) ParseGeometry(argv[i+1],&geometry_info);
3095 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
3102 if (LocaleCompare(
"threshold",option+1) == 0)
3110 (void) SyncImageSettings(mogrify_info,*image);
3112 threshold=(double) QuantumRange/2;
3114 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
3116 (void) BilevelImageChannel(*image,channel,threshold);
3117 InheritException(exception,&(*image)->exception);
3120 if (LocaleCompare(
"thumbnail",option+1) == 0)
3125 (void) SyncImageSettings(mogrify_info,*image);
3126 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3127 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3131 if (LocaleCompare(
"tile",option+1) == 0)
3135 if (draw_info->fill_pattern != (Image *) NULL)
3136 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3139 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3143 if (LocaleCompare(
"tint",option+1) == 0)
3148 (void) SyncImageSettings(mogrify_info,*image);
3149 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3152 if (LocaleCompare(
"transform",option+1) == 0)
3157 (void) SyncImageSettings(mogrify_info,*image);
3158 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3162 if (LocaleCompare(
"transparent",option+1) == 0)
3167 (void) SyncImageSettings(mogrify_info,*image);
3168 (void) QueryMagickColor(argv[i+1],&target,exception);
3169 (void) TransparentPaintImage(*image,&target,(Quantum)
3170 TransparentOpacity,*option ==
'-' ? MagickFalse : MagickTrue);
3171 InheritException(exception,&(*image)->exception);
3174 if (LocaleCompare(
"transpose",option+1) == 0)
3179 (void) SyncImageSettings(mogrify_info,*image);
3180 mogrify_image=TransposeImage(*image,exception);
3183 if (LocaleCompare(
"transverse",option+1) == 0)
3188 (void) SyncImageSettings(mogrify_info,*image);
3189 mogrify_image=TransverseImage(*image,exception);
3192 if (LocaleCompare(
"treedepth",option+1) == 0)
3194 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3197 if (LocaleCompare(
"trim",option+1) == 0)
3202 (void) SyncImageSettings(mogrify_info,*image);
3203 mogrify_image=TrimImage(*image,exception);
3206 if (LocaleCompare(
"type",option+1) == 0)
3211 (void) SyncImageSettings(mogrify_info,*image);
3215 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3217 (*image)->type=UndefinedType;
3218 (void) SetImageType(*image,type);
3219 InheritException(exception,&(*image)->exception);
3226 if (LocaleCompare(
"undercolor",option+1) == 0)
3228 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3232 if (LocaleCompare(
"unique",option+1) == 0)
3236 (void) DeleteImageArtifact(*image,
"identify:unique-colors");
3239 (void) SetImageArtifact(*image,
"identify:unique-colors",
"true");
3240 (void) SetImageArtifact(*image,
"verbose",
"true");
3243 if (LocaleCompare(
"unique-colors",option+1) == 0)
3248 (void) SyncImageSettings(mogrify_info,*image);
3249 mogrify_image=UniqueImageColors(*image,exception);
3252 if (LocaleCompare(
"unsharp",option+1) == 0)
3257 (void) SyncImageSettings(mogrify_info,*image);
3258 flags=ParseGeometry(argv[i+1],&geometry_info);
3259 if ((flags & SigmaValue) == 0)
3260 geometry_info.sigma=1.0;
3261 if ((flags & XiValue) == 0)
3262 geometry_info.xi=1.0;
3263 if ((flags & PsiValue) == 0)
3264 geometry_info.psi=0.05;
3265 mogrify_image=UnsharpMaskImageChannel(*image,channel,
3266 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3267 geometry_info.psi,exception);
3274 if (LocaleCompare(
"verbose",option+1) == 0)
3276 (void) SetImageArtifact(*image,option+1,
3277 *option ==
'+' ?
"false" :
"true");
3280 if (LocaleCompare(
"vignette",option+1) == 0)
3285 (void) SyncImageSettings(mogrify_info,*image);
3286 flags=ParseGeometry(argv[i+1],&geometry_info);
3287 if ((flags & SigmaValue) == 0)
3288 geometry_info.sigma=1.0;
3289 if ((flags & XiValue) == 0)
3290 geometry_info.xi=0.1*(*image)->columns;
3291 if ((flags & PsiValue) == 0)
3292 geometry_info.psi=0.1*(*image)->rows;
3293 if ((flags & PercentValue) != 0)
3295 geometry_info.xi*=(double) (*image)->columns/100.0;
3296 geometry_info.psi*=(
double) (*image)->rows/100.0;
3298 mogrify_image=VignetteImage(*image,geometry_info.rho,
3299 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3300 ceil(geometry_info.psi-0.5),exception);
3303 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
3307 (void) SetImageVirtualPixelMethod(*image,
3308 UndefinedVirtualPixelMethod);
3311 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3312 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3320 if (LocaleCompare(
"wave",option+1) == 0)
3325 (void) SyncImageSettings(mogrify_info,*image);
3326 flags=ParseGeometry(argv[i+1],&geometry_info);
3327 if ((flags & SigmaValue) == 0)
3328 geometry_info.sigma=1.0;
3329 mogrify_image=WaveImage(*image,geometry_info.rho,
3330 geometry_info.sigma,exception);
3333 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3338 (void) SyncImageSettings(mogrify_info,*image);
3339 flags=ParseGeometry(argv[i+1],&geometry_info);
3340 if ((flags & PercentValue) != 0)
3342 geometry_info.rho=(double) QuantumRange*geometry_info.rho/100.0;
3343 geometry_info.sigma=(
double) QuantumRange*geometry_info.sigma/
3346 if ((flags & SigmaValue) == 0)
3347 geometry_info.sigma=0.0;
3348 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3349 geometry_info.sigma,exception);
3352 if (LocaleCompare(
"weight",option+1) == 0)
3357 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3360 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3361 draw_info->weight=(size_t) weight;
3364 if (LocaleCompare(
"white-threshold",option+1) == 0)
3369 (void) SyncImageSettings(mogrify_info,*image);
3370 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3372 InheritException(exception,&(*image)->exception);
3383 if (mogrify_image != (Image *) NULL)
3384 ReplaceImageInListReturnLast(image,mogrify_image);
3387 if (region_image != (Image *) NULL)
3392 (void) SyncImageSettings(mogrify_info,*image);
3393 (void) CompositeImage(region_image,region_image->matte != MagickFalse ?
3394 CopyCompositeOp : OverCompositeOp,*image,region_geometry.x,
3396 InheritException(exception,®ion_image->exception);
3397 *image=DestroyImage(*image);
3398 *image=region_image;
3399 region_image = (Image *) NULL;
3404 quantize_info=DestroyQuantizeInfo(quantize_info);
3405 draw_info=DestroyDrawInfo(draw_info);
3406 mogrify_info=DestroyImageInfo(mogrify_info);
3407 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3408 return(status == 0 ? MagickFalse : MagickTrue);
3445static MagickBooleanType MogrifyUsage(
void)
3449 " -debug events display copious debugging information\n"
3450 " -distribute-cache port\n"
3451 " distributed pixel cache spanning one or more servers\n"
3452 " -help print program options\n"
3453 " -list type print a list of supported option arguments\n"
3454 " -log format format of debugging information\n"
3455 " -version print version information",
3457 " -adaptive-blur geometry\n"
3458 " adaptively blur pixels; decrease effect near edges\n"
3459 " -adaptive-resize geometry\n"
3460 " adaptively resize image using 'mesh' interpolation\n"
3461 " -adaptive-sharpen geometry\n"
3462 " adaptively sharpen pixels; increase effect near edges\n"
3463 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3464 " transparent, extract, background, or shape\n"
3465 " -annotate geometry text\n"
3466 " annotate the image with text\n"
3467 " -auto-gamma automagically adjust gamma level of image\n"
3468 " -auto-level automagically adjust color levels of image\n"
3469 " -auto-orient automagically orient (rotate) image\n"
3470 " -bench iterations measure performance\n"
3471 " -black-threshold value\n"
3472 " force all pixels below the threshold into black\n"
3473 " -blue-shift simulate a scene at nighttime in the moonlight\n"
3474 " -blur geometry reduce image noise and reduce detail levels\n"
3475 " -border geometry surround image with a border of color\n"
3476 " -bordercolor color border color\n"
3477 " -brightness-contrast geometry\n"
3478 " improve brightness / contrast of the image\n"
3479 " -canny geometry detect edges in the image\n"
3480 " -cdl filename color correct with a color decision list\n"
3481 " -charcoal radius simulate a charcoal drawing\n"
3482 " -chop geometry remove pixels from the image interior\n"
3483 " -clamp keep pixel values in range (0-QuantumRange)\n"
3484 " -clip clip along the first path from the 8BIM profile\n"
3485 " -clip-mask filename associate a clip mask with the image\n"
3486 " -clip-path id clip along a named path from the 8BIM profile\n"
3487 " -colorize value colorize the image with the fill color\n"
3488 " -color-matrix matrix apply color correction to the image\n"
3489 " -connected-components connectivity\n"
3490 " connected-components uniquely labeled\n"
3491 " -contrast enhance or reduce the image contrast\n"
3492 " -contrast-stretch geometry\n"
3493 " improve contrast by `stretching' the intensity range\n"
3494 " -convolve coefficients\n"
3495 " apply a convolution kernel to the image\n"
3496 " -cycle amount cycle the image colormap\n"
3497 " -decipher filename convert cipher pixels to plain pixels\n"
3498 " -deskew threshold straighten an image\n"
3499 " -despeckle reduce the speckles within an image\n"
3500 " -distort method args\n"
3501 " distort images according to given method ad args\n"
3502 " -draw string annotate the image with a graphic primitive\n"
3503 " -edge radius apply a filter to detect edges in the image\n"
3504 " -encipher filename convert plain pixels to cipher pixels\n"
3505 " -emboss radius emboss an image\n"
3506 " -enhance apply a digital filter to enhance a noisy image\n"
3507 " -equalize perform histogram equalization to an image\n"
3508 " -evaluate operator value\n"
3509 " evaluate an arithmetic, relational, or logical expression\n"
3510 " -extent geometry set the image size\n"
3511 " -extract geometry extract area from image\n"
3512 " -hough-lines geometry\n"
3513 " identify lines in the image\n"
3514 " -features distance analyze image features (e.g. contrast, correlation)\n"
3515 " -fft implements the discrete Fourier transform (DFT)\n"
3516 " -flip flip image vertically\n"
3517 " -floodfill geometry color\n"
3518 " floodfill the image with color\n"
3519 " -flop flop image horizontally\n"
3520 " -frame geometry surround image with an ornamental border\n"
3521 " -function name parameters\n"
3522 " apply function over image values\n"
3523 " -gamma value level of gamma correction\n"
3524 " -gaussian-blur geometry\n"
3525 " reduce image noise and reduce detail levels\n"
3526 " -geometry geometry preferred size or location of the image\n"
3527 " -grayscale method convert image to grayscale\n"
3528 " -help print program options\n"
3529 " -identify identify the format and characteristics of the image\n"
3530 " -ift implements the inverse discrete Fourier transform (DFT)\n"
3531 " -implode amount implode image pixels about the center\n"
3532 " -kuwahara geometry edge preserving noise reduction filter\n"
3533 " -lat geometry local adaptive thresholding\n"
3534 " -layers method optimize, merge, or compare image layers\n"
3535 " -level value adjust the level of image contrast\n"
3536 " -level-colors color,color\n"
3537 " level image with the given colors\n"
3538 " -linear-stretch geometry\n"
3539 " improve contrast by `stretching with saturation'\n"
3540 " -liquid-rescale geometry\n"
3541 " rescale image with seam-carving\n"
3542 " -local-contrast geometry\n"
3543 " enhance local contrast\n"
3544 " -magnify double the size of the image with pixel art scaling\n"
3545 " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3546 " -median geometry apply a median filter to the image\n"
3547 " -mode geometry make each pixel the 'predominant color' of the\n"
3549 " -modulate value vary the brightness, saturation, and hue\n"
3550 " -monochrome transform image to black and white\n"
3551 " -morphology method kernel\n"
3552 " apply a morphology method to the image\n"
3553 " -motion-blur geometry\n"
3554 " simulate motion blur\n"
3555 " -negate replace every pixel with its complementary color \n"
3556 " -noise geometry add or reduce noise in an image\n"
3557 " -normalize transform image to span the full range of colors\n"
3558 " -opaque color change this color to the fill color\n"
3559 " -ordered-dither NxN\n"
3560 " add a noise pattern to the image with specific\n"
3562 " -paint radius simulate an oil painting\n"
3563 " -perceptible epsilon\n"
3564 " pixel value less than |epsilon| become epsilon or\n"
3566 " -polaroid angle simulate a Polaroid picture\n"
3567 " -posterize levels reduce the image to a limited number of color levels\n"
3568 " -profile filename add, delete, or apply an image profile\n"
3569 " -quantize colorspace reduce colors in this colorspace\n"
3570 " -radial-blur angle radial blur the image\n"
3571 " -raise value lighten/darken image edges to create a 3-D effect\n"
3572 " -random-threshold low,high\n"
3573 " random threshold the image\n"
3574 " -region geometry apply options to a portion of the image\n"
3575 " -render render vector graphics\n"
3576 " -resample geometry change the resolution of an image\n"
3577 " -resize geometry resize the image\n"
3578 " -roll geometry roll an image vertically or horizontally\n"
3579 " -rotate degrees apply Paeth rotation to the image\n"
3580 " -sample geometry scale image with pixel sampling\n"
3581 " -scale geometry scale the image\n"
3582 " -segment values segment an image\n"
3583 " -selective-blur geometry\n"
3584 " selectively blur pixels within a contrast threshold\n"
3585 " -sepia-tone threshold\n"
3586 " simulate a sepia-toned photo\n"
3587 " -set property value set an image property\n"
3588 " -shade degrees shade the image using a distant light source\n"
3589 " -shadow geometry simulate an image shadow\n"
3590 " -sharpen geometry sharpen the image\n"
3591 " -shave geometry shave pixels from the image edges\n"
3592 " -shear geometry slide one edge of the image along the X or Y axis\n"
3593 " -sigmoidal-contrast geometry\n"
3594 " increase the contrast without saturating highlights or\n"
3596 " -sketch geometry simulate a pencil sketch\n"
3597 " -solarize threshold negate all pixels above the threshold level\n"
3598 " -sparse-color method args\n"
3599 " fill in a image based on a few color points\n"
3600 " -splice geometry splice the background color into the image\n"
3601 " -spread radius displace image pixels by a random amount\n"
3602 " -statistic type radius\n"
3603 " replace each pixel with corresponding statistic from the neighborhood\n"
3604 " -strip strip image of all profiles and comments\n"
3605 " -swirl degrees swirl image pixels about the center\n"
3606 " -threshold value threshold the image\n"
3607 " -thumbnail geometry create a thumbnail of the image\n"
3608 " -tile filename tile image when filling a graphic primitive\n"
3609 " -tint value tint the image with the fill color\n"
3610 " -transform affine transform image\n"
3611 " -transparent color make this color transparent within the image\n"
3612 " -transpose flip image vertically and rotate 90 degrees\n"
3613 " -transverse flop image horizontally and rotate 270 degrees\n"
3614 " -trim trim image edges\n"
3615 " -type type image type\n"
3616 " -unique-colors discard all but one of any pixel color\n"
3617 " -unsharp geometry sharpen the image\n"
3618 " -vignette geometry soften the edges of the image in vignette style\n"
3619 " -wave geometry alter an image along a sine wave\n"
3620 " -wavelet-denoise threshold\n"
3621 " removes noise from the image using a wavelet transform\n"
3622 " -white-threshold value\n"
3623 " force all pixels above the threshold into white",
3624 sequence_operators[] =
3625 " -affinity filename transform image colors to match this set of colors\n"
3626 " -append append an image sequence\n"
3627 " -clut apply a color lookup table to the image\n"
3628 " -coalesce merge a sequence of images\n"
3629 " -combine combine a sequence of images\n"
3630 " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3631 " -complex operator perform complex mathematics on an image sequence\n"
3632 " -composite composite image\n"
3633 " -copy geometry offset\n"
3634 " copy pixels from one area of an image to another\n"
3635 " -crop geometry cut out a rectangular region of the image\n"
3636 " -deconstruct break down an image sequence into constituent parts\n"
3637 " -evaluate-sequence operator\n"
3638 " evaluate an arithmetic, relational, or logical expression\n"
3639 " -flatten flatten a sequence of images\n"
3640 " -fx expression apply mathematical expression to an image channel(s)\n"
3641 " -hald-clut apply a Hald color lookup table to the image\n"
3642 " -layers method optimize, merge, or compare image layers\n"
3643 " -morph value morph an image sequence\n"
3644 " -mosaic create a mosaic from an image sequence\n"
3645 " -poly terms build a polynomial from the image sequence and the corresponding\n"
3646 " terms (coefficients and degree pairs).\n"
3647 " -print string interpret string and print to console\n"
3648 " -process arguments process the image with a custom image filter\n"
3649 " -separate separate an image channel into a grayscale image\n"
3650 " -smush geometry smush an image sequence together\n"
3651 " -write filename write images to this file",
3653 " -adjoin join images into a single multi-image file\n"
3654 " -affine matrix affine transform matrix\n"
3655 " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3656 " -antialias remove pixel-aliasing\n"
3657 " -authenticate password\n"
3658 " decipher image with this password\n"
3659 " -attenuate value lessen (or intensify) when adding noise to an image\n"
3660 " -background color background color\n"
3661 " -bias value add bias when convolving an image\n"
3662 " -black-point-compensation\n"
3663 " use black point compensation\n"
3664 " -blue-primary point chromaticity blue primary point\n"
3665 " -bordercolor color border color\n"
3666 " -caption string assign a caption to an image\n"
3667 " -cdl filename color correct with a color decision list\n"
3668 " -channel type apply option to select image channels\n"
3669 " -colors value preferred number of colors in the image\n"
3670 " -colorspace type alternate image colorspace\n"
3671 " -comment string annotate image with comment\n"
3672 " -compose operator set image composite operator\n"
3673 " -compress type type of pixel compression when writing the image\n"
3674 " -decipher filename convert cipher pixels to plain pixels\n"
3675 " -define format:option\n"
3676 " define one or more image format options\n"
3677 " -delay value display the next image after pausing\n"
3678 " -density geometry horizontal and vertical density of the image\n"
3679 " -depth value image depth\n"
3680 " -direction type render text right-to-left or left-to-right\n"
3681 " -display server get image or font from this X server\n"
3682 " -dispose method layer disposal method\n"
3683 " -dither method apply error diffusion to image\n"
3684 " -encipher filename convert plain pixels to cipher pixels\n"
3685 " -encoding type text encoding type\n"
3686 " -endian type endianness (MSB or LSB) of the image\n"
3687 " -family name render text with this font family\n"
3688 " -features distance analyze image features (e.g. contrast, correlation)\n"
3689 " -fill color color to use when filling a graphic primitive\n"
3690 " -filter type use this filter when resizing an image\n"
3691 " -flatten flatten a sequence of images\n"
3692 " -font name render text with this font\n"
3693 " -format \"string\" output formatted image characteristics\n"
3694 " -function name apply a function to the image\n"
3695 " -fuzz distance colors within this distance are considered equal\n"
3696 " -gravity type horizontal and vertical text placement\n"
3697 " -green-primary point chromaticity green primary point\n"
3698 " -intensity method method to generate intensity value from pixel\n"
3699 " -intent type type of rendering intent when managing the image color\n"
3700 " -interlace type type of image interlacing scheme\n"
3701 " -interline-spacing value\n"
3702 " set the space between two text lines\n"
3703 " -interpolate method pixel color interpolation method\n"
3704 " -interword-spacing value\n"
3705 " set the space between two words\n"
3706 " -kerning value set the space between two letters\n"
3707 " -label string assign a label to an image\n"
3708 " -limit type value pixel cache resource limit\n"
3709 " -loop iterations add Netscape loop extension to your GIF animation\n"
3710 " -mask filename associate a mask with the image\n"
3711 " -matte store matte channel if the image has one\n"
3712 " -mattecolor color frame color\n"
3713 " -monitor monitor progress\n"
3714 " -morphology method kernel\n"
3715 " apply a morphology method to the image\n"
3716 " -orient type image orientation\n"
3717 " -page geometry size and location of an image canvas (setting)\n"
3718 " -path path write images to this path on disk\n"
3719 " -ping efficiently determine image attributes\n"
3720 " -pointsize value font point size\n"
3721 " -precision value maximum number of significant digits to print\n"
3722 " -preview type image preview type\n"
3723 " -quality value JPEG/MIFF/PNG compression level\n"
3724 " -quiet suppress all warning messages\n"
3725 " -red-primary point chromaticity red primary point\n"
3726 " -regard-warnings pay attention to warning messages\n"
3727 " -remap filename transform image colors to match this set of colors\n"
3728 " -repage geometry size and location of an image canvas\n"
3729 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3730 " -sampling-factor geometry\n"
3731 " horizontal and vertical sampling factor\n"
3732 " -scene value image scene number\n"
3733 " -seed value seed a new sequence of pseudo-random numbers\n"
3734 " -size geometry width and height of image\n"
3735 " -stretch type render text with this font stretch\n"
3736 " -stroke color graphic primitive stroke color\n"
3737 " -strokewidth value graphic primitive stroke width\n"
3738 " -style type render text with this font style\n"
3739 " -synchronize synchronize image to storage device\n"
3740 " -taint declare the image as modified\n"
3741 " -texture filename name of texture to tile onto the image background\n"
3742 " -tile-offset geometry\n"
3744 " -treedepth value color tree depth\n"
3745 " -transparent-color color\n"
3746 " transparent color\n"
3747 " -undercolor color annotation bounding box color\n"
3748 " -units type the units of image resolution\n"
3749 " -verbose print detailed information about the image\n"
3750 " -view FlashPix viewing transforms\n"
3751 " -virtual-pixel method\n"
3752 " virtual pixel access method\n"
3753 " -weight type render text with this font weight\n"
3754 " -white-point point chromaticity white point",
3756 " -delete indexes delete the image from the image sequence\n"
3757 " -duplicate count,indexes\n"
3758 " duplicate an image one or more times\n"
3759 " -insert index insert last image into the image sequence\n"
3760 " -reverse reverse image sequence\n"
3761 " -swap indexes swap two images in the image sequence";
3763 ListMagickVersion(stdout);
3764 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
3766 (void) fprintf(stdout,
"\nImage Settings:\n");
3767 (void) fputs(settings,stdout);
3768 (void) fprintf(stdout,
"\nImage Operators:\n");
3769 (void) fputs(operators,stdout);
3770 (void) fprintf(stdout,
"\nImage Sequence Operators:\n");
3771 (void) fputs(sequence_operators,stdout);
3772 (void) fprintf(stdout,
"\nImage Stack Operators:\n");
3773 (void) fputs(stack_operators,stdout);
3774 (void) fprintf(stdout,
"\nMiscellaneous Options:\n");
3775 (void) fputs(miscellaneous,stdout);
3776 (void) fprintf(stdout,
3777 "\nBy default, the image format of `file' is determined by its magic\n");
3778 (void) fprintf(stdout,
3779 "number. To specify a particular image format, precede the filename\n");
3780 (void) fprintf(stdout,
3781 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3782 (void) fprintf(stdout,
3783 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3784 (void) fprintf(stdout,
"'-' for standard input or output.\n");
3788WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3789 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
3791#define DestroyMogrify() \
3793 if (format != (char *) NULL) \
3794 format=DestroyString(format); \
3795 if (path != (char *) NULL) \
3796 path=DestroyString(path); \
3797 DestroyImageStack(); \
3798 for (i=0; i < (ssize_t) argc; i++) \
3799 argv[i]=DestroyString(argv[i]); \
3800 argv=(char **) RelinquishMagickMemory(argv); \
3802#define ThrowMogrifyException(asperity,tag,option) \
3804 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3807 return(MagickFalse); \
3809#define ThrowMogrifyInvalidArgumentException(option,argument) \
3811 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3812 "InvalidArgument","`%s': %s",argument,option); \
3814 return(MagickFalse); \
3826 image_stack[MaxImageStackDepth+1];
3834 respect_parenthesis;
3846 wand_unreferenced(metadata);
3851 assert(image_info != (ImageInfo *) NULL);
3852 assert(image_info->signature == MagickCoreSignature);
3853 assert(exception != (ExceptionInfo *) NULL);
3854 if (IsEventLogging() != MagickFalse)
3855 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3859 if ((LocaleCompare(
"version",option+1) == 0) ||
3860 (LocaleCompare(
"-version",option+1) == 0))
3862 ListMagickVersion(stdout);
3868 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3869 "MissingArgument",
"%s",
"");
3870 (void) MogrifyUsage();
3871 return(MagickFalse);
3873 format=(
char *) NULL;
3875 global_colormap=MagickFalse;
3879 option=(
char *) NULL;
3881 respect_parenthesis=MagickFalse;
3886 ReadCommandlLine(argc,&argv);
3887 status=ExpandFilenames(&argc,&argv);
3888 if (status == MagickFalse)
3889 ThrowMogrifyException(ResourceLimitError,
"MemoryAllocationFailed",
3890 GetExceptionMessage(errno));
3891 for (i=1; i < (ssize_t) argc; i++)
3894 if (LocaleCompare(option,
"(") == 0)
3896 FireImageStack(MagickFalse,MagickTrue,pend);
3897 if (k == MaxImageStackDepth)
3898 ThrowMogrifyException(OptionError,
"ParenthesisNestedTooDeeply",
3903 if (LocaleCompare(option,
")") == 0)
3905 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3907 ThrowMogrifyException(OptionError,
"UnableToParseExpression",option);
3911 if (IsCommandOption(option) == MagickFalse)
3914 backup_filename[MaxTextExtent],
3916 magic[MagickPathExtent];
3927 FireImageStack(MagickFalse,MagickFalse,pend);
3929 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
3931 (void) SetImageOption(image_info,
"filename",filename);
3932 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3933 images=ReadImages(image_info,exception);
3934 status&=(images != (Image *) NULL) &&
3935 (exception->severity < ErrorException);
3936 if (images == (Image *) NULL)
3938 properties=(*GetBlobProperties(images));
3939 if (format != (
char *) NULL)
3940 GetPathComponent(images->magick_filename,BasePathSansCompressExtension,
3942 if (path != (
char *) NULL)
3944 GetPathComponent(option,TailPath,filename);
3945 (void) FormatLocaleString(images->filename,MaxTextExtent,
"%s%c%s",
3946 path,*DirectorySeparator,filename);
3948 if (format != (
char *) NULL)
3949 AppendImageFormat(format,images->filename);
3950 AppendImageStack(images);
3951 FinalizeImageSettings(image_info,image,MagickFalse);
3952 if (image == (Image *) NULL)
3954 if (global_colormap != MagickFalse)
3959 quantize_info=AcquireQuantizeInfo(image_info);
3960 (void) RemapImages(quantize_info,images,(Image *) NULL);
3961 quantize_info=DestroyQuantizeInfo(quantize_info);
3963 *backup_filename=
'\0';
3965 GetPathComponent(filename,MagickPath,magic);
3969 filename[MagickPathExtent];
3971 if (format != (
char *) NULL)
3972 (void) CopyMagickString(magic,format,MagickPathExtent);
3973 (void) FormatLocaleString(filename,MagickPathExtent,
"%s:%s",magic,
3975 (void) CopyMagickString(image->filename,filename,MagickPathExtent);
3977 if ((LocaleCompare(image->filename,
"-") != 0) &&
3978 (IsPathWritable(image->filename) != MagickFalse))
3986 (void) CopyMagickString(backup_filename,image->filename,
3988 for (i=0; i < 6; i++)
3990 (void) ConcatenateMagickString(backup_filename,
"~",MaxTextExtent);
3991 if (IsPathAccessible(backup_filename) == MagickFalse)
3994 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3995 (rename_utf8(image->filename,backup_filename) != 0))
3996 *backup_filename=
'\0';
4001 image_info->synchronize=MagickTrue;
4002 status&=WriteImages(image_info,image,image->filename,exception);
4003 if (status != MagickFalse)
4005#if defined(MAGICKCORE_HAVE_UTIME)
4010 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
4011 "preserve-timestamp"));
4012 if (preserve_timestamp != MagickFalse)
4017 timestamp.actime=properties.st_atime;
4018 timestamp.modtime=properties.st_mtime;
4019 (void) utime(image->filename,×tamp);
4023 if (*backup_filename !=
'\0')
4024 (void) remove_utf8(backup_filename);
4027 if (*backup_filename !=
'\0')
4028 (void) rename_utf8(backup_filename,image->filename);
4029 RemoveAllImageStack();
4032 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4033 switch (*(option+1))
4037 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
4040 if (i == (ssize_t) argc)
4041 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4042 if (IsGeometry(argv[i]) == MagickFalse)
4043 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4046 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
4049 if (i == (ssize_t) argc)
4050 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4051 if (IsGeometry(argv[i]) == MagickFalse)
4052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4055 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
4058 if (i == (ssize_t) argc)
4059 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4060 if (IsGeometry(argv[i]) == MagickFalse)
4061 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4064 if (LocaleCompare(
"affine",option+1) == 0)
4069 if (i == (ssize_t) argc)
4070 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4071 if (IsGeometry(argv[i]) == MagickFalse)
4072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4075 if (LocaleCompare(
"alpha",option+1) == 0)
4083 if (i == (ssize_t) argc)
4084 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4085 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
4087 ThrowMogrifyException(OptionError,
"UnrecognizedAlphaChannelType",
4091 if (LocaleCompare(
"annotate",option+1) == 0)
4096 if (i == (ssize_t) argc)
4097 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4098 if (IsGeometry(argv[i]) == MagickFalse)
4099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4100 if (i == (ssize_t) argc)
4101 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4105 if (LocaleCompare(
"antialias",option+1) == 0)
4107 if (LocaleCompare(
"append",option+1) == 0)
4109 if (LocaleCompare(
"attenuate",option+1) == 0)
4114 if (i == (ssize_t) argc)
4115 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4116 if (IsGeometry(argv[i]) == MagickFalse)
4117 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4120 if (LocaleCompare(
"authenticate",option+1) == 0)
4125 if (i == (ssize_t) argc)
4126 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4129 if (LocaleCompare(
"auto-gamma",option+1) == 0)
4131 if (LocaleCompare(
"auto-level",option+1) == 0)
4133 if (LocaleCompare(
"auto-orient",option+1) == 0)
4135 if (LocaleCompare(
"average",option+1) == 0)
4137 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4141 if (LocaleCompare(
"background",option+1) == 0)
4146 if (i == (ssize_t) argc)
4147 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4150 if (LocaleCompare(
"bias",option+1) == 0)
4155 if (i == (ssize_t) argc)
4156 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4157 if (IsGeometry(argv[i]) == MagickFalse)
4158 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4161 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
4163 if (LocaleCompare(
"black-threshold",option+1) == 0)
4168 if (i == (ssize_t) argc)
4169 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4170 if (IsGeometry(argv[i]) == MagickFalse)
4171 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4174 if (LocaleCompare(
"blue-primary",option+1) == 0)
4179 if (i == (ssize_t) argc)
4180 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4181 if (IsGeometry(argv[i]) == MagickFalse)
4182 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4185 if (LocaleCompare(
"blue-shift",option+1) == 0)
4188 if (i == (ssize_t) argc)
4189 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4190 if (IsGeometry(argv[i]) == MagickFalse)
4191 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4194 if (LocaleCompare(
"blur",option+1) == 0)
4197 if (i == (ssize_t) argc)
4198 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4199 if (IsGeometry(argv[i]) == MagickFalse)
4200 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4203 if (LocaleCompare(
"border",option+1) == 0)
4208 if (i == (ssize_t) argc)
4209 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4210 if (IsGeometry(argv[i]) == MagickFalse)
4211 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4214 if (LocaleCompare(
"bordercolor",option+1) == 0)
4219 if (i == (ssize_t) argc)
4220 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4223 if (LocaleCompare(
"box",option+1) == 0)
4228 if (i == (ssize_t) argc)
4229 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4232 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
4235 if (i == (ssize_t) argc)
4236 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4237 if (IsGeometry(argv[i]) == MagickFalse)
4238 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4241 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4245 if (LocaleCompare(
"cache",option+1) == 0)
4250 if (i == (ssize_t) argc)
4251 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4252 if (IsGeometry(argv[i]) == MagickFalse)
4253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4256 if (LocaleCompare(
"canny",option+1) == 0)
4261 if (i == (ssize_t) argc)
4262 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4263 if (IsGeometry(argv[i]) == MagickFalse)
4264 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4267 if (LocaleCompare(
"caption",option+1) == 0)
4272 if (i == (ssize_t) argc)
4273 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4276 if (LocaleCompare(
"channel",option+1) == 0)
4284 if (i == (ssize_t) argc)
4285 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4286 channel=ParseChannelOption(argv[i]);
4288 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4292 if (LocaleCompare(
"cdl",option+1) == 0)
4297 if (i == (ssize_t) argc)
4298 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4301 if (LocaleCompare(
"charcoal",option+1) == 0)
4306 if (i == (ssize_t) argc)
4307 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4308 if (IsGeometry(argv[i]) == MagickFalse)
4309 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4312 if (LocaleCompare(
"chop",option+1) == 0)
4317 if (i == (ssize_t) argc)
4318 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4319 if (IsGeometry(argv[i]) == MagickFalse)
4320 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4323 if (LocaleCompare(
"clamp",option+1) == 0)
4325 if (LocaleCompare(
"clip",option+1) == 0)
4327 if (LocaleCompare(
"clip-mask",option+1) == 0)
4332 if (i == (ssize_t) argc)
4333 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4336 if (LocaleCompare(
"clut",option+1) == 0)
4338 if (LocaleCompare(
"coalesce",option+1) == 0)
4340 if (LocaleCompare(
"colorize",option+1) == 0)
4345 if (i == (ssize_t) argc)
4346 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4347 if (IsGeometry(argv[i]) == MagickFalse)
4348 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4351 if (LocaleCompare(
"color-matrix",option+1) == 0)
4359 if (i == (ssize_t) argc)
4360 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4361 kernel_info=AcquireKernelInfo(argv[i]);
4362 if (kernel_info == (KernelInfo *) NULL)
4363 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4364 kernel_info=DestroyKernelInfo(kernel_info);
4367 if (LocaleCompare(
"colors",option+1) == 0)
4372 if (i == (ssize_t) argc)
4373 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4374 if (IsGeometry(argv[i]) == MagickFalse)
4375 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4378 if (LocaleCompare(
"colorspace",option+1) == 0)
4386 if (i == (ssize_t) argc)
4387 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4388 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4391 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4395 if (LocaleCompare(
"combine",option+1) == 0)
4400 if (i == (ssize_t) argc)
4401 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4404 if (LocaleCompare(
"comment",option+1) == 0)
4409 if (i == (ssize_t) argc)
4410 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4413 if (LocaleCompare(
"compare",option+1) == 0)
4415 if (LocaleCompare(
"complex",option+1) == 0)
4423 if (i == (ssize_t) argc)
4424 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4425 op=ParseCommandOption(MagickComplexOptions,MagickFalse,argv[i]);
4427 ThrowMogrifyException(OptionError,
"UnrecognizedComplexOperator",
4431 if (LocaleCompare(
"compose",option+1) == 0)
4439 if (i == (ssize_t) argc)
4440 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4441 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4444 ThrowMogrifyException(OptionError,
"UnrecognizedComposeOperator",
4448 if (LocaleCompare(
"composite",option+1) == 0)
4450 if (LocaleCompare(
"compress",option+1) == 0)
4458 if (i == (ssize_t) argc)
4459 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4460 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4463 ThrowMogrifyException(OptionError,
"UnrecognizedImageCompression",
4467 if (LocaleCompare(
"concurrent",option+1) == 0)
4469 if (LocaleCompare(
"connected-components",option+1) == 0)
4472 if (i == (ssize_t) argc)
4473 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4474 if (IsGeometry(argv[i]) == MagickFalse)
4475 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4478 if (LocaleCompare(
"contrast",option+1) == 0)
4480 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
4483 if (i == (ssize_t) argc)
4484 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4485 if (IsGeometry(argv[i]) == MagickFalse)
4486 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4489 if (LocaleCompare(
"convolve",option+1) == 0)
4497 if (i == (ssize_t) argc)
4498 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4499 kernel_info=AcquireKernelInfo(argv[i]);
4500 if (kernel_info == (KernelInfo *) NULL)
4501 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4502 kernel_info=DestroyKernelInfo(kernel_info);
4505 if (LocaleCompare(
"copy",option+1) == 0)
4510 if (i == (ssize_t) argc)
4511 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4512 if (IsGeometry(argv[i]) == MagickFalse)
4513 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4515 if (i == (ssize_t) argc)
4516 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4517 if (IsGeometry(argv[i]) == MagickFalse)
4518 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4521 if (LocaleCompare(
"crop",option+1) == 0)
4526 if (i == (ssize_t) argc)
4527 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4528 if (IsGeometry(argv[i]) == MagickFalse)
4529 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4532 if (LocaleCompare(
"cycle",option+1) == 0)
4537 if (i == (ssize_t) argc)
4538 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4539 if (IsGeometry(argv[i]) == MagickFalse)
4540 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4543 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4547 if (LocaleCompare(
"decipher",option+1) == 0)
4552 if (i == (ssize_t) argc)
4553 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4556 if (LocaleCompare(
"deconstruct",option+1) == 0)
4558 if (LocaleCompare(
"debug",option+1) == 0)
4566 if (i == (ssize_t) argc)
4567 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4568 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4570 ThrowMogrifyException(OptionError,
"UnrecognizedEventType",
4572 (void) SetLogEventMask(argv[i]);
4575 if (LocaleCompare(
"define",option+1) == 0)
4578 if (i == (ssize_t) argc)
4579 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4585 define=GetImageOption(image_info,argv[i]);
4586 if (define == (
const char *) NULL)
4587 ThrowMogrifyException(OptionError,
"NoSuchOption",argv[i]);
4592 if (LocaleCompare(
"delay",option+1) == 0)
4597 if (i == (ssize_t) argc)
4598 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4599 if (IsGeometry(argv[i]) == MagickFalse)
4600 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4603 if (LocaleCompare(
"delete",option+1) == 0)
4608 if (i == (ssize_t) argc)
4609 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4610 if (LocaleNCompare(argv[i],
"registry:",9) == 0)
4612 (void) DeleteImageRegistry(argv[i]+9);
4615 if (IsGeometry(argv[i]) == MagickFalse)
4616 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4619 if (LocaleCompare(
"density",option+1) == 0)
4624 if (i == (ssize_t) argc)
4625 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4626 if (IsGeometry(argv[i]) == MagickFalse)
4627 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4630 if (LocaleCompare(
"depth",option+1) == 0)
4635 if (i == (ssize_t) argc)
4636 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4637 if (IsGeometry(argv[i]) == MagickFalse)
4638 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4641 if (LocaleCompare(
"deskew",option+1) == 0)
4646 if (i == (ssize_t) argc)
4647 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4648 if (IsGeometry(argv[i]) == MagickFalse)
4649 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4652 if (LocaleCompare(
"despeckle",option+1) == 0)
4654 if (LocaleCompare(
"dft",option+1) == 0)
4656 if (LocaleCompare(
"direction",option+1) == 0)
4664 if (i == (ssize_t) argc)
4665 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4666 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4669 ThrowMogrifyException(OptionError,
"UnrecognizedDirectionType",
4673 if (LocaleCompare(
"display",option+1) == 0)
4678 if (i == (ssize_t) argc)
4679 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4682 if (LocaleCompare(
"dispose",option+1) == 0)
4690 if (i == (ssize_t) argc)
4691 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4692 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4695 ThrowMogrifyException(OptionError,
"UnrecognizedDisposeMethod",
4699 if (LocaleCompare(
"distort",option+1) == 0)
4705 if (i == (ssize_t) argc)
4706 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4707 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4709 ThrowMogrifyException(OptionError,
"UnrecognizedDistortMethod",
4712 if (i == (ssize_t) argc)
4713 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4716 if (LocaleCompare(
"dither",option+1) == 0)
4724 if (i == (ssize_t) argc)
4725 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4726 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4728 ThrowMogrifyException(OptionError,
"UnrecognizedDitherMethod",
4732 if (LocaleCompare(
"draw",option+1) == 0)
4737 if (i == (ssize_t) argc)
4738 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4741 if (LocaleCompare(
"duplicate",option+1) == 0)
4746 if (i == (ssize_t) argc)
4747 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4748 if (IsGeometry(argv[i]) == MagickFalse)
4749 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4752 if (LocaleCompare(
"duration",option+1) == 0)
4757 if (i == (ssize_t) argc)
4758 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4759 if (IsGeometry(argv[i]) == MagickFalse)
4760 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4763 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4767 if (LocaleCompare(
"edge",option+1) == 0)
4772 if (i == (ssize_t) argc)
4773 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4774 if (IsGeometry(argv[i]) == MagickFalse)
4775 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4778 if (LocaleCompare(
"emboss",option+1) == 0)
4783 if (i == (ssize_t) argc)
4784 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4785 if (IsGeometry(argv[i]) == MagickFalse)
4786 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4789 if (LocaleCompare(
"encipher",option+1) == 0)
4794 if (i == (ssize_t) argc)
4795 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4798 if (LocaleCompare(
"encoding",option+1) == 0)
4803 if (i == (ssize_t) argc)
4804 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4807 if (LocaleCompare(
"endian",option+1) == 0)
4815 if (i == (ssize_t) argc)
4816 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4817 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4819 ThrowMogrifyException(OptionError,
"UnrecognizedEndianType",
4823 if (LocaleCompare(
"enhance",option+1) == 0)
4825 if (LocaleCompare(
"equalize",option+1) == 0)
4827 if (LocaleCompare(
"evaluate",option+1) == 0)
4835 if (i == (ssize_t) argc)
4836 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4837 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4839 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4842 if (i == (ssize_t) argc)
4843 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4844 if (IsGeometry(argv[i]) == MagickFalse)
4845 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4848 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4856 if (i == (ssize_t) argc)
4857 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4858 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4860 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4864 if (LocaleCompare(
"extent",option+1) == 0)
4869 if (i == (ssize_t) argc)
4870 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4871 if (IsGeometry(argv[i]) == MagickFalse)
4872 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4875 if (LocaleCompare(
"extract",option+1) == 0)
4880 if (i == (ssize_t) argc)
4881 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4882 if (IsGeometry(argv[i]) == MagickFalse)
4883 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4886 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4890 if (LocaleCompare(
"family",option+1) == 0)
4895 if (i == (ssize_t) argc)
4896 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4899 if (LocaleCompare(
"features",option+1) == 0)
4904 if (i == (ssize_t) argc)
4905 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4906 if (IsGeometry(argv[i]) == MagickFalse)
4907 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4910 if (LocaleCompare(
"fill",option+1) == 0)
4915 if (i == (ssize_t) argc)
4916 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4919 if (LocaleCompare(
"filter",option+1) == 0)
4927 if (i == (ssize_t) argc)
4928 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4929 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4931 ThrowMogrifyException(OptionError,
"UnrecognizedImageFilter",
4935 if (LocaleCompare(
"flatten",option+1) == 0)
4937 if (LocaleCompare(
"flip",option+1) == 0)
4939 if (LocaleCompare(
"flop",option+1) == 0)
4941 if (LocaleCompare(
"floodfill",option+1) == 0)
4946 if (i == (ssize_t) argc)
4947 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4948 if (IsGeometry(argv[i]) == MagickFalse)
4949 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4951 if (i == (ssize_t) argc)
4952 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4955 if (LocaleCompare(
"font",option+1) == 0)
4960 if (i == (ssize_t) argc)
4961 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4964 if (LocaleCompare(
"format",option+1) == 0)
4966 (void) CopyMagickString(argv[i]+1,
"sans",MaxTextExtent);
4967 (void) CloneString(&format,(
char *) NULL);
4971 if (i == (ssize_t) argc)
4972 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4973 (void) CloneString(&format,argv[i]);
4974 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4975 (void) ConcatenateMagickString(image_info->filename,
":",
4977 (void) SetImageInfo(image_info,0,exception);
4978 if (*image_info->magick ==
'\0')
4979 ThrowMogrifyException(OptionError,
"UnrecognizedImageFormat",
4983 if (LocaleCompare(
"frame",option+1) == 0)
4988 if (i == (ssize_t) argc)
4989 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4990 if (IsGeometry(argv[i]) == MagickFalse)
4991 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4994 if (LocaleCompare(
"function",option+1) == 0)
5002 if (i == (ssize_t) argc)
5003 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5004 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
5006 ThrowMogrifyException(OptionError,
"UnrecognizedFunction",argv[i]);
5008 if (i == (ssize_t) argc)
5009 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5012 if (LocaleCompare(
"fuzz",option+1) == 0)
5017 if (i == (ssize_t) argc)
5018 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5019 if (IsGeometry(argv[i]) == MagickFalse)
5020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5023 if (LocaleCompare(
"fx",option+1) == 0)
5028 if (i == (ssize_t) argc)
5029 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5032 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5036 if (LocaleCompare(
"gamma",option+1) == 0)
5039 if (i == (ssize_t) argc)
5040 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5041 if (IsGeometry(argv[i]) == MagickFalse)
5042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5045 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
5046 (LocaleCompare(
"gaussian",option+1) == 0))
5049 if (i == (ssize_t) argc)
5050 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5051 if (IsGeometry(argv[i]) == MagickFalse)
5052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5055 if (LocaleCompare(
"geometry",option+1) == 0)
5060 if (i == (ssize_t) argc)
5061 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5062 if (IsGeometry(argv[i]) == MagickFalse)
5063 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5066 if (LocaleCompare(
"gravity",option+1) == 0)
5074 if (i == (ssize_t) argc)
5075 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5076 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5079 ThrowMogrifyException(OptionError,
"UnrecognizedGravityType",
5083 if (LocaleCompare(
"grayscale",option+1) == 0)
5091 if (i == (ssize_t) argc)
5092 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5093 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5096 ThrowMogrifyException(OptionError,
"UnrecognizedIntensityMethod",
5100 if (LocaleCompare(
"green-primary",option+1) == 0)
5105 if (i == (ssize_t) argc)
5106 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5107 if (IsGeometry(argv[i]) == MagickFalse)
5108 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5111 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5115 if (LocaleCompare(
"hald-clut",option+1) == 0)
5117 if (LocaleCompare(
"hough-lines",option+1) == 0)
5122 if (i == (ssize_t) argc)
5123 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5124 if (IsGeometry(argv[i]) == MagickFalse)
5125 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5128 if ((LocaleCompare(
"help",option+1) == 0) ||
5129 (LocaleCompare(
"-help",option+1) == 0))
5132 return(MogrifyUsage());
5134 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5138 if (LocaleCompare(
"identify",option+1) == 0)
5140 if (LocaleCompare(
"idft",option+1) == 0)
5142 if (LocaleCompare(
"implode",option+1) == 0)
5147 if (i == (ssize_t) argc)
5148 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5149 if (IsGeometry(argv[i]) == MagickFalse)
5150 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5153 if (LocaleCompare(
"intensity",option+1) == 0)
5161 if (i == (ssize_t) argc)
5162 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5163 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5164 MagickFalse,argv[i]);
5166 ThrowMogrifyException(OptionError,
5167 "UnrecognizedPixelIntensityMethod",argv[i]);
5170 if (LocaleCompare(
"intent",option+1) == 0)
5178 if (i == (ssize_t) argc)
5179 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5180 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5182 ThrowMogrifyException(OptionError,
"UnrecognizedIntentType",
5186 if (LocaleCompare(
"interlace",option+1) == 0)
5194 if (i == (ssize_t) argc)
5195 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5196 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5199 ThrowMogrifyException(OptionError,
"UnrecognizedInterlaceType",
5203 if (LocaleCompare(
"interline-spacing",option+1) == 0)
5208 if (i == (ssize_t) argc)
5209 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5210 if (IsGeometry(argv[i]) == MagickFalse)
5211 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5214 if (LocaleCompare(
"interpolate",option+1) == 0)
5222 if (i == (ssize_t) argc)
5223 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5224 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5226 if (interpolate < 0)
5227 ThrowMogrifyException(OptionError,
"UnrecognizedInterpolateMethod",
5231 if (LocaleCompare(
"interword-spacing",option+1) == 0)
5236 if (i == (ssize_t) argc)
5237 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5238 if (IsGeometry(argv[i]) == MagickFalse)
5239 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5242 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5246 if (LocaleCompare(
"kerning",option+1) == 0)
5251 if (i == (ssize_t) argc)
5252 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5253 if (IsGeometry(argv[i]) == MagickFalse)
5254 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5257 if (LocaleCompare(
"kuwahara",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(
"label",option+1) == 0)
5275 if (i == (ssize_t) argc)
5276 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5279 if (LocaleCompare(
"lat",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(
"layers",option+1) == 0)
5298 if (i == (ssize_t) argc)
5299 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5300 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5302 ThrowMogrifyException(OptionError,
"UnrecognizedLayerMethod",
5306 if (LocaleCompare(
"level",option+1) == 0)
5309 if (i == (ssize_t) argc)
5310 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5311 if (IsGeometry(argv[i]) == MagickFalse)
5312 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5315 if (LocaleCompare(
"level-colors",option+1) == 0)
5318 if (i == (ssize_t) argc)
5319 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5322 if (LocaleCompare(
"linewidth",option+1) == 0)
5327 if (i == (ssize_t) argc)
5328 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5329 if (IsGeometry(argv[i]) == MagickFalse)
5330 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5333 if (LocaleCompare(
"limit",option+1) == 0)
5347 if (i == (ssize_t) argc)
5348 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5349 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5352 ThrowMogrifyException(OptionError,
"UnrecognizedResourceType",
5355 if (i == (ssize_t) argc)
5356 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5357 value=StringToDouble(argv[i],&p);
5359 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
5360 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5363 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
5366 if (i == (ssize_t) argc)
5367 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5368 if (IsGeometry(argv[i]) == MagickFalse)
5369 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5372 if (LocaleCompare(
"list",option+1) == 0)
5380 if (i == (ssize_t) argc)
5381 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5382 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5384 ThrowMogrifyException(OptionError,
"UnrecognizedListType",argv[i]);
5385 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
5387 return(status == 0 ? MagickFalse : MagickTrue);
5389 if (LocaleCompare(
"local-contrast",option+1) == 0)
5392 if (i == (ssize_t) argc)
5393 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5394 if (IsGeometry(argv[i]) == MagickFalse)
5395 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5398 if (LocaleCompare(
"log",option+1) == 0)
5403 if ((i == (ssize_t) argc) ||
5404 (strchr(argv[i],
'%') == (
char *) NULL))
5405 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5408 if (LocaleCompare(
"loop",option+1) == 0)
5413 if (i == (ssize_t) argc)
5414 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5415 if (IsGeometry(argv[i]) == MagickFalse)
5416 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5419 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5423 if (LocaleCompare(
"magnify",option+1) == 0)
5425 if (LocaleCompare(
"map",option+1) == 0)
5427 global_colormap=(*option ==
'+') ? MagickTrue : MagickFalse;
5431 if (i == (ssize_t) argc)
5432 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5435 if (LocaleCompare(
"mask",option+1) == 0)
5440 if (i == (ssize_t) argc)
5441 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5444 if (LocaleCompare(
"matte",option+1) == 0)
5446 if (LocaleCompare(
"mattecolor",option+1) == 0)
5451 if (i == (ssize_t) argc)
5452 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5455 if (LocaleCompare(
"metric",option+1) == 0)
5463 if (i == (ssize_t) argc)
5464 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5465 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5467 ThrowMogrifyException(OptionError,
"UnrecognizedMetricType",
5471 if (LocaleCompare(
"maximum",option+1) == 0)
5473 if (LocaleCompare(
"mean-shift",option+1) == 0)
5478 if (i == (ssize_t) argc)
5479 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5480 if (IsGeometry(argv[i]) == MagickFalse)
5481 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5484 if (LocaleCompare(
"median",option+1) == 0)
5489 if (i == (ssize_t) argc)
5490 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5491 if (IsGeometry(argv[i]) == MagickFalse)
5492 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5495 if (LocaleCompare(
"minimum",option+1) == 0)
5497 if (LocaleCompare(
"modulate",option+1) == 0)
5502 if (i == (ssize_t) argc)
5503 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5504 if (IsGeometry(argv[i]) == MagickFalse)
5505 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5508 if (LocaleCompare(
"mode",option+1) == 0)
5513 if (i == (ssize_t) argc)
5514 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5515 if (IsGeometry(argv[i]) == MagickFalse)
5516 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5519 if (LocaleCompare(
"monitor",option+1) == 0)
5521 if (LocaleCompare(
"monochrome",option+1) == 0)
5523 if (LocaleCompare(
"morph",option+1) == 0)
5528 if (i == (ssize_t) argc)
5529 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5530 if (IsGeometry(argv[i]) == MagickFalse)
5531 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5534 if (LocaleCompare(
"morphology",option+1) == 0)
5537 token[MaxTextExtent];
5546 if (i == (ssize_t) argc)
5547 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5548 (void) GetNextToken(argv[i],(
const char **) NULL,MaxTextExtent,token);
5549 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5551 ThrowMogrifyException(OptionError,
"UnrecognizedMorphologyMethod",
5554 if (i == (ssize_t) argc)
5555 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5556 kernel_info=AcquireKernelInfo(argv[i]);
5557 if (kernel_info == (KernelInfo *) NULL)
5558 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5559 kernel_info=DestroyKernelInfo(kernel_info);
5562 if (LocaleCompare(
"mosaic",option+1) == 0)
5564 if (LocaleCompare(
"motion-blur",option+1) == 0)
5569 if (i == (ssize_t) argc)
5570 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5571 if (IsGeometry(argv[i]) == MagickFalse)
5572 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5575 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5579 if (LocaleCompare(
"negate",option+1) == 0)
5581 if (LocaleCompare(
"noise",option+1) == 0)
5584 if (i == (ssize_t) argc)
5585 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5591 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5593 ThrowMogrifyException(OptionError,
"UnrecognizedNoiseType",
5597 if (IsGeometry(argv[i]) == MagickFalse)
5598 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5601 if (LocaleCompare(
"noop",option+1) == 0)
5603 if (LocaleCompare(
"normalize",option+1) == 0)
5605 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5609 if (LocaleCompare(
"opaque",option+1) == 0)
5612 if (i == (ssize_t) argc)
5613 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5616 if (LocaleCompare(
"ordered-dither",option+1) == 0)
5621 if (i == (ssize_t) argc)
5622 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5625 if (LocaleCompare(
"orient",option+1) == 0)
5630 orientation=UndefinedOrientation;
5634 if (i == (ssize_t) argc)
5635 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5636 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5638 if (orientation < 0)
5639 ThrowMogrifyException(OptionError,
"UnrecognizedImageOrientation",
5643 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5647 if (LocaleCompare(
"page",option+1) == 0)
5652 if (i == (ssize_t) argc)
5653 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5656 if (LocaleCompare(
"paint",option+1) == 0)
5661 if (i == (ssize_t) argc)
5662 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5663 if (IsGeometry(argv[i]) == MagickFalse)
5664 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5667 if (LocaleCompare(
"path",option+1) == 0)
5669 (void) CloneString(&path,(
char *) NULL);
5673 if (i == (ssize_t) argc)
5674 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5675 (void) CloneString(&path,argv[i]);
5678 if (LocaleCompare(
"perceptible",option+1) == 0)
5683 if (i == (ssize_t) argc)
5684 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5685 if (IsGeometry(argv[i]) == MagickFalse)
5686 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5689 if (LocaleCompare(
"pointsize",option+1) == 0)
5694 if (i == (ssize_t) argc)
5695 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5696 if (IsGeometry(argv[i]) == MagickFalse)
5697 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5700 if (LocaleCompare(
"polaroid",option+1) == 0)
5705 if (i == (ssize_t) argc)
5706 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5707 if (IsGeometry(argv[i]) == MagickFalse)
5708 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5711 if (LocaleCompare(
"poly",option+1) == 0)
5716 if (i == (ssize_t) argc)
5717 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5718 if (IsGeometry(argv[i]) == MagickFalse)
5719 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5722 if (LocaleCompare(
"posterize",option+1) == 0)
5727 if (i == (ssize_t) argc)
5728 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5729 if (IsGeometry(argv[i]) == MagickFalse)
5730 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5733 if (LocaleCompare(
"precision",option+1) == 0)
5738 if (i == (ssize_t) argc)
5739 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5740 if (IsGeometry(argv[i]) == MagickFalse)
5741 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5744 if (LocaleCompare(
"print",option+1) == 0)
5749 if (i == (ssize_t) argc)
5750 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5753 if (LocaleCompare(
"process",option+1) == 0)
5758 if (i == (ssize_t) argc)
5759 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5762 if (LocaleCompare(
"profile",option+1) == 0)
5765 if (i == (ssize_t) argc)
5766 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5769 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5773 if (LocaleCompare(
"quality",option+1) == 0)
5778 if (i == (ssize_t) argc)
5779 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5780 if (IsGeometry(argv[i]) == MagickFalse)
5781 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5784 if (LocaleCompare(
"quantize",option+1) == 0)
5792 if (i == (ssize_t) argc)
5793 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5794 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5797 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
5801 if (LocaleCompare(
"quiet",option+1) == 0)
5803 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5807 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
5808 LocaleCompare(
"rotational-blur",option+1) == 0)
5811 if (i == (ssize_t) argc)
5812 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5813 if (IsGeometry(argv[i]) == MagickFalse)
5814 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5817 if (LocaleCompare(
"raise",option+1) == 0)
5820 if (i == (ssize_t) argc)
5821 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5822 if (IsGeometry(argv[i]) == MagickFalse)
5823 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5826 if (LocaleCompare(
"random-threshold",option+1) == 0)
5831 if (i == (ssize_t) argc)
5832 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5833 if (IsGeometry(argv[i]) == MagickFalse)
5834 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5837 if (LocaleCompare(
"recolor",option+1) == 0)
5842 if (i == (ssize_t) argc)
5843 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5844 if (IsGeometry(argv[i]) == MagickFalse)
5845 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5848 if (LocaleCompare(
"red-primary",option+1) == 0)
5853 if (i == (ssize_t) argc)
5854 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5855 if (IsGeometry(argv[i]) == MagickFalse)
5856 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5858 if (LocaleCompare(
"regard-warnings",option+1) == 0)
5860 if (LocaleCompare(
"region",option+1) == 0)
5865 if (i == (ssize_t) argc)
5866 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5867 if (IsGeometry(argv[i]) == MagickFalse)
5868 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5871 if (LocaleCompare(
"remap",option+1) == 0)
5876 if (i == (ssize_t) argc)
5877 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5880 if (LocaleCompare(
"render",option+1) == 0)
5882 if (LocaleCompare(
"repage",option+1) == 0)
5887 if (i == (ssize_t) argc)
5888 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5889 if (IsGeometry(argv[i]) == MagickFalse)
5890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5893 if (LocaleCompare(
"resample",option+1) == 0)
5898 if (i == (ssize_t) argc)
5899 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5900 if (IsGeometry(argv[i]) == MagickFalse)
5901 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5904 if (LocaleCompare(
"resize",option+1) == 0)
5909 if (i == (ssize_t) argc)
5910 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5911 if (IsGeometry(argv[i]) == MagickFalse)
5912 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5915 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
5917 respect_parenthesis=(*option ==
'-') ? MagickTrue : MagickFalse;
5920 if (LocaleCompare(
"reverse",option+1) == 0)
5922 if (LocaleCompare(
"roll",option+1) == 0)
5927 if (i == (ssize_t) argc)
5928 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5929 if (IsGeometry(argv[i]) == MagickFalse)
5930 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5933 if (LocaleCompare(
"rotate",option+1) == 0)
5936 if (i == (ssize_t) argc)
5937 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5938 if (IsGeometry(argv[i]) == MagickFalse)
5939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5942 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5946 if (LocaleCompare(
"sample",option+1) == 0)
5951 if (i == (ssize_t) argc)
5952 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5953 if (IsGeometry(argv[i]) == MagickFalse)
5954 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5957 if (LocaleCompare(
"sampling-factor",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(
"scale",option+1) == 0)
5973 if (i == (ssize_t) argc)
5974 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5975 if (IsGeometry(argv[i]) == MagickFalse)
5976 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5979 if (LocaleCompare(
"scene",option+1) == 0)
5984 if (i == (ssize_t) argc)
5985 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5986 if (IsGeometry(argv[i]) == MagickFalse)
5987 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5990 if (LocaleCompare(
"seed",option+1) == 0)
5995 if (i == (ssize_t) argc)
5996 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5997 if (IsGeometry(argv[i]) == MagickFalse)
5998 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6001 if (LocaleCompare(
"segment",option+1) == 0)
6006 if (i == (ssize_t) argc)
6007 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6008 if (IsGeometry(argv[i]) == MagickFalse)
6009 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6012 if (LocaleCompare(
"selective-blur",option+1) == 0)
6015 if (i == (ssize_t) argc)
6016 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6017 if (IsGeometry(argv[i]) == MagickFalse)
6018 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6021 if (LocaleCompare(
"separate",option+1) == 0)
6023 if (LocaleCompare(
"sepia-tone",option+1) == 0)
6028 if (i == (ssize_t) argc)
6029 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6030 if (IsGeometry(argv[i]) == MagickFalse)
6031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6034 if (LocaleCompare(
"set",option+1) == 0)
6037 if (i == (ssize_t) argc)
6038 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6042 if (i == (ssize_t) argc)
6043 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6046 if (LocaleCompare(
"shade",option+1) == 0)
6049 if (i == (ssize_t) argc)
6050 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6051 if (IsGeometry(argv[i]) == MagickFalse)
6052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6055 if (LocaleCompare(
"shadow",option+1) == 0)
6060 if (i == (ssize_t) argc)
6061 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6062 if (IsGeometry(argv[i]) == MagickFalse)
6063 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6066 if (LocaleCompare(
"sharpen",option+1) == 0)
6069 if (i == (ssize_t) argc)
6070 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6071 if (IsGeometry(argv[i]) == MagickFalse)
6072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6075 if (LocaleCompare(
"shave",option+1) == 0)
6080 if (i == (ssize_t) argc)
6081 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6082 if (IsGeometry(argv[i]) == MagickFalse)
6083 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6086 if (LocaleCompare(
"shear",option+1) == 0)
6089 if (i == (ssize_t) argc)
6090 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6091 if (IsGeometry(argv[i]) == MagickFalse)
6092 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6095 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
6098 if (i == (ssize_t) argc)
6099 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6100 if (IsGeometry(argv[i]) == MagickFalse)
6101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6104 if (LocaleCompare(
"size",option+1) == 0)
6109 if (i == (ssize_t) argc)
6110 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6111 if (IsGeometry(argv[i]) == MagickFalse)
6112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6115 if (LocaleCompare(
"sketch",option+1) == 0)
6120 if (i == (ssize_t) argc)
6121 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6122 if (IsGeometry(argv[i]) == MagickFalse)
6123 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6126 if (LocaleCompare(
"smush",option+1) == 0)
6129 if (i == (ssize_t) argc)
6130 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6131 if (IsGeometry(argv[i]) == MagickFalse)
6132 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6136 if (LocaleCompare(
"solarize",option+1) == 0)
6141 if (i == (ssize_t) argc)
6142 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6143 if (IsGeometry(argv[i]) == MagickFalse)
6144 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6147 if (LocaleCompare(
"sparse-color",option+1) == 0)
6153 if (i == (ssize_t) argc)
6154 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6155 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6157 ThrowMogrifyException(OptionError,
"UnrecognizedSparseColorMethod",
6160 if (i == (ssize_t) argc)
6161 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6164 if (LocaleCompare(
"splice",option+1) == 0)
6169 if (i == (ssize_t) argc)
6170 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6171 if (IsGeometry(argv[i]) == MagickFalse)
6172 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6175 if (LocaleCompare(
"spread",option+1) == 0)
6180 if (i == (ssize_t) argc)
6181 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6182 if (IsGeometry(argv[i]) == MagickFalse)
6183 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6186 if (LocaleCompare(
"statistic",option+1) == 0)
6194 if (i == (ssize_t) argc)
6195 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6196 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6198 ThrowMogrifyException(OptionError,
"UnrecognizedStatisticType",
6201 if (i == (ssize_t) argc)
6202 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6203 if (IsGeometry(argv[i]) == MagickFalse)
6204 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6207 if (LocaleCompare(
"stretch",option+1) == 0)
6215 if (i == (ssize_t) argc)
6216 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6217 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
6219 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6223 if (LocaleCompare(
"strip",option+1) == 0)
6225 if (LocaleCompare(
"stroke",option+1) == 0)
6230 if (i == (ssize_t) argc)
6231 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6234 if (LocaleCompare(
"strokewidth",option+1) == 0)
6239 if (i == (ssize_t) argc)
6240 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6241 if (IsGeometry(argv[i]) == MagickFalse)
6242 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6245 if (LocaleCompare(
"style",option+1) == 0)
6253 if (i == (ssize_t) argc)
6254 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6255 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6257 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6261 if (LocaleCompare(
"swap",option+1) == 0)
6266 if (i == (ssize_t) argc)
6267 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6268 if (IsGeometry(argv[i]) == MagickFalse)
6269 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6272 if (LocaleCompare(
"swirl",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(
"synchronize",option+1) == 0)
6285 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6289 if (LocaleCompare(
"taint",option+1) == 0)
6291 if (LocaleCompare(
"texture",option+1) == 0)
6296 if (i == (ssize_t) argc)
6297 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6300 if (LocaleCompare(
"tile",option+1) == 0)
6305 if (i == (ssize_t) argc)
6306 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6309 if (LocaleCompare(
"tile-offset",option+1) == 0)
6314 if (i == (ssize_t) argc)
6315 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6316 if (IsGeometry(argv[i]) == MagickFalse)
6317 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6320 if (LocaleCompare(
"tint",option+1) == 0)
6325 if (i == (ssize_t) argc)
6326 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6327 if (IsGeometry(argv[i]) == MagickFalse)
6328 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6331 if (LocaleCompare(
"transform",option+1) == 0)
6333 if (LocaleCompare(
"transpose",option+1) == 0)
6335 if (LocaleCompare(
"transverse",option+1) == 0)
6337 if (LocaleCompare(
"threshold",option+1) == 0)
6342 if (i == (ssize_t) argc)
6343 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6344 if (IsGeometry(argv[i]) == MagickFalse)
6345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6348 if (LocaleCompare(
"thumbnail",option+1) == 0)
6353 if (i == (ssize_t) argc)
6354 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6355 if (IsGeometry(argv[i]) == MagickFalse)
6356 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6359 if (LocaleCompare(
"transparent",option+1) == 0)
6362 if (i == (ssize_t) argc)
6363 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6366 if (LocaleCompare(
"transparent-color",option+1) == 0)
6371 if (i == (ssize_t) argc)
6372 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6375 if (LocaleCompare(
"treedepth",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(
"trim",option+1) == 0)
6388 if (LocaleCompare(
"type",option+1) == 0)
6396 if (i == (ssize_t) argc)
6397 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6398 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6400 ThrowMogrifyException(OptionError,
"UnrecognizedImageType",
6404 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6408 if (LocaleCompare(
"undercolor",option+1) == 0)
6413 if (i == (ssize_t) argc)
6414 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6417 if (LocaleCompare(
"unique-colors",option+1) == 0)
6419 if (LocaleCompare(
"units",option+1) == 0)
6427 if (i == (ssize_t) argc)
6428 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6429 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6432 ThrowMogrifyException(OptionError,
"UnrecognizedUnitsType",
6436 if (LocaleCompare(
"unsharp",option+1) == 0)
6439 if (i == (ssize_t) argc)
6440 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6441 if (IsGeometry(argv[i]) == MagickFalse)
6442 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6445 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6449 if (LocaleCompare(
"verbose",option+1) == 0)
6451 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
6454 if ((LocaleCompare(
"version",option+1) == 0) ||
6455 (LocaleCompare(
"-version",option+1) == 0))
6457 ListMagickVersion(stdout);
6460 if (LocaleCompare(
"view",option+1) == 0)
6465 if (i == (ssize_t) argc)
6466 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6469 if (LocaleCompare(
"vignette",option+1) == 0)
6474 if (i == (ssize_t) argc)
6475 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6476 if (IsGeometry(argv[i]) == MagickFalse)
6477 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6480 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
6488 if (i == (ssize_t) argc)
6489 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6490 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6493 ThrowMogrifyException(OptionError,
6494 "UnrecognizedVirtualPixelMethod",argv[i]);
6497 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6501 if (LocaleCompare(
"wave",option+1) == 0)
6504 if (i == (ssize_t) argc)
6505 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6506 if (IsGeometry(argv[i]) == MagickFalse)
6507 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6510 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
6513 if (i == (ssize_t) argc)
6514 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6515 if (IsGeometry(argv[i]) == MagickFalse)
6516 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6519 if (LocaleCompare(
"weight",option+1) == 0)
6524 if (i == (ssize_t) argc)
6525 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6528 if (LocaleCompare(
"white-point",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(
"white-threshold",option+1) == 0)
6544 if (i == (ssize_t) argc)
6545 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6546 if (IsGeometry(argv[i]) == MagickFalse)
6547 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6550 if (LocaleCompare(
"write",option+1) == 0)
6553 if (i == (ssize_t) argc)
6554 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6557 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6562 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6564 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6565 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6566 if (fire != MagickFalse)
6567 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6570 ThrowMogrifyException(OptionError,
"UnbalancedParenthesis",argv[i]);
6571 if (i != (ssize_t) argc)
6572 ThrowMogrifyException(OptionError,
"MissingAnImageFilename",argv[i]);
6574 return(status != 0 ? MagickTrue : MagickFalse);
6609WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6610 const int argc,
const char **argv,ExceptionInfo *exception)
6627 assert(image_info != (ImageInfo *) NULL);
6628 assert(image_info->signature == MagickCoreSignature);
6629 if (IsEventLogging() != MagickFalse)
6630 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
6631 image_info->filename);
6637 for (i=0; i < (ssize_t) argc; i++)
6640 if (IsCommandOption(option) == MagickFalse)
6642 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6643 count=MagickMax(count,0L);
6644 if ((i+count) >= (ssize_t) argc)
6646 switch (*(option+1))
6650 if (LocaleCompare(
"adjoin",option+1) == 0)
6652 image_info->adjoin=(*option ==
'-') ? MagickTrue : MagickFalse;
6655 if (LocaleCompare(
"antialias",option+1) == 0)
6657 image_info->antialias=(*option ==
'-') ? MagickTrue : MagickFalse;
6660 if (LocaleCompare(
"attenuate",option+1) == 0)
6664 (void) DeleteImageOption(image_info,option+1);
6667 (void) SetImageOption(image_info,option+1,argv[i+1]);
6670 if (LocaleCompare(
"authenticate",option+1) == 0)
6673 (void) CloneString(&image_info->authenticate,(
char *) NULL);
6675 (
void) CloneString(&image_info->authenticate,argv[i+1]);
6682 if (LocaleCompare(
"background",option+1) == 0)
6686 (void) DeleteImageOption(image_info,option+1);
6687 (void) QueryColorDatabase(MogrifyBackgroundColor,
6688 &image_info->background_color,exception);
6691 (void) SetImageOption(image_info,option+1,argv[i+1]);
6692 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6696 if (LocaleCompare(
"bias",option+1) == 0)
6700 (void) SetImageOption(image_info,option+1,
"0.0");
6703 (void) SetImageOption(image_info,option+1,argv[i+1]);
6706 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
6710 (void) SetImageOption(image_info,option+1,
"false");
6713 (void) SetImageOption(image_info,option+1,
"true");
6716 if (LocaleCompare(
"blue-primary",option+1) == 0)
6720 (void) SetImageOption(image_info,option+1,
"0.0");
6723 (void) SetImageOption(image_info,option+1,argv[i+1]);
6726 if (LocaleCompare(
"bordercolor",option+1) == 0)
6730 (void) DeleteImageOption(image_info,option+1);
6731 (void) QueryColorDatabase(MogrifyBorderColor,
6732 &image_info->border_color,exception);
6735 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6737 (void) SetImageOption(image_info,option+1,argv[i+1]);
6740 if (LocaleCompare(
"box",option+1) == 0)
6744 (void) SetImageOption(image_info,
"undercolor",
"none");
6747 (void) SetImageOption(image_info,
"undercolor",argv[i+1]);
6754 if (LocaleCompare(
"cache",option+1) == 0)
6759 limit=MagickResourceInfinity;
6760 if (LocaleCompare(
"unlimited",argv[i+1]) != 0)
6761 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],100.0);
6762 (void) SetMagickResourceLimit(MemoryResource,limit);
6763 (void) SetMagickResourceLimit(MapResource,2*limit);
6766 if (LocaleCompare(
"caption",option+1) == 0)
6770 (void) DeleteImageOption(image_info,option+1);
6773 (void) SetImageOption(image_info,option+1,argv[i+1]);
6776 if (LocaleCompare(
"channel",option+1) == 0)
6780 image_info->channel=DefaultChannels;
6783 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6786 if (LocaleCompare(
"colors",option+1) == 0)
6788 image_info->colors=StringToUnsignedLong(argv[i+1]);
6791 if (LocaleCompare(
"colorspace",option+1) == 0)
6795 image_info->colorspace=UndefinedColorspace;
6796 (void) SetImageOption(image_info,option+1,
"undefined");
6799 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6800 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6801 (void) SetImageOption(image_info,option+1,argv[i+1]);
6804 if (LocaleCompare(
"comment",option+1) == 0)
6808 (void) DeleteImageOption(image_info,option+1);
6811 (void) SetImageOption(image_info,option+1,argv[i+1]);
6814 if (LocaleCompare(
"compose",option+1) == 0)
6818 (void) SetImageOption(image_info,option+1,
"undefined");
6821 (void) SetImageOption(image_info,option+1,argv[i+1]);
6824 if (LocaleCompare(
"compress",option+1) == 0)
6828 image_info->compression=UndefinedCompression;
6829 (void) SetImageOption(image_info,option+1,
"undefined");
6832 image_info->compression=(CompressionType) ParseCommandOption(
6833 MagickCompressOptions,MagickFalse,argv[i+1]);
6834 (void) SetImageOption(image_info,option+1,argv[i+1]);
6841 if (LocaleCompare(
"debug",option+1) == 0)
6844 (void) SetLogEventMask(
"none");
6846 (
void) SetLogEventMask(argv[i+1]);
6847 image_info->debug=IsEventLogging();
6850 if (LocaleCompare(
"define",option+1) == 0)
6854 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6855 (void) DeleteImageRegistry(argv[i+1]+9);
6857 (
void) DeleteImageOption(image_info,argv[i+1]);
6860 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6862 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6866 (void) DefineImageOption(image_info,argv[i+1]);
6869 if (LocaleCompare(
"delay",option+1) == 0)
6873 (void) SetImageOption(image_info,option+1,
"0");
6876 (void) SetImageOption(image_info,option+1,argv[i+1]);
6879 if (LocaleCompare(
"density",option+1) == 0)
6886 if (image_info->density != (
char *) NULL)
6887 image_info->density=DestroyString(image_info->density);
6888 (void) SetImageOption(image_info,option+1,
"72");
6891 (void) CloneString(&image_info->density,argv[i+1]);
6892 (void) SetImageOption(image_info,option+1,argv[i+1]);
6895 if (LocaleCompare(
"depth",option+1) == 0)
6899 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6902 image_info->depth=StringToUnsignedLong(argv[i+1]);
6905 if (LocaleCompare(
"direction",option+1) == 0)
6909 (void) SetImageOption(image_info,option+1,
"undefined");
6912 (void) SetImageOption(image_info,option+1,argv[i+1]);
6915 if (LocaleCompare(
"display",option+1) == 0)
6919 if (image_info->server_name != (
char *) NULL)
6920 image_info->server_name=DestroyString(
6921 image_info->server_name);
6924 (void) CloneString(&image_info->server_name,argv[i+1]);
6927 if (LocaleCompare(
"dispose",option+1) == 0)
6931 (void) SetImageOption(image_info,option+1,
"undefined");
6934 (void) SetImageOption(image_info,option+1,argv[i+1]);
6937 if (LocaleCompare(
"dither",option+1) == 0)
6941 image_info->dither=MagickFalse;
6942 (void) SetImageOption(image_info,option+1,
"none");
6945 (void) SetImageOption(image_info,option+1,argv[i+1]);
6946 image_info->dither=MagickTrue;
6953 if (LocaleCompare(
"encoding",option+1) == 0)
6957 (void) SetImageOption(image_info,option+1,
"undefined");
6960 (void) SetImageOption(image_info,option+1,argv[i+1]);
6963 if (LocaleCompare(
"endian",option+1) == 0)
6967 image_info->endian=UndefinedEndian;
6968 (void) SetImageOption(image_info,option+1,
"undefined");
6971 image_info->endian=(EndianType) ParseCommandOption(
6972 MagickEndianOptions,MagickFalse,argv[i+1]);
6973 (void) SetImageOption(image_info,option+1,argv[i+1]);
6976 if (LocaleCompare(
"extract",option+1) == 0)
6983 if (image_info->extract != (
char *) NULL)
6984 image_info->extract=DestroyString(image_info->extract);
6987 (void) CloneString(&image_info->extract,argv[i+1]);
6994 if (LocaleCompare(
"family",option+1) == 0)
6997 (void) SetImageOption(image_info,option+1,argv[i+1]);
7000 if (LocaleCompare(
"fill",option+1) == 0)
7004 (void) SetImageOption(image_info,option+1,
"none");
7007 (void) SetImageOption(image_info,option+1,argv[i+1]);
7010 if (LocaleCompare(
"filter",option+1) == 0)
7014 (void) SetImageOption(image_info,option+1,
"undefined");
7017 (void) SetImageOption(image_info,option+1,argv[i+1]);
7020 if (LocaleCompare(
"font",option+1) == 0)
7024 if (image_info->font != (
char *) NULL)
7025 image_info->font=DestroyString(image_info->font);
7028 (void) CloneString(&image_info->font,argv[i+1]);
7031 if (LocaleCompare(
"format",option+1) == 0)
7033 (void) SetImageOption(image_info,option+1,argv[i+1]);
7036 if (LocaleCompare(
"fuzz",option+1) == 0)
7040 image_info->fuzz=0.0;
7041 (void) SetImageOption(image_info,option+1,
"0");
7044 image_info->fuzz=StringToDoubleInterval(argv[i+1],(
double)
7046 (void) SetImageOption(image_info,option+1,argv[i+1]);
7053 if (LocaleCompare(
"gravity",option+1) == 0)
7057 (void) SetImageOption(image_info,option+1,
"undefined");
7060 (void) SetImageOption(image_info,option+1,argv[i+1]);
7063 if (LocaleCompare(
"green-primary",option+1) == 0)
7067 (void) SetImageOption(image_info,option+1,
"0.0");
7070 (void) SetImageOption(image_info,option+1,argv[i+1]);
7077 if (LocaleCompare(
"intensity",option+1) == 0)
7081 (void) SetImageOption(image_info,option+1,
"undefined");
7084 (void) SetImageOption(image_info,option+1,argv[i+1]);
7087 if (LocaleCompare(
"intent",option+1) == 0)
7091 (void) SetImageOption(image_info,option+1,
"undefined");
7094 (void) SetImageOption(image_info,option+1,argv[i+1]);
7097 if (LocaleCompare(
"interlace",option+1) == 0)
7101 image_info->interlace=UndefinedInterlace;
7102 (void) SetImageOption(image_info,option+1,
"undefined");
7105 image_info->interlace=(InterlaceType) ParseCommandOption(
7106 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7107 (void) SetImageOption(image_info,option+1,argv[i+1]);
7110 if (LocaleCompare(
"interline-spacing",option+1) == 0)
7114 (void) SetImageOption(image_info,option+1,
"undefined");
7117 (void) SetImageOption(image_info,option+1,argv[i+1]);
7120 if (LocaleCompare(
"interpolate",option+1) == 0)
7124 (void) SetImageOption(image_info,option+1,
"undefined");
7127 (void) SetImageOption(image_info,option+1,argv[i+1]);
7130 if (LocaleCompare(
"interword-spacing",option+1) == 0)
7134 (void) SetImageOption(image_info,option+1,
"undefined");
7137 (void) SetImageOption(image_info,option+1,argv[i+1]);
7144 if (LocaleCompare(
"kerning",option+1) == 0)
7148 (void) SetImageOption(image_info,option+1,
"undefined");
7151 (void) SetImageOption(image_info,option+1,argv[i+1]);
7158 if (LocaleCompare(
"label",option+1) == 0)
7162 (void) DeleteImageOption(image_info,option+1);
7165 (void) SetImageOption(image_info,option+1,argv[i+1]);
7168 if (LocaleCompare(
"limit",option+1) == 0)
7178 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7179 MagickFalse,argv[i+1]);
7180 limit=MagickResourceInfinity;
7181 if (LocaleCompare(
"unlimited",argv[i+2]) != 0)
7182 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7183 if (type == TimeResource)
7184 limit=(MagickSizeType) ParseMagickTimeToLive(argv[i+2]);
7185 (void) SetMagickResourceLimit(type,limit);
7188 if (LocaleCompare(
"list",option+1) == 0)
7196 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7199 case MagickCoderOptions:
7201 (void) ListCoderInfo((FILE *) NULL,exception);
7204 case MagickColorOptions:
7206 (void) ListColorInfo((FILE *) NULL,exception);
7209 case MagickConfigureOptions:
7211 (void) ListConfigureInfo((FILE *) NULL,exception);
7214 case MagickDelegateOptions:
7216 (void) ListDelegateInfo((FILE *) NULL,exception);
7219 case MagickFontOptions:
7221 (void) ListTypeInfo((FILE *) NULL,exception);
7224 case MagickFormatOptions:
7226 (void) ListMagickInfo((FILE *) NULL,exception);
7229 case MagickLocaleOptions:
7231 (void) ListLocaleInfo((FILE *) NULL,exception);
7234 case MagickLogOptions:
7236 (void) ListLogInfo((FILE *) NULL,exception);
7239 case MagickMagicOptions:
7241 (void) ListMagicInfo((FILE *) NULL,exception);
7244 case MagickMimeOptions:
7246 (void) ListMimeInfo((FILE *) NULL,exception);
7249 case MagickModuleOptions:
7251 (void) ListModuleInfo((FILE *) NULL,exception);
7254 case MagickPagesizeOptions:
7256 (void) ListPagesizes((FILE *) NULL,exception);
7259 case MagickPolicyOptions:
7261 (void) ListPolicyInfo((FILE *) NULL,exception);
7264 case MagickResourceOptions:
7266 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7269 case MagickThresholdOptions:
7271 (void) ListThresholdMaps((FILE *) NULL,exception);
7276 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7283 if (LocaleCompare(
"log",option+1) == 0)
7287 (void) SetLogFormat(argv[i+1]);
7290 if (LocaleCompare(
"loop",option+1) == 0)
7294 (void) SetImageOption(image_info,option+1,
"0");
7297 (void) SetImageOption(image_info,option+1,argv[i+1]);
7304 if (LocaleCompare(
"matte",option+1) == 0)
7308 (void) SetImageOption(image_info,option+1,
"false");
7311 (void) SetImageOption(image_info,option+1,
"true");
7314 if (LocaleCompare(
"mattecolor",option+1) == 0)
7318 (void) SetImageOption(image_info,option+1,argv[i+1]);
7319 (void) QueryColorDatabase(MogrifyMatteColor,
7320 &image_info->matte_color,exception);
7323 (void) SetImageOption(image_info,option+1,argv[i+1]);
7324 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7328 if (LocaleCompare(
"metric",option+1) == 0)
7332 (void) DeleteImageOption(image_info,option+1);
7335 (void) SetImageOption(image_info,option+1,argv[i+1]);
7338 if (LocaleCompare(
"monitor",option+1) == 0)
7340 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7344 if (LocaleCompare(
"monochrome",option+1) == 0)
7346 image_info->monochrome=(*option ==
'-') ? MagickTrue : MagickFalse;
7353 if (LocaleCompare(
"orient",option+1) == 0)
7357 image_info->orientation=UndefinedOrientation;
7358 (void) SetImageOption(image_info,option+1,
"undefined");
7361 image_info->orientation=(OrientationType) ParseCommandOption(
7362 MagickOrientationOptions,MagickFalse,argv[i+1]);
7363 (void) SetImageOption(image_info,option+1,argv[i+1]);
7370 if (LocaleCompare(
"page",option+1) == 0)
7374 page[MaxTextExtent];
7387 (void) DeleteImageOption(image_info,option+1);
7388 (void) CloneString(&image_info->page,(
char *) NULL);
7391 (void) memset(&geometry,0,
sizeof(geometry));
7392 image_option=GetImageOption(image_info,
"page");
7393 if (image_option != (
const char *) NULL)
7394 (void) ParseAbsoluteGeometry(image_option,&geometry);
7395 canonical_page=GetPageGeometry(argv[i+1]);
7396 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7397 canonical_page=DestroyString(canonical_page);
7398 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu",
7399 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
7400 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7401 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu%+ld%+ld",
7402 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
7403 (
long) geometry.x,(long) geometry.y);
7404 (void) SetImageOption(image_info,option+1,page);
7405 (void) CloneString(&image_info->page,page);
7408 if (LocaleCompare(
"pen",option+1) == 0)
7412 (void) SetImageOption(image_info,option+1,
"none");
7415 (void) SetImageOption(image_info,option+1,argv[i+1]);
7418 if (LocaleCompare(
"ping",option+1) == 0)
7420 image_info->ping=(*option ==
'-') ? MagickTrue : MagickFalse;
7423 if (LocaleCompare(
"pointsize",option+1) == 0)
7426 geometry_info.rho=0.0;
7428 (
void) ParseGeometry(argv[i+1],&geometry_info);
7429 image_info->pointsize=geometry_info.rho;
7432 if (LocaleCompare(
"precision",option+1) == 0)
7434 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7437 if (LocaleCompare(
"preview",option+1) == 0)
7444 image_info->preview_type=UndefinedPreview;
7447 image_info->preview_type=(PreviewType) ParseCommandOption(
7448 MagickPreviewOptions,MagickFalse,argv[i+1]);
7455 if (LocaleCompare(
"quality",option+1) == 0)
7462 image_info->quality=UndefinedCompressionQuality;
7463 (void) SetImageOption(image_info,option+1,
"0");
7466 image_info->quality=StringToUnsignedLong(argv[i+1]);
7467 (void) SetImageOption(image_info,option+1,argv[i+1]);
7470 if (LocaleCompare(
"quiet",option+1) == 0)
7472 static WarningHandler
7473 warning_handler = (WarningHandler) NULL;
7480 warning_handler=SetWarningHandler(warning_handler);
7486 warning_handler=SetWarningHandler((WarningHandler) NULL);
7493 if (LocaleCompare(
"red-primary",option+1) == 0)
7497 (void) SetImageOption(image_info,option+1,
"0.0");
7500 (void) SetImageOption(image_info,option+1,argv[i+1]);
7507 if (LocaleCompare(
"sampling-factor",option+1) == 0)
7514 if (image_info->sampling_factor != (
char *) NULL)
7515 image_info->sampling_factor=DestroyString(
7516 image_info->sampling_factor);
7519 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7522 if (LocaleCompare(
"scene",option+1) == 0)
7529 image_info->scene=0;
7530 (void) SetImageOption(image_info,option+1,
"0");
7533 image_info->scene=StringToUnsignedLong(argv[i+1]);
7534 (void) SetImageOption(image_info,option+1,argv[i+1]);
7537 if (LocaleCompare(
"seed",option+1) == 0)
7544 seed=(
unsigned long) time((time_t *) NULL);
7545 SetRandomSecretKey(seed);
7548 seed=StringToUnsignedLong(argv[i+1]);
7549 SetRandomSecretKey(seed);
7552 if (LocaleCompare(
"size",option+1) == 0)
7556 if (image_info->size != (
char *) NULL)
7557 image_info->size=DestroyString(image_info->size);
7560 (void) CloneString(&image_info->size,argv[i+1]);
7563 if (LocaleCompare(
"stroke",option+1) == 0)
7566 (void) SetImageOption(image_info,option+1,
"none");
7568 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7571 if (LocaleCompare(
"strokewidth",option+1) == 0)
7574 (void) SetImageOption(image_info,option+1,
"0");
7576 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7579 if (LocaleCompare(
"style",option+1) == 0)
7582 (void) SetImageOption(image_info,option+1,
"none");
7584 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7587 if (LocaleCompare(
"synchronize",option+1) == 0)
7591 image_info->synchronize=MagickFalse;
7594 image_info->synchronize=MagickTrue;
7601 if (LocaleCompare(
"taint",option+1) == 0)
7605 (void) SetImageOption(image_info,option+1,
"false");
7608 (void) SetImageOption(image_info,option+1,
"true");
7611 if (LocaleCompare(
"texture",option+1) == 0)
7615 if (image_info->texture != (
char *) NULL)
7616 image_info->texture=DestroyString(image_info->texture);
7619 (void) CloneString(&image_info->texture,argv[i+1]);
7622 if (LocaleCompare(
"tile-offset",option+1) == 0)
7626 (void) SetImageOption(image_info,option+1,
"0");
7629 (void) SetImageOption(image_info,option+1,argv[i+1]);
7632 if (LocaleCompare(
"transparent-color",option+1) == 0)
7636 (void) QueryColorDatabase(
"none",&image_info->transparent_color, exception);
7637 (void) SetImageOption(image_info,option+1,
"none");
7640 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7642 (void) SetImageOption(image_info,option+1,argv[i+1]);
7645 if (LocaleCompare(
"type",option+1) == 0)
7649 image_info->type=UndefinedType;
7650 (void) SetImageOption(image_info,option+1,
"undefined");
7653 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7654 MagickFalse,argv[i+1]);
7655 (void) SetImageOption(image_info,option+1,argv[i+1]);
7662 if (LocaleCompare(
"undercolor",option+1) == 0)
7666 (void) DeleteImageOption(image_info,option+1);
7669 (void) SetImageOption(image_info,option+1,argv[i+1]);
7672 if (LocaleCompare(
"units",option+1) == 0)
7676 image_info->units=UndefinedResolution;
7677 (void) SetImageOption(image_info,option+1,
"undefined");
7680 image_info->units=(ResolutionType) ParseCommandOption(
7681 MagickResolutionOptions,MagickFalse,argv[i+1]);
7682 (void) SetImageOption(image_info,option+1,argv[i+1]);
7689 if (LocaleCompare(
"verbose",option+1) == 0)
7693 image_info->verbose=MagickFalse;
7696 image_info->verbose=MagickTrue;
7697 image_info->ping=MagickFalse;
7700 if (LocaleCompare(
"view",option+1) == 0)
7704 if (image_info->view != (
char *) NULL)
7705 image_info->view=DestroyString(image_info->view);
7708 (void) CloneString(&image_info->view,argv[i+1]);
7711 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
7715 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7716 (void) SetImageOption(image_info,option+1,
"undefined");
7719 image_info->virtual_pixel_method=(VirtualPixelMethod)
7720 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7722 (void) SetImageOption(image_info,option+1,argv[i+1]);
7729 if (LocaleCompare(
"weight",option+1) == 0)
7732 (void) SetImageOption(image_info,option+1,
"0");
7734 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7737 if (LocaleCompare(
"white-point",option+1) == 0)
7741 (void) SetImageOption(image_info,option+1,
"0.0");
7744 (void) SetImageOption(image_info,option+1,argv[i+1]);
7791WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7792 const int argc,
const char **argv,Image **images,ExceptionInfo *exception)
7819 assert(image_info != (ImageInfo *) NULL);
7820 assert(image_info->signature == MagickCoreSignature);
7821 assert(images != (Image **) NULL);
7822 assert((*images)->previous == (Image *) NULL);
7823 assert((*images)->signature == MagickCoreSignature);
7824 if (IsEventLogging() != MagickFalse)
7825 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
7826 (*images)->filename);
7827 if ((argc <= 0) || (*argv == (
char *) NULL))
7829 mogrify_info=CloneImageInfo(image_info);
7830 quantize_info=AcquireQuantizeInfo(mogrify_info);
7831 channel=mogrify_info->channel;
7833 for (i=0; i < (ssize_t) argc; i++)
7835 if (*images == (Image *) NULL)
7838 if (IsCommandOption(option) == MagickFalse)
7840 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7841 count=MagickMax(count,0L);
7842 if ((i+count) >= (ssize_t) argc)
7844 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
7845 switch (*(option+1))
7849 if (LocaleCompare(
"affinity",option+1) == 0)
7851 (void) SyncImagesSettings(mogrify_info,*images);
7854 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7855 InheritException(exception,&(*images)->exception);
7861 if (LocaleCompare(
"append",option+1) == 0)
7866 (void) SyncImagesSettings(mogrify_info,*images);
7867 append_image=AppendImages(*images,*option ==
'-' ? MagickTrue :
7868 MagickFalse,exception);
7869 if (append_image == (Image *) NULL)
7874 *images=DestroyImageList(*images);
7875 *images=append_image;
7878 if (LocaleCompare(
"average",option+1) == 0)
7886 (void) SyncImagesSettings(mogrify_info,*images);
7887 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7889 if (average_image == (Image *) NULL)
7894 *images=DestroyImageList(*images);
7895 *images=average_image;
7902 if (LocaleCompare(
"channel",option+1) == 0)
7906 channel=DefaultChannels;
7909 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7912 if (LocaleCompare(
"clut",option+1) == 0)
7918 (void) SyncImagesSettings(mogrify_info,*images);
7919 image=RemoveFirstImageFromList(images);
7920 clut_image=RemoveFirstImageFromList(images);
7921 if (clut_image == (Image *) NULL)
7923 (void) ThrowMagickException(exception,GetMagickModule(),
7924 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7925 image=DestroyImage(image);
7929 (void) ClutImageChannel(image,channel,clut_image);
7930 clut_image=DestroyImage(clut_image);
7931 InheritException(exception,&image->exception);
7932 *images=DestroyImageList(*images);
7936 if (LocaleCompare(
"coalesce",option+1) == 0)
7941 (void) SyncImagesSettings(mogrify_info,*images);
7942 coalesce_image=CoalesceImages(*images,exception);
7943 if (coalesce_image == (Image *) NULL)
7948 *images=DestroyImageList(*images);
7949 *images=coalesce_image;
7952 if (LocaleCompare(
"combine",option+1) == 0)
7957 (void) SyncImagesSettings(mogrify_info,*images);
7958 combine_image=CombineImages(*images,channel,exception);
7959 if (combine_image == (Image *) NULL)
7964 *images=DestroyImageList(*images);
7965 *images=combine_image;
7968 if (LocaleCompare(
"compare",option+1) == 0)
7985 (void) SyncImagesSettings(mogrify_info,*images);
7986 image=RemoveFirstImageFromList(images);
7987 reconstruct_image=RemoveFirstImageFromList(images);
7988 if (reconstruct_image == (Image *) NULL)
7990 (void) ThrowMagickException(exception,GetMagickModule(),
7991 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7992 image=DestroyImage(image);
7996 metric=UndefinedMetric;
7997 option=GetImageOption(image_info,
"metric");
7998 if (option != (
const char *) NULL)
7999 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
8000 MagickFalse,option);
8001 difference_image=CompareImageChannels(image,reconstruct_image,
8002 channel,metric,&distortion,exception);
8003 if (difference_image == (Image *) NULL)
8005 reconstruct_image=DestroyImage(reconstruct_image);
8006 image=DestroyImage(image);
8007 if (*images != (Image *) NULL)
8008 *images=DestroyImageList(*images);
8009 *images=difference_image;
8012 if (LocaleCompare(
"complex",option+1) == 0)
8020 (void) SyncImageSettings(mogrify_info,*images);
8021 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
8022 MagickFalse,argv[i+1]);
8023 complex_images=ComplexImages(*images,op,exception);
8024 if (complex_images == (Image *) NULL)
8029 *images=DestroyImageList(*images);
8030 *images=complex_images;
8033 if (LocaleCompare(
"composite",option+1) == 0)
8043 (void) SyncImagesSettings(mogrify_info,*images);
8044 image=RemoveFirstImageFromList(images);
8045 composite_image=RemoveFirstImageFromList(images);
8046 if (composite_image == (Image *) NULL)
8048 (void) ThrowMagickException(exception,GetMagickModule(),
8049 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8050 image=DestroyImage(image);
8054 (void) TransformImage(&composite_image,(
char *) NULL,
8055 composite_image->geometry);
8056 SetGeometry(composite_image,&geometry);
8057 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
8058 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8060 mask_image=RemoveFirstImageFromList(images);
8061 if (mask_image != (Image *) NULL)
8063 if ((image->compose == DisplaceCompositeOp) ||
8064 (image->compose == DistortCompositeOp))
8069 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8071 mask_image=DestroyImage(mask_image);
8078 if (image->mask != (Image *) NULL)
8079 image->mask=DestroyImage(image->mask);
8080 image->mask=mask_image;
8081 (void) NegateImage(image->mask,MagickFalse);
8084 (void) CompositeImageChannel(image,channel,image->compose,
8085 composite_image,geometry.x,geometry.y);
8086 if (mask_image != (Image *) NULL)
8088 image->mask=DestroyImage(image->mask);
8089 mask_image=image->mask;
8091 composite_image=DestroyImage(composite_image);
8092 InheritException(exception,&image->exception);
8093 *images=DestroyImageList(*images);
8097 if (LocaleCompare(
"copy",option+1) == 0)
8111 (void) SyncImageSettings(mogrify_info,*images);
8112 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8113 offset.x=geometry.x;
8114 offset.y=geometry.y;
8115 source_image=(*images);
8116 if (source_image->next != (Image *) NULL)
8117 source_image=source_image->next;
8118 (
void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8120 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8128 if (LocaleCompare(
"deconstruct",option+1) == 0)
8133 (void) SyncImagesSettings(mogrify_info,*images);
8134 deconstruct_image=DeconstructImages(*images,exception);
8135 if (deconstruct_image == (Image *) NULL)
8140 *images=DestroyImageList(*images);
8141 *images=deconstruct_image;
8144 if (LocaleCompare(
"delete",option+1) == 0)
8147 DeleteImages(images,
"-1",exception);
8149 DeleteImages(images,argv[i+1],exception);
8152 if (LocaleCompare(
"dither",option+1) == 0)
8156 quantize_info->dither=MagickFalse;
8159 quantize_info->dither=MagickTrue;
8160 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8161 MagickDitherOptions,MagickFalse,argv[i+1]);
8164 if (LocaleCompare(
"duplicate",option+1) == 0)
8170 duplicate_images=DuplicateImages(*images,1,
"-1",exception);
8179 number_duplicates=(size_t) StringToLong(argv[i+1]);
8180 p=strchr(argv[i+1],
',');
8181 if (p == (
const char *) NULL)
8182 duplicate_images=DuplicateImages(*images,number_duplicates,
8185 duplicate_images=DuplicateImages(*images,number_duplicates,
8188 AppendImageToList(images, duplicate_images);
8189 (void) SyncImagesSettings(mogrify_info,*images);
8196 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
8201 MagickEvaluateOperator
8204 (void) SyncImageSettings(mogrify_info,*images);
8205 op=(MagickEvaluateOperator) ParseCommandOption(
8206 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8207 evaluate_image=EvaluateImages(*images,op,exception);
8208 if (evaluate_image == (Image *) NULL)
8213 *images=DestroyImageList(*images);
8214 *images=evaluate_image;
8221 if (LocaleCompare(
"fft",option+1) == 0)
8229 (void) SyncImageSettings(mogrify_info,*images);
8230 fourier_image=ForwardFourierTransformImage(*images,*option ==
'-' ?
8231 MagickTrue : MagickFalse,exception);
8232 if (fourier_image == (Image *) NULL)
8234 *images=DestroyImageList(*images);
8235 *images=fourier_image;
8238 if (LocaleCompare(
"flatten",option+1) == 0)
8243 (void) SyncImagesSettings(mogrify_info,*images);
8244 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8245 if (flatten_image == (Image *) NULL)
8247 *images=DestroyImageList(*images);
8248 *images=flatten_image;
8251 if (LocaleCompare(
"fx",option+1) == 0)
8256 (void) SyncImagesSettings(mogrify_info,*images);
8257 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
8258 if (fx_image == (Image *) NULL)
8263 *images=DestroyImageList(*images);
8271 if (LocaleCompare(
"hald-clut",option+1) == 0)
8277 (void) SyncImagesSettings(mogrify_info,*images);
8278 image=RemoveFirstImageFromList(images);
8279 hald_image=RemoveFirstImageFromList(images);
8280 if (hald_image == (Image *) NULL)
8282 (void) ThrowMagickException(exception,GetMagickModule(),
8283 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8284 image=DestroyImage(image);
8288 (void) HaldClutImageChannel(image,channel,hald_image);
8289 hald_image=DestroyImage(hald_image);
8290 InheritException(exception,&image->exception);
8291 if (*images != (Image *) NULL)
8292 *images=DestroyImageList(*images);
8300 if (LocaleCompare(
"ift",option+1) == 0)
8310 (void) SyncImagesSettings(mogrify_info,*images);
8311 magnitude_image=RemoveFirstImageFromList(images);
8312 phase_image=RemoveFirstImageFromList(images);
8313 if (phase_image == (Image *) NULL)
8315 (void) ThrowMagickException(exception,GetMagickModule(),
8316 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8317 magnitude_image=DestroyImage(magnitude_image);
8321 fourier_image=InverseFourierTransformImage(magnitude_image,
8322 phase_image,*option ==
'-' ? MagickTrue : MagickFalse,exception);
8323 magnitude_image=DestroyImage(magnitude_image);
8324 phase_image=DestroyImage(phase_image);
8325 if (fourier_image == (Image *) NULL)
8327 if (*images != (Image *) NULL)
8328 *images=DestroyImageList(*images);
8329 *images=fourier_image;
8332 if (LocaleCompare(
"insert",option+1) == 0)
8340 index=(ssize_t) StringToLong(argv[i+1]);
8341 p=RemoveLastImageFromList(images);
8342 if (p == (Image *) NULL)
8344 (void) ThrowMagickException(exception,GetMagickModule(),
8345 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8351 PrependImageToList(images,q);
8353 if (index == (ssize_t) GetImageListLength(*images))
8354 AppendImageToList(images,q);
8357 q=GetImageFromList(*images,index-1);
8358 if (q == (Image *) NULL)
8361 (void) ThrowMagickException(exception,GetMagickModule(),
8362 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8366 InsertImageInList(&q,p);
8368 *images=GetFirstImageInList(q);
8375 if (LocaleCompare(
"layers",option+1) == 0)
8383 (void) SyncImagesSettings(mogrify_info,*images);
8384 layers=(Image *) NULL;
8385 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
8386 MagickFalse,argv[i+1]);
8391 layers=CoalesceImages(*images,exception);
8394 case CompareAnyLayer:
8395 case CompareClearLayer:
8396 case CompareOverlayLayer:
8399 layers=CompareImageLayers(*images,method,exception);
8405 case TrimBoundsLayer:
8407 layers=MergeImageLayers(*images,method,exception);
8412 layers=DisposeImages(*images,exception);
8415 case OptimizeImageLayer:
8417 layers=OptimizeImageLayers(*images,exception);
8420 case OptimizePlusLayer:
8422 layers=OptimizePlusImageLayers(*images,exception);
8425 case OptimizeTransLayer:
8427 OptimizeImageTransparency(*images,exception);
8430 case RemoveDupsLayer:
8432 RemoveDuplicateLayers(images,exception);
8435 case RemoveZeroLayer:
8437 RemoveZeroDelayLayers(images,exception);
8445 layers=CoalesceImages(*images,exception);
8446 if (layers == (Image *) NULL)
8451 InheritException(exception,&layers->exception);
8452 *images=DestroyImageList(*images);
8454 layers=OptimizeImageLayers(*images,exception);
8455 if (layers == (Image *) NULL)
8460 InheritException(exception,&layers->exception);
8461 *images=DestroyImageList(*images);
8463 layers=(Image *) NULL;
8464 OptimizeImageTransparency(*images,exception);
8465 InheritException(exception,&(*images)->exception);
8466 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8469 case CompositeLayer:
8484 while (source != (Image *) NULL)
8486 source=GetNextImageInList(source);
8487 if ((source != (Image *) NULL) &&
8488 (LocaleCompare(source->magick,
"NULL") == 0))
8491 if (source != (Image *) NULL)
8493 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8494 (GetNextImageInList(source) == (Image *) NULL))
8495 source=(Image *) NULL;
8501 source=SplitImageList(source->previous);
8502 DeleteImageFromList(&source);
8505 if (source == (Image *) NULL)
8507 (void) ThrowMagickException(exception,GetMagickModule(),
8508 OptionError,
"MissingNullSeparator",
"layers Composite");
8515 SetGeometry(*images,&geometry);
8516 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8517 geometry.width=source->page.width != 0 ?
8518 source->page.width : source->columns;
8519 geometry.height=source->page.height != 0 ?
8520 source->page.height : source->rows;
8521 GravityAdjustGeometry((*images)->page.width != 0 ?
8522 (*images)->page.width : (*images)->columns,
8523 (*images)->page.height != 0 ? (*images)->page.height :
8524 (*images)->rows,(*images)->gravity,&geometry);
8525 compose=OverCompositeOp;
8526 option=GetImageOption(mogrify_info,
"compose");
8527 if (option != (
const char *) NULL)
8528 compose=(CompositeOperator) ParseCommandOption(
8529 MagickComposeOptions,MagickFalse,option);
8530 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8532 source=DestroyImageList(source);
8536 if (layers == (Image *) NULL)
8538 InheritException(exception,&layers->exception);
8539 *images=DestroyImageList(*images);
8547 if (LocaleCompare(
"map",option+1) == 0)
8549 (void) SyncImagesSettings(mogrify_info,*images);
8552 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8553 InheritException(exception,&(*images)->exception);
8559 if (LocaleCompare(
"maximum",option+1) == 0)
8567 (void) SyncImagesSettings(mogrify_info,*images);
8568 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8569 if (maximum_image == (Image *) NULL)
8574 *images=DestroyImageList(*images);
8575 *images=maximum_image;
8578 if (LocaleCompare(
"minimum",option+1) == 0)
8586 (void) SyncImagesSettings(mogrify_info,*images);
8587 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8588 if (minimum_image == (Image *) NULL)
8593 *images=DestroyImageList(*images);
8594 *images=minimum_image;
8597 if (LocaleCompare(
"morph",option+1) == 0)
8602 (void) SyncImagesSettings(mogrify_info,*images);
8603 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8605 if (morph_image == (Image *) NULL)
8610 *images=DestroyImageList(*images);
8611 *images=morph_image;
8614 if (LocaleCompare(
"mosaic",option+1) == 0)
8619 (void) SyncImagesSettings(mogrify_info,*images);
8620 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8621 if (mosaic_image == (Image *) NULL)
8626 *images=DestroyImageList(*images);
8627 *images=mosaic_image;
8634 if (LocaleCompare(
"poly",option+1) == 0)
8638 token[MaxTextExtent];
8658 (void) SyncImageSettings(mogrify_info,*images);
8659 args=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8660 InheritException(exception,&(*images)->exception);
8661 if (args == (
char *) NULL)
8664 for (x=0; *p !=
'\0'; x++)
8666 (void) GetNextToken(p,&p,MaxTextExtent,token);
8668 (void) GetNextToken(p,&p,MaxTextExtent,token);
8670 number_arguments=(size_t) x;
8671 arguments=(
double *) AcquireQuantumMemory(number_arguments,
8672 sizeof(*arguments));
8673 if (arguments == (
double *) NULL)
8674 ThrowWandFatalException(ResourceLimitFatalError,
8675 "MemoryAllocationFailed",(*images)->filename);
8676 (void) memset(arguments,0,number_arguments*
8677 sizeof(*arguments));
8679 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
8681 (void) GetNextToken(p,&p,MaxTextExtent,token);
8683 (void) GetNextToken(p,&p,MaxTextExtent,token);
8684 arguments[x]=StringToDouble(token,(
char **) NULL);
8686 args=DestroyString(args);
8687 polynomial_image=PolynomialImageChannel(*images,channel,
8688 number_arguments >> 1,arguments,exception);
8689 arguments=(
double *) RelinquishMagickMemory(arguments);
8690 if (polynomial_image == (Image *) NULL)
8695 *images=DestroyImageList(*images);
8696 *images=polynomial_image;
8699 if (LocaleCompare(
"print",option+1) == 0)
8704 (void) SyncImagesSettings(mogrify_info,*images);
8705 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8706 if (
string == (
char *) NULL)
8708 InheritException(exception,&(*images)->exception);
8709 (void) FormatLocaleFile(stdout,
"%s",
string);
8710 string=DestroyString(
string);
8712 if (LocaleCompare(
"process",option+1) == 0)
8721 (void) SyncImagesSettings(mogrify_info,*images);
8722 arguments=StringToArgv(argv[i+1],&number_arguments);
8723 if ((arguments == (
char **) NULL) || (number_arguments == 1))
8725 if ((argc > 1) && (strchr(arguments[1],
'=') != (
char *) NULL))
8748 length=strlen(argv[i+1]);
8749 token=(
char *) NULL;
8750 if (~length >= (MaxTextExtent-1))
8751 token=(
char *) AcquireQuantumMemory(length+MaxTextExtent,
8753 if (token == (
char *) NULL)
8756 arguments=argv[i+1];
8757 token_info=AcquireTokenInfo();
8758 status=Tokenizer(token_info,0,token,length,arguments,
"",
"=",
8759 "\"",
'\0',&breaker,&next,"e);
8760 token_info=DestroyTokenInfo(token_info);
8766 argv=(&(arguments[next]));
8767 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8770 token=DestroyString(token);
8773 (void) SubstituteString(&arguments[1],
"-",
"");
8774 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8775 number_arguments-2,(
const char **) arguments+2,exception);
8776 for (j=0; j < number_arguments; j++)
8777 arguments[j]=DestroyString(arguments[j]);
8778 arguments=(
char **) RelinquishMagickMemory(arguments);
8785 if (LocaleCompare(
"reverse",option+1) == 0)
8787 ReverseImageList(images);
8788 InheritException(exception,&(*images)->exception);
8795 if (LocaleCompare(
"smush",option+1) == 0)
8803 (void) SyncImagesSettings(mogrify_info,*images);
8804 offset=(ssize_t) StringToLong(argv[i+1]);
8805 smush_image=SmushImages(*images,*option ==
'-' ? MagickTrue :
8806 MagickFalse,offset,exception);
8807 if (smush_image == (Image *) NULL)
8812 *images=DestroyImageList(*images);
8813 *images=smush_image;
8816 if (LocaleCompare(
"swap",option+1) == 0)
8838 flags=ParseGeometry(argv[i+1],&geometry_info);
8839 index=(ssize_t) geometry_info.rho;
8840 if ((flags & SigmaValue) != 0)
8841 swap_index=(ssize_t) geometry_info.sigma;
8843 p=GetImageFromList(*images,index);
8844 q=GetImageFromList(*images,swap_index);
8845 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8847 (void) ThrowMagickException(exception,GetMagickModule(),
8848 OptionError,
"NoSuchImage",
"`%s'",(*images)->filename);
8854 u=CloneImage(p,0,0,MagickTrue,exception);
8855 if (u == (Image *) NULL)
8857 v=CloneImage(q,0,0,MagickTrue,exception);
8858 if (v == (Image *) NULL)
8863 ReplaceImageInList(&p,v);
8864 ReplaceImageInList(&q,u);
8865 *images=GetFirstImageInList(q);
8872 if (LocaleCompare(
"write",option+1) == 0)
8883 (void) SyncImagesSettings(mogrify_info,*images);
8884 (void) FormatLocaleString(key,MaxTextExtent,
"cache:%s",argv[i+1]);
8885 (void) DeleteImageRegistry(key);
8886 write_images=CloneImageList(*images,exception);
8887 write_info=CloneImageInfo(mogrify_info);
8888 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8889 write_info=DestroyImageInfo(write_info);
8890 write_images=DestroyImageList(write_images);
8900 quantize_info=DestroyQuantizeInfo(quantize_info);
8901 mogrify_info=DestroyImageInfo(mogrify_info);
8902 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8903 return(status != 0 ? MagickTrue : MagickFalse);
8943WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8944 const MagickBooleanType post,
const int argc,
const char **argv,
8945 Image **images,ExceptionInfo *exception)
8947#define MogrifyImageTag "Mogrify/Image"
8961 assert(image_info != (ImageInfo *) NULL);
8962 assert(image_info->signature == MagickCoreSignature);
8963 if (images == (Image **) NULL)
8964 return(MogrifyImage(image_info,argc,argv,images,exception));
8965 assert((*images)->previous == (Image *) NULL);
8966 assert((*images)->signature == MagickCoreSignature);
8967 if (IsEventLogging() != MagickFalse)
8968 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
8969 (*images)->filename);
8970 if ((argc <= 0) || (*argv == (
char *) NULL))
8972 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8976 (void) FormatLocaleFile(stderr,
"mogrify start %s %d (%s)\n",argv[0],argc,
8982 if (post == MagickFalse)
8983 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8988 n=GetImageListLength(*images);
8992 (void) FormatLocaleFile(stderr,
"mogrify %ld of %ld\n",(
long)
8993 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8995 status&=MogrifyImage(image_info,argc,argv,images,exception);
8996 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8997 if (proceed == MagickFalse)
8999 if ((*images)->next == (Image *) NULL)
9001 *images=(*images)->next;
9004 assert(*images != (Image *) NULL);
9006 (void) FormatLocaleFile(stderr,
"mogrify end %ld of %ld\n",(
long)
9007 GetImageIndexInList(*images),(long)GetImageListLength(*images));
9012 *images=GetFirstImageInList(*images);
9013 if (post != MagickFalse)
9014 status&=MogrifyImageList(image_info,argc,argv,images,exception);
9015 return(status != 0 ? MagickTrue : MagickFalse);