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";
118 WandExport 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);
343 static 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);
377 static inline MagickBooleanType IsPathWritable(
const char *path)
379 if (IsPathAccessible(path) == MagickFalse)
381 if (access_utf8(path,W_OK) != 0)
386 static 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);
425 static 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 );
657 WandExport 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*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*=(MagickRealType) (QuantumRange/100.0);
1989 white_point*=(MagickRealType) (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*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=QuantumRange*geometry_info.rho/100.0;
3343 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
3345 if ((flags & SigmaValue) == 0)
3346 geometry_info.sigma=0.0;
3347 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3348 geometry_info.sigma,exception);
3351 if (LocaleCompare(
"weight",option+1) == 0)
3356 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3359 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3360 draw_info->weight=(size_t) weight;
3363 if (LocaleCompare(
"white-threshold",option+1) == 0)
3368 (void) SyncImageSettings(mogrify_info,*image);
3369 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3371 InheritException(exception,&(*image)->exception);
3382 if (mogrify_image != (Image *) NULL)
3383 ReplaceImageInListReturnLast(image,mogrify_image);
3386 if (region_image != (Image *) NULL)
3391 (void) SyncImageSettings(mogrify_info,*image);
3392 (void) CompositeImage(region_image,region_image->matte != MagickFalse ?
3393 CopyCompositeOp : OverCompositeOp,*image,region_geometry.x,
3395 InheritException(exception,®ion_image->exception);
3396 *image=DestroyImage(*image);
3397 *image=region_image;
3398 region_image = (Image *) NULL;
3403 quantize_info=DestroyQuantizeInfo(quantize_info);
3404 draw_info=DestroyDrawInfo(draw_info);
3405 mogrify_info=DestroyImageInfo(mogrify_info);
3406 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3407 return(status == 0 ? MagickFalse : MagickTrue);
3444 static MagickBooleanType MogrifyUsage(
void)
3448 " -debug events display copious debugging information\n"
3449 " -distribute-cache port\n"
3450 " distributed pixel cache spanning one or more servers\n"
3451 " -help print program options\n"
3452 " -list type print a list of supported option arguments\n"
3453 " -log format format of debugging information\n"
3454 " -version print version information",
3456 " -adaptive-blur geometry\n"
3457 " adaptively blur pixels; decrease effect near edges\n"
3458 " -adaptive-resize geometry\n"
3459 " adaptively resize image using 'mesh' interpolation\n"
3460 " -adaptive-sharpen geometry\n"
3461 " adaptively sharpen pixels; increase effect near edges\n"
3462 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3463 " transparent, extract, background, or shape\n"
3464 " -annotate geometry text\n"
3465 " annotate the image with text\n"
3466 " -auto-gamma automagically adjust gamma level of image\n"
3467 " -auto-level automagically adjust color levels of image\n"
3468 " -auto-orient automagically orient (rotate) image\n"
3469 " -bench iterations measure performance\n"
3470 " -black-threshold value\n"
3471 " force all pixels below the threshold into black\n"
3472 " -blue-shift simulate a scene at nighttime in the moonlight\n"
3473 " -blur geometry reduce image noise and reduce detail levels\n"
3474 " -border geometry surround image with a border of color\n"
3475 " -bordercolor color border color\n"
3476 " -brightness-contrast geometry\n"
3477 " improve brightness / contrast of the image\n"
3478 " -canny geometry detect edges in the image\n"
3479 " -cdl filename color correct with a color decision list\n"
3480 " -charcoal radius simulate a charcoal drawing\n"
3481 " -chop geometry remove pixels from the image interior\n"
3482 " -clamp keep pixel values in range (0-QuantumRange)\n"
3483 " -clip clip along the first path from the 8BIM profile\n"
3484 " -clip-mask filename associate a clip mask with the image\n"
3485 " -clip-path id clip along a named path from the 8BIM profile\n"
3486 " -colorize value colorize the image with the fill color\n"
3487 " -color-matrix matrix apply color correction to the image\n"
3488 " -connected-components connectivity\n"
3489 " connected-components uniquely labeled\n"
3490 " -contrast enhance or reduce the image contrast\n"
3491 " -contrast-stretch geometry\n"
3492 " improve contrast by `stretching' the intensity range\n"
3493 " -convolve coefficients\n"
3494 " apply a convolution kernel to the image\n"
3495 " -cycle amount cycle the image colormap\n"
3496 " -decipher filename convert cipher pixels to plain pixels\n"
3497 " -deskew threshold straighten an image\n"
3498 " -despeckle reduce the speckles within an image\n"
3499 " -distort method args\n"
3500 " distort images according to given method ad args\n"
3501 " -draw string annotate the image with a graphic primitive\n"
3502 " -edge radius apply a filter to detect edges in the image\n"
3503 " -encipher filename convert plain pixels to cipher pixels\n"
3504 " -emboss radius emboss an image\n"
3505 " -enhance apply a digital filter to enhance a noisy image\n"
3506 " -equalize perform histogram equalization to an image\n"
3507 " -evaluate operator value\n"
3508 " evaluate an arithmetic, relational, or logical expression\n"
3509 " -extent geometry set the image size\n"
3510 " -extract geometry extract area from image\n"
3511 " -hough-lines geometry\n"
3512 " identify lines in the image\n"
3513 " -features distance analyze image features (e.g. contrast, correlation)\n"
3514 " -fft implements the discrete Fourier transform (DFT)\n"
3515 " -flip flip image vertically\n"
3516 " -floodfill geometry color\n"
3517 " floodfill the image with color\n"
3518 " -flop flop image horizontally\n"
3519 " -frame geometry surround image with an ornamental border\n"
3520 " -function name parameters\n"
3521 " apply function over image values\n"
3522 " -gamma value level of gamma correction\n"
3523 " -gaussian-blur geometry\n"
3524 " reduce image noise and reduce detail levels\n"
3525 " -geometry geometry preferred size or location of the image\n"
3526 " -grayscale method convert image to grayscale\n"
3527 " -help print program options\n"
3528 " -identify identify the format and characteristics of the image\n"
3529 " -ift implements the inverse discrete Fourier transform (DFT)\n"
3530 " -implode amount implode image pixels about the center\n"
3531 " -kuwahara geometry edge preserving noise reduction filter\n"
3532 " -lat geometry local adaptive thresholding\n"
3533 " -layers method optimize, merge, or compare image layers\n"
3534 " -level value adjust the level of image contrast\n"
3535 " -level-colors color,color\n"
3536 " level image with the given colors\n"
3537 " -linear-stretch geometry\n"
3538 " improve contrast by `stretching with saturation'\n"
3539 " -liquid-rescale geometry\n"
3540 " rescale image with seam-carving\n"
3541 " -local-contrast geometry\n"
3542 " enhance local contrast\n"
3543 " -magnify double the size of the image with pixel art scaling\n"
3544 " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3545 " -median geometry apply a median filter to the image\n"
3546 " -mode geometry make each pixel the 'predominant color' of the\n"
3548 " -modulate value vary the brightness, saturation, and hue\n"
3549 " -monochrome transform image to black and white\n"
3550 " -morphology method kernel\n"
3551 " apply a morphology method to the image\n"
3552 " -motion-blur geometry\n"
3553 " simulate motion blur\n"
3554 " -negate replace every pixel with its complementary color \n"
3555 " -noise geometry add or reduce noise in an image\n"
3556 " -normalize transform image to span the full range of colors\n"
3557 " -opaque color change this color to the fill color\n"
3558 " -ordered-dither NxN\n"
3559 " add a noise pattern to the image with specific\n"
3561 " -paint radius simulate an oil painting\n"
3562 " -perceptible epsilon\n"
3563 " pixel value less than |epsilon| become epsilon or\n"
3565 " -polaroid angle simulate a Polaroid picture\n"
3566 " -posterize levels reduce the image to a limited number of color levels\n"
3567 " -profile filename add, delete, or apply an image profile\n"
3568 " -quantize colorspace reduce colors in this colorspace\n"
3569 " -radial-blur angle radial blur the image\n"
3570 " -raise value lighten/darken image edges to create a 3-D effect\n"
3571 " -random-threshold low,high\n"
3572 " random threshold the image\n"
3573 " -region geometry apply options to a portion of the image\n"
3574 " -render render vector graphics\n"
3575 " -resample geometry change the resolution of an image\n"
3576 " -resize geometry resize the image\n"
3577 " -roll geometry roll an image vertically or horizontally\n"
3578 " -rotate degrees apply Paeth rotation to the image\n"
3579 " -sample geometry scale image with pixel sampling\n"
3580 " -scale geometry scale the image\n"
3581 " -segment values segment an image\n"
3582 " -selective-blur geometry\n"
3583 " selectively blur pixels within a contrast threshold\n"
3584 " -sepia-tone threshold\n"
3585 " simulate a sepia-toned photo\n"
3586 " -set property value set an image property\n"
3587 " -shade degrees shade the image using a distant light source\n"
3588 " -shadow geometry simulate an image shadow\n"
3589 " -sharpen geometry sharpen the image\n"
3590 " -shave geometry shave pixels from the image edges\n"
3591 " -shear geometry slide one edge of the image along the X or Y axis\n"
3592 " -sigmoidal-contrast geometry\n"
3593 " increase the contrast without saturating highlights or\n"
3595 " -sketch geometry simulate a pencil sketch\n"
3596 " -solarize threshold negate all pixels above the threshold level\n"
3597 " -sparse-color method args\n"
3598 " fill in a image based on a few color points\n"
3599 " -splice geometry splice the background color into the image\n"
3600 " -spread radius displace image pixels by a random amount\n"
3601 " -statistic type radius\n"
3602 " replace each pixel with corresponding statistic from the neighborhood\n"
3603 " -strip strip image of all profiles and comments\n"
3604 " -swirl degrees swirl image pixels about the center\n"
3605 " -threshold value threshold the image\n"
3606 " -thumbnail geometry create a thumbnail of the image\n"
3607 " -tile filename tile image when filling a graphic primitive\n"
3608 " -tint value tint the image with the fill color\n"
3609 " -transform affine transform image\n"
3610 " -transparent color make this color transparent within the image\n"
3611 " -transpose flip image vertically and rotate 90 degrees\n"
3612 " -transverse flop image horizontally and rotate 270 degrees\n"
3613 " -trim trim image edges\n"
3614 " -type type image type\n"
3615 " -unique-colors discard all but one of any pixel color\n"
3616 " -unsharp geometry sharpen the image\n"
3617 " -vignette geometry soften the edges of the image in vignette style\n"
3618 " -wave geometry alter an image along a sine wave\n"
3619 " -wavelet-denoise threshold\n"
3620 " removes noise from the image using a wavelet transform\n"
3621 " -white-threshold value\n"
3622 " force all pixels above the threshold into white",
3623 sequence_operators[] =
3624 " -affinity filename transform image colors to match this set of colors\n"
3625 " -append append an image sequence\n"
3626 " -clut apply a color lookup table to the image\n"
3627 " -coalesce merge a sequence of images\n"
3628 " -combine combine a sequence of images\n"
3629 " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3630 " -complex operator perform complex mathematics on an image sequence\n"
3631 " -composite composite image\n"
3632 " -copy geometry offset\n"
3633 " copy pixels from one area of an image to another\n"
3634 " -crop geometry cut out a rectangular region of the image\n"
3635 " -deconstruct break down an image sequence into constituent parts\n"
3636 " -evaluate-sequence operator\n"
3637 " evaluate an arithmetic, relational, or logical expression\n"
3638 " -flatten flatten a sequence of images\n"
3639 " -fx expression apply mathematical expression to an image channel(s)\n"
3640 " -hald-clut apply a Hald color lookup table to the image\n"
3641 " -layers method optimize, merge, or compare image layers\n"
3642 " -morph value morph an image sequence\n"
3643 " -mosaic create a mosaic from an image sequence\n"
3644 " -poly terms build a polynomial from the image sequence and the corresponding\n"
3645 " terms (coefficients and degree pairs).\n"
3646 " -print string interpret string and print to console\n"
3647 " -process arguments process the image with a custom image filter\n"
3648 " -separate separate an image channel into a grayscale image\n"
3649 " -smush geometry smush an image sequence together\n"
3650 " -write filename write images to this file",
3652 " -adjoin join images into a single multi-image file\n"
3653 " -affine matrix affine transform matrix\n"
3654 " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3655 " -antialias remove pixel-aliasing\n"
3656 " -authenticate password\n"
3657 " decipher image with this password\n"
3658 " -attenuate value lessen (or intensify) when adding noise to an image\n"
3659 " -background color background color\n"
3660 " -bias value add bias when convolving an image\n"
3661 " -black-point-compensation\n"
3662 " use black point compensation\n"
3663 " -blue-primary point chromaticity blue primary point\n"
3664 " -bordercolor color border color\n"
3665 " -caption string assign a caption to an image\n"
3666 " -cdl filename color correct with a color decision list\n"
3667 " -channel type apply option to select image channels\n"
3668 " -colors value preferred number of colors in the image\n"
3669 " -colorspace type alternate image colorspace\n"
3670 " -comment string annotate image with comment\n"
3671 " -compose operator set image composite operator\n"
3672 " -compress type type of pixel compression when writing the image\n"
3673 " -decipher filename convert cipher pixels to plain pixels\n"
3674 " -define format:option\n"
3675 " define one or more image format options\n"
3676 " -delay value display the next image after pausing\n"
3677 " -density geometry horizontal and vertical density of the image\n"
3678 " -depth value image depth\n"
3679 " -direction type render text right-to-left or left-to-right\n"
3680 " -display server get image or font from this X server\n"
3681 " -dispose method layer disposal method\n"
3682 " -dither method apply error diffusion to image\n"
3683 " -encipher filename convert plain pixels to cipher pixels\n"
3684 " -encoding type text encoding type\n"
3685 " -endian type endianness (MSB or LSB) of the image\n"
3686 " -family name render text with this font family\n"
3687 " -features distance analyze image features (e.g. contrast, correlation)\n"
3688 " -fill color color to use when filling a graphic primitive\n"
3689 " -filter type use this filter when resizing an image\n"
3690 " -flatten flatten a sequence of images\n"
3691 " -font name render text with this font\n"
3692 " -format \"string\" output formatted image characteristics\n"
3693 " -function name apply a function to the image\n"
3694 " -fuzz distance colors within this distance are considered equal\n"
3695 " -gravity type horizontal and vertical text placement\n"
3696 " -green-primary point chromaticity green primary point\n"
3697 " -intensity method method to generate intensity value from pixel\n"
3698 " -intent type type of rendering intent when managing the image color\n"
3699 " -interlace type type of image interlacing scheme\n"
3700 " -interline-spacing value\n"
3701 " set the space between two text lines\n"
3702 " -interpolate method pixel color interpolation method\n"
3703 " -interword-spacing value\n"
3704 " set the space between two words\n"
3705 " -kerning value set the space between two letters\n"
3706 " -label string assign a label to an image\n"
3707 " -limit type value pixel cache resource limit\n"
3708 " -loop iterations add Netscape loop extension to your GIF animation\n"
3709 " -mask filename associate a mask with the image\n"
3710 " -matte store matte channel if the image has one\n"
3711 " -mattecolor color frame color\n"
3712 " -monitor monitor progress\n"
3713 " -morphology method kernel\n"
3714 " apply a morphology method to the image\n"
3715 " -orient type image orientation\n"
3716 " -page geometry size and location of an image canvas (setting)\n"
3717 " -path path write images to this path on disk\n"
3718 " -ping efficiently determine image attributes\n"
3719 " -pointsize value font point size\n"
3720 " -precision value maximum number of significant digits to print\n"
3721 " -preview type image preview type\n"
3722 " -quality value JPEG/MIFF/PNG compression level\n"
3723 " -quiet suppress all warning messages\n"
3724 " -red-primary point chromaticity red primary point\n"
3725 " -regard-warnings pay attention to warning messages\n"
3726 " -remap filename transform image colors to match this set of colors\n"
3727 " -repage geometry size and location of an image canvas\n"
3728 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3729 " -sampling-factor geometry\n"
3730 " horizontal and vertical sampling factor\n"
3731 " -scene value image scene number\n"
3732 " -seed value seed a new sequence of pseudo-random numbers\n"
3733 " -size geometry width and height of image\n"
3734 " -stretch type render text with this font stretch\n"
3735 " -stroke color graphic primitive stroke color\n"
3736 " -strokewidth value graphic primitive stroke width\n"
3737 " -style type render text with this font style\n"
3738 " -synchronize synchronize image to storage device\n"
3739 " -taint declare the image as modified\n"
3740 " -texture filename name of texture to tile onto the image background\n"
3741 " -tile-offset geometry\n"
3743 " -treedepth value color tree depth\n"
3744 " -transparent-color color\n"
3745 " transparent color\n"
3746 " -undercolor color annotation bounding box color\n"
3747 " -units type the units of image resolution\n"
3748 " -verbose print detailed information about the image\n"
3749 " -view FlashPix viewing transforms\n"
3750 " -virtual-pixel method\n"
3751 " virtual pixel access method\n"
3752 " -weight type render text with this font weight\n"
3753 " -white-point point chromaticity white point",
3755 " -delete indexes delete the image from the image sequence\n"
3756 " -duplicate count,indexes\n"
3757 " duplicate an image one or more times\n"
3758 " -insert index insert last image into the image sequence\n"
3759 " -reverse reverse image sequence\n"
3760 " -swap indexes swap two images in the image sequence";
3762 ListMagickVersion(stdout);
3763 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
3765 (void) fprintf(stdout,
"\nImage Settings:\n");
3766 (void) fputs(settings,stdout);
3767 (void) fprintf(stdout,
"\nImage Operators:\n");
3768 (void) fputs(operators,stdout);
3769 (void) fprintf(stdout,
"\nImage Sequence Operators:\n");
3770 (void) fputs(sequence_operators,stdout);
3771 (void) fprintf(stdout,
"\nImage Stack Operators:\n");
3772 (void) fputs(stack_operators,stdout);
3773 (void) fprintf(stdout,
"\nMiscellaneous Options:\n");
3774 (void) fputs(miscellaneous,stdout);
3775 (void) fprintf(stdout,
3776 "\nBy default, the image format of `file' is determined by its magic\n");
3777 (void) fprintf(stdout,
3778 "number. To specify a particular image format, precede the filename\n");
3779 (void) fprintf(stdout,
3780 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3781 (void) fprintf(stdout,
3782 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3783 (void) fprintf(stdout,
"'-' for standard input or output.\n");
3787 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3788 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
3790 #define DestroyMogrify() \
3792 if (format != (char *) NULL) \
3793 format=DestroyString(format); \
3794 if (path != (char *) NULL) \
3795 path=DestroyString(path); \
3796 DestroyImageStack(); \
3797 for (i=0; i < (ssize_t) argc; i++) \
3798 argv[i]=DestroyString(argv[i]); \
3799 argv=(char **) RelinquishMagickMemory(argv); \
3801 #define ThrowMogrifyException(asperity,tag,option) \
3803 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3806 return(MagickFalse); \
3808 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3810 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3811 "InvalidArgument","`%s': %s",argument,option); \
3813 return(MagickFalse); \
3825 image_stack[MaxImageStackDepth+1];
3833 respect_parenthesis;
3845 wand_unreferenced(metadata);
3850 assert(image_info != (ImageInfo *) NULL);
3851 assert(image_info->signature == MagickCoreSignature);
3852 assert(exception != (ExceptionInfo *) NULL);
3853 if (IsEventLogging() != MagickFalse)
3854 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3858 if ((LocaleCompare(
"version",option+1) == 0) ||
3859 (LocaleCompare(
"-version",option+1) == 0))
3861 ListMagickVersion(stdout);
3866 return(MogrifyUsage());
3867 format=(
char *) NULL;
3869 global_colormap=MagickFalse;
3873 option=(
char *) NULL;
3875 respect_parenthesis=MagickFalse;
3880 ReadCommandlLine(argc,&argv);
3881 status=ExpandFilenames(&argc,&argv);
3882 if (status == MagickFalse)
3883 ThrowMogrifyException(ResourceLimitError,
"MemoryAllocationFailed",
3884 GetExceptionMessage(errno));
3885 for (i=1; i < (ssize_t) argc; i++)
3888 if (LocaleCompare(option,
"(") == 0)
3890 FireImageStack(MagickFalse,MagickTrue,pend);
3891 if (k == MaxImageStackDepth)
3892 ThrowMogrifyException(OptionError,
"ParenthesisNestedTooDeeply",
3897 if (LocaleCompare(option,
")") == 0)
3899 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3901 ThrowMogrifyException(OptionError,
"UnableToParseExpression",option);
3905 if (IsCommandOption(option) == MagickFalse)
3908 backup_filename[MaxTextExtent],
3910 magic[MagickPathExtent];
3921 FireImageStack(MagickFalse,MagickFalse,pend);
3923 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
3925 (void) SetImageOption(image_info,
"filename",filename);
3926 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3927 images=ReadImages(image_info,exception);
3928 status&=(images != (Image *) NULL) &&
3929 (exception->severity < ErrorException);
3930 if (images == (Image *) NULL)
3932 properties=(*GetBlobProperties(images));
3933 if (format != (
char *) NULL)
3934 GetPathComponent(images->magick_filename,BasePathSansCompressExtension,
3936 if (path != (
char *) NULL)
3938 GetPathComponent(option,TailPath,filename);
3939 (void) FormatLocaleString(images->filename,MaxTextExtent,
"%s%c%s",
3940 path,*DirectorySeparator,filename);
3942 if (format != (
char *) NULL)
3943 AppendImageFormat(format,images->filename);
3944 AppendImageStack(images);
3945 FinalizeImageSettings(image_info,image,MagickFalse);
3946 if (image == (Image *) NULL)
3948 if (global_colormap != MagickFalse)
3953 quantize_info=AcquireQuantizeInfo(image_info);
3954 (void) RemapImages(quantize_info,images,(Image *) NULL);
3955 quantize_info=DestroyQuantizeInfo(quantize_info);
3957 *backup_filename=
'\0';
3959 GetPathComponent(filename,MagickPath,magic);
3963 filename[MagickPathExtent];
3965 if (format != (
char *) NULL)
3966 (void) CopyMagickString(magic,format,MagickPathExtent);
3967 (void) FormatLocaleString(filename,MagickPathExtent,
"%s:%s",magic,
3969 (void) CopyMagickString(image->filename,filename,MagickPathExtent);
3971 if ((LocaleCompare(image->filename,
"-") != 0) &&
3972 (IsPathWritable(image->filename) != MagickFalse))
3980 (void) CopyMagickString(backup_filename,image->filename,
3982 for (i=0; i < 6; i++)
3984 (void) ConcatenateMagickString(backup_filename,
"~",MaxTextExtent);
3985 if (IsPathAccessible(backup_filename) == MagickFalse)
3988 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3989 (rename_utf8(image->filename,backup_filename) != 0))
3990 *backup_filename=
'\0';
3995 image_info->synchronize=MagickTrue;
3996 status&=WriteImages(image_info,image,image->filename,exception);
3997 if (status != MagickFalse)
3999 #if defined(MAGICKCORE_HAVE_UTIME)
4004 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
4005 "preserve-timestamp"));
4006 if (preserve_timestamp != MagickFalse)
4011 timestamp.actime=properties.st_atime;
4012 timestamp.modtime=properties.st_mtime;
4013 (void) utime(image->filename,×tamp);
4017 if (*backup_filename !=
'\0')
4018 (void) remove_utf8(backup_filename);
4021 if (*backup_filename !=
'\0')
4022 (void) rename_utf8(backup_filename,image->filename);
4023 RemoveAllImageStack();
4026 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4027 switch (*(option+1))
4031 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
4034 if (i == (ssize_t) argc)
4035 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4036 if (IsGeometry(argv[i]) == MagickFalse)
4037 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4040 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
4043 if (i == (ssize_t) argc)
4044 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4045 if (IsGeometry(argv[i]) == MagickFalse)
4046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4049 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
4052 if (i == (ssize_t) argc)
4053 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4054 if (IsGeometry(argv[i]) == MagickFalse)
4055 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4058 if (LocaleCompare(
"affine",option+1) == 0)
4063 if (i == (ssize_t) argc)
4064 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4065 if (IsGeometry(argv[i]) == MagickFalse)
4066 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4069 if (LocaleCompare(
"alpha",option+1) == 0)
4077 if (i == (ssize_t) argc)
4078 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4079 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
4081 ThrowMogrifyException(OptionError,
"UnrecognizedAlphaChannelType",
4085 if (LocaleCompare(
"annotate",option+1) == 0)
4090 if (i == (ssize_t) argc)
4091 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4092 if (IsGeometry(argv[i]) == MagickFalse)
4093 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4094 if (i == (ssize_t) argc)
4095 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4099 if (LocaleCompare(
"antialias",option+1) == 0)
4101 if (LocaleCompare(
"append",option+1) == 0)
4103 if (LocaleCompare(
"attenuate",option+1) == 0)
4108 if (i == (ssize_t) argc)
4109 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4110 if (IsGeometry(argv[i]) == MagickFalse)
4111 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4114 if (LocaleCompare(
"authenticate",option+1) == 0)
4119 if (i == (ssize_t) argc)
4120 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4123 if (LocaleCompare(
"auto-gamma",option+1) == 0)
4125 if (LocaleCompare(
"auto-level",option+1) == 0)
4127 if (LocaleCompare(
"auto-orient",option+1) == 0)
4129 if (LocaleCompare(
"average",option+1) == 0)
4131 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4135 if (LocaleCompare(
"background",option+1) == 0)
4140 if (i == (ssize_t) argc)
4141 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4144 if (LocaleCompare(
"bias",option+1) == 0)
4149 if (i == (ssize_t) argc)
4150 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4151 if (IsGeometry(argv[i]) == MagickFalse)
4152 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4155 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
4157 if (LocaleCompare(
"black-threshold",option+1) == 0)
4162 if (i == (ssize_t) argc)
4163 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4164 if (IsGeometry(argv[i]) == MagickFalse)
4165 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4168 if (LocaleCompare(
"blue-primary",option+1) == 0)
4173 if (i == (ssize_t) argc)
4174 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4175 if (IsGeometry(argv[i]) == MagickFalse)
4176 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4179 if (LocaleCompare(
"blue-shift",option+1) == 0)
4182 if (i == (ssize_t) argc)
4183 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4184 if (IsGeometry(argv[i]) == MagickFalse)
4185 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4188 if (LocaleCompare(
"blur",option+1) == 0)
4191 if (i == (ssize_t) argc)
4192 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4193 if (IsGeometry(argv[i]) == MagickFalse)
4194 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4197 if (LocaleCompare(
"border",option+1) == 0)
4202 if (i == (ssize_t) argc)
4203 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4204 if (IsGeometry(argv[i]) == MagickFalse)
4205 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4208 if (LocaleCompare(
"bordercolor",option+1) == 0)
4213 if (i == (ssize_t) argc)
4214 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4217 if (LocaleCompare(
"box",option+1) == 0)
4222 if (i == (ssize_t) argc)
4223 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4226 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
4229 if (i == (ssize_t) argc)
4230 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4231 if (IsGeometry(argv[i]) == MagickFalse)
4232 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4235 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4239 if (LocaleCompare(
"cache",option+1) == 0)
4244 if (i == (ssize_t) argc)
4245 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4246 if (IsGeometry(argv[i]) == MagickFalse)
4247 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4250 if (LocaleCompare(
"canny",option+1) == 0)
4255 if (i == (ssize_t) argc)
4256 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4257 if (IsGeometry(argv[i]) == MagickFalse)
4258 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4261 if (LocaleCompare(
"caption",option+1) == 0)
4266 if (i == (ssize_t) argc)
4267 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4270 if (LocaleCompare(
"channel",option+1) == 0)
4278 if (i == (ssize_t) argc)
4279 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4280 channel=ParseChannelOption(argv[i]);
4282 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4286 if (LocaleCompare(
"cdl",option+1) == 0)
4291 if (i == (ssize_t) argc)
4292 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4295 if (LocaleCompare(
"charcoal",option+1) == 0)
4300 if (i == (ssize_t) argc)
4301 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4302 if (IsGeometry(argv[i]) == MagickFalse)
4303 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4306 if (LocaleCompare(
"chop",option+1) == 0)
4311 if (i == (ssize_t) argc)
4312 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4313 if (IsGeometry(argv[i]) == MagickFalse)
4314 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4317 if (LocaleCompare(
"clamp",option+1) == 0)
4319 if (LocaleCompare(
"clip",option+1) == 0)
4321 if (LocaleCompare(
"clip-mask",option+1) == 0)
4326 if (i == (ssize_t) argc)
4327 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4330 if (LocaleCompare(
"clut",option+1) == 0)
4332 if (LocaleCompare(
"coalesce",option+1) == 0)
4334 if (LocaleCompare(
"colorize",option+1) == 0)
4339 if (i == (ssize_t) argc)
4340 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4341 if (IsGeometry(argv[i]) == MagickFalse)
4342 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4345 if (LocaleCompare(
"color-matrix",option+1) == 0)
4353 if (i == (ssize_t) argc)
4354 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4355 kernel_info=AcquireKernelInfo(argv[i]);
4356 if (kernel_info == (KernelInfo *) NULL)
4357 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4358 kernel_info=DestroyKernelInfo(kernel_info);
4361 if (LocaleCompare(
"colors",option+1) == 0)
4366 if (i == (ssize_t) argc)
4367 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4368 if (IsGeometry(argv[i]) == MagickFalse)
4369 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4372 if (LocaleCompare(
"colorspace",option+1) == 0)
4380 if (i == (ssize_t) argc)
4381 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4382 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4385 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4389 if (LocaleCompare(
"combine",option+1) == 0)
4394 if (i == (ssize_t) argc)
4395 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4398 if (LocaleCompare(
"comment",option+1) == 0)
4403 if (i == (ssize_t) argc)
4404 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4407 if (LocaleCompare(
"compare",option+1) == 0)
4409 if (LocaleCompare(
"complex",option+1) == 0)
4417 if (i == (ssize_t) argc)
4418 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4419 op=ParseCommandOption(MagickComplexOptions,MagickFalse,argv[i]);
4421 ThrowMogrifyException(OptionError,
"UnrecognizedComplexOperator",
4425 if (LocaleCompare(
"compose",option+1) == 0)
4433 if (i == (ssize_t) argc)
4434 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4435 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4438 ThrowMogrifyException(OptionError,
"UnrecognizedComposeOperator",
4442 if (LocaleCompare(
"composite",option+1) == 0)
4444 if (LocaleCompare(
"compress",option+1) == 0)
4452 if (i == (ssize_t) argc)
4453 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4454 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4457 ThrowMogrifyException(OptionError,
"UnrecognizedImageCompression",
4461 if (LocaleCompare(
"concurrent",option+1) == 0)
4463 if (LocaleCompare(
"connected-components",option+1) == 0)
4466 if (i == (ssize_t) argc)
4467 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4468 if (IsGeometry(argv[i]) == MagickFalse)
4469 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4472 if (LocaleCompare(
"contrast",option+1) == 0)
4474 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
4477 if (i == (ssize_t) argc)
4478 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4479 if (IsGeometry(argv[i]) == MagickFalse)
4480 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4483 if (LocaleCompare(
"convolve",option+1) == 0)
4491 if (i == (ssize_t) argc)
4492 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4493 kernel_info=AcquireKernelInfo(argv[i]);
4494 if (kernel_info == (KernelInfo *) NULL)
4495 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4496 kernel_info=DestroyKernelInfo(kernel_info);
4499 if (LocaleCompare(
"copy",option+1) == 0)
4504 if (i == (ssize_t) argc)
4505 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4506 if (IsGeometry(argv[i]) == MagickFalse)
4507 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4509 if (i == (ssize_t) argc)
4510 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4511 if (IsGeometry(argv[i]) == MagickFalse)
4512 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4515 if (LocaleCompare(
"crop",option+1) == 0)
4520 if (i == (ssize_t) argc)
4521 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4522 if (IsGeometry(argv[i]) == MagickFalse)
4523 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4526 if (LocaleCompare(
"cycle",option+1) == 0)
4531 if (i == (ssize_t) argc)
4532 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4533 if (IsGeometry(argv[i]) == MagickFalse)
4534 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4537 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4541 if (LocaleCompare(
"decipher",option+1) == 0)
4546 if (i == (ssize_t) argc)
4547 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4550 if (LocaleCompare(
"deconstruct",option+1) == 0)
4552 if (LocaleCompare(
"debug",option+1) == 0)
4560 if (i == (ssize_t) argc)
4561 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4562 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4564 ThrowMogrifyException(OptionError,
"UnrecognizedEventType",
4566 (void) SetLogEventMask(argv[i]);
4569 if (LocaleCompare(
"define",option+1) == 0)
4572 if (i == (ssize_t) argc)
4573 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4579 define=GetImageOption(image_info,argv[i]);
4580 if (define == (
const char *) NULL)
4581 ThrowMogrifyException(OptionError,
"NoSuchOption",argv[i]);
4586 if (LocaleCompare(
"delay",option+1) == 0)
4591 if (i == (ssize_t) argc)
4592 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4593 if (IsGeometry(argv[i]) == MagickFalse)
4594 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4597 if (LocaleCompare(
"delete",option+1) == 0)
4602 if (i == (ssize_t) argc)
4603 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4604 if (LocaleNCompare(argv[i],
"registry:",9) == 0)
4606 (void) DeleteImageRegistry(argv[i]+9);
4609 if (IsGeometry(argv[i]) == MagickFalse)
4610 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4613 if (LocaleCompare(
"density",option+1) == 0)
4618 if (i == (ssize_t) argc)
4619 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4620 if (IsGeometry(argv[i]) == MagickFalse)
4621 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4624 if (LocaleCompare(
"depth",option+1) == 0)
4629 if (i == (ssize_t) argc)
4630 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4631 if (IsGeometry(argv[i]) == MagickFalse)
4632 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4635 if (LocaleCompare(
"deskew",option+1) == 0)
4640 if (i == (ssize_t) argc)
4641 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4642 if (IsGeometry(argv[i]) == MagickFalse)
4643 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4646 if (LocaleCompare(
"despeckle",option+1) == 0)
4648 if (LocaleCompare(
"dft",option+1) == 0)
4650 if (LocaleCompare(
"direction",option+1) == 0)
4658 if (i == (ssize_t) argc)
4659 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4660 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4663 ThrowMogrifyException(OptionError,
"UnrecognizedDirectionType",
4667 if (LocaleCompare(
"display",option+1) == 0)
4672 if (i == (ssize_t) argc)
4673 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4676 if (LocaleCompare(
"dispose",option+1) == 0)
4684 if (i == (ssize_t) argc)
4685 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4686 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4689 ThrowMogrifyException(OptionError,
"UnrecognizedDisposeMethod",
4693 if (LocaleCompare(
"distort",option+1) == 0)
4699 if (i == (ssize_t) argc)
4700 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4701 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4703 ThrowMogrifyException(OptionError,
"UnrecognizedDistortMethod",
4706 if (i == (ssize_t) argc)
4707 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4710 if (LocaleCompare(
"dither",option+1) == 0)
4718 if (i == (ssize_t) argc)
4719 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4720 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4722 ThrowMogrifyException(OptionError,
"UnrecognizedDitherMethod",
4726 if (LocaleCompare(
"draw",option+1) == 0)
4731 if (i == (ssize_t) argc)
4732 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4735 if (LocaleCompare(
"duplicate",option+1) == 0)
4740 if (i == (ssize_t) argc)
4741 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4742 if (IsGeometry(argv[i]) == MagickFalse)
4743 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4746 if (LocaleCompare(
"duration",option+1) == 0)
4751 if (i == (ssize_t) argc)
4752 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4753 if (IsGeometry(argv[i]) == MagickFalse)
4754 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4757 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4761 if (LocaleCompare(
"edge",option+1) == 0)
4766 if (i == (ssize_t) argc)
4767 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4768 if (IsGeometry(argv[i]) == MagickFalse)
4769 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4772 if (LocaleCompare(
"emboss",option+1) == 0)
4777 if (i == (ssize_t) argc)
4778 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4779 if (IsGeometry(argv[i]) == MagickFalse)
4780 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4783 if (LocaleCompare(
"encipher",option+1) == 0)
4788 if (i == (ssize_t) argc)
4789 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4792 if (LocaleCompare(
"encoding",option+1) == 0)
4797 if (i == (ssize_t) argc)
4798 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4801 if (LocaleCompare(
"endian",option+1) == 0)
4809 if (i == (ssize_t) argc)
4810 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4811 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4813 ThrowMogrifyException(OptionError,
"UnrecognizedEndianType",
4817 if (LocaleCompare(
"enhance",option+1) == 0)
4819 if (LocaleCompare(
"equalize",option+1) == 0)
4821 if (LocaleCompare(
"evaluate",option+1) == 0)
4829 if (i == (ssize_t) argc)
4830 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4831 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4833 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4836 if (i == (ssize_t) argc)
4837 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4838 if (IsGeometry(argv[i]) == MagickFalse)
4839 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4842 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4850 if (i == (ssize_t) argc)
4851 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4852 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4854 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4858 if (LocaleCompare(
"extent",option+1) == 0)
4863 if (i == (ssize_t) argc)
4864 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4865 if (IsGeometry(argv[i]) == MagickFalse)
4866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4869 if (LocaleCompare(
"extract",option+1) == 0)
4874 if (i == (ssize_t) argc)
4875 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4876 if (IsGeometry(argv[i]) == MagickFalse)
4877 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4880 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4884 if (LocaleCompare(
"family",option+1) == 0)
4889 if (i == (ssize_t) argc)
4890 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4893 if (LocaleCompare(
"features",option+1) == 0)
4898 if (i == (ssize_t) argc)
4899 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4900 if (IsGeometry(argv[i]) == MagickFalse)
4901 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4904 if (LocaleCompare(
"fill",option+1) == 0)
4909 if (i == (ssize_t) argc)
4910 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4913 if (LocaleCompare(
"filter",option+1) == 0)
4921 if (i == (ssize_t) argc)
4922 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4923 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4925 ThrowMogrifyException(OptionError,
"UnrecognizedImageFilter",
4929 if (LocaleCompare(
"flatten",option+1) == 0)
4931 if (LocaleCompare(
"flip",option+1) == 0)
4933 if (LocaleCompare(
"flop",option+1) == 0)
4935 if (LocaleCompare(
"floodfill",option+1) == 0)
4940 if (i == (ssize_t) argc)
4941 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4942 if (IsGeometry(argv[i]) == MagickFalse)
4943 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4945 if (i == (ssize_t) argc)
4946 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4949 if (LocaleCompare(
"font",option+1) == 0)
4954 if (i == (ssize_t) argc)
4955 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4958 if (LocaleCompare(
"format",option+1) == 0)
4960 (void) CopyMagickString(argv[i]+1,
"sans",MaxTextExtent);
4961 (void) CloneString(&format,(
char *) NULL);
4965 if (i == (ssize_t) argc)
4966 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4967 (void) CloneString(&format,argv[i]);
4968 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4969 (void) ConcatenateMagickString(image_info->filename,
":",
4971 (void) SetImageInfo(image_info,0,exception);
4972 if (*image_info->magick ==
'\0')
4973 ThrowMogrifyException(OptionError,
"UnrecognizedImageFormat",
4977 if (LocaleCompare(
"frame",option+1) == 0)
4982 if (i == (ssize_t) argc)
4983 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4984 if (IsGeometry(argv[i]) == MagickFalse)
4985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4988 if (LocaleCompare(
"function",option+1) == 0)
4996 if (i == (ssize_t) argc)
4997 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4998 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
5000 ThrowMogrifyException(OptionError,
"UnrecognizedFunction",argv[i]);
5002 if (i == (ssize_t) argc)
5003 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5006 if (LocaleCompare(
"fuzz",option+1) == 0)
5011 if (i == (ssize_t) argc)
5012 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5013 if (IsGeometry(argv[i]) == MagickFalse)
5014 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5017 if (LocaleCompare(
"fx",option+1) == 0)
5022 if (i == (ssize_t) argc)
5023 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5026 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5030 if (LocaleCompare(
"gamma",option+1) == 0)
5033 if (i == (ssize_t) argc)
5034 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5035 if (IsGeometry(argv[i]) == MagickFalse)
5036 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5039 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
5040 (LocaleCompare(
"gaussian",option+1) == 0))
5043 if (i == (ssize_t) argc)
5044 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5045 if (IsGeometry(argv[i]) == MagickFalse)
5046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5049 if (LocaleCompare(
"geometry",option+1) == 0)
5054 if (i == (ssize_t) argc)
5055 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5056 if (IsGeometry(argv[i]) == MagickFalse)
5057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5060 if (LocaleCompare(
"gravity",option+1) == 0)
5068 if (i == (ssize_t) argc)
5069 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5070 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5073 ThrowMogrifyException(OptionError,
"UnrecognizedGravityType",
5077 if (LocaleCompare(
"grayscale",option+1) == 0)
5085 if (i == (ssize_t) argc)
5086 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5087 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5090 ThrowMogrifyException(OptionError,
"UnrecognizedIntensityMethod",
5094 if (LocaleCompare(
"green-primary",option+1) == 0)
5099 if (i == (ssize_t) argc)
5100 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5101 if (IsGeometry(argv[i]) == MagickFalse)
5102 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5105 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5109 if (LocaleCompare(
"hald-clut",option+1) == 0)
5111 if (LocaleCompare(
"hough-lines",option+1) == 0)
5116 if (i == (ssize_t) argc)
5117 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5118 if (IsGeometry(argv[i]) == MagickFalse)
5119 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5122 if ((LocaleCompare(
"help",option+1) == 0) ||
5123 (LocaleCompare(
"-help",option+1) == 0))
5126 return(MogrifyUsage());
5128 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5132 if (LocaleCompare(
"identify",option+1) == 0)
5134 if (LocaleCompare(
"idft",option+1) == 0)
5136 if (LocaleCompare(
"implode",option+1) == 0)
5141 if (i == (ssize_t) argc)
5142 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5143 if (IsGeometry(argv[i]) == MagickFalse)
5144 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5147 if (LocaleCompare(
"intensity",option+1) == 0)
5155 if (i == (ssize_t) argc)
5156 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5157 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5158 MagickFalse,argv[i]);
5160 ThrowMogrifyException(OptionError,
5161 "UnrecognizedPixelIntensityMethod",argv[i]);
5164 if (LocaleCompare(
"intent",option+1) == 0)
5172 if (i == (ssize_t) argc)
5173 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5174 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5176 ThrowMogrifyException(OptionError,
"UnrecognizedIntentType",
5180 if (LocaleCompare(
"interlace",option+1) == 0)
5188 if (i == (ssize_t) argc)
5189 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5190 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5193 ThrowMogrifyException(OptionError,
"UnrecognizedInterlaceType",
5197 if (LocaleCompare(
"interline-spacing",option+1) == 0)
5202 if (i == (ssize_t) argc)
5203 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5204 if (IsGeometry(argv[i]) == MagickFalse)
5205 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5208 if (LocaleCompare(
"interpolate",option+1) == 0)
5216 if (i == (ssize_t) argc)
5217 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5218 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5220 if (interpolate < 0)
5221 ThrowMogrifyException(OptionError,
"UnrecognizedInterpolateMethod",
5225 if (LocaleCompare(
"interword-spacing",option+1) == 0)
5230 if (i == (ssize_t) argc)
5231 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5232 if (IsGeometry(argv[i]) == MagickFalse)
5233 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5236 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5240 if (LocaleCompare(
"kerning",option+1) == 0)
5245 if (i == (ssize_t) argc)
5246 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5247 if (IsGeometry(argv[i]) == MagickFalse)
5248 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5251 if (LocaleCompare(
"kuwahara",option+1) == 0)
5254 if (i == (ssize_t) argc)
5255 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5256 if (IsGeometry(argv[i]) == MagickFalse)
5257 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5260 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5264 if (LocaleCompare(
"label",option+1) == 0)
5269 if (i == (ssize_t) argc)
5270 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5273 if (LocaleCompare(
"lat",option+1) == 0)
5278 if (i == (ssize_t) argc)
5279 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5280 if (IsGeometry(argv[i]) == MagickFalse)
5281 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5284 if (LocaleCompare(
"layers",option+1) == 0)
5292 if (i == (ssize_t) argc)
5293 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5294 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5296 ThrowMogrifyException(OptionError,
"UnrecognizedLayerMethod",
5300 if (LocaleCompare(
"level",option+1) == 0)
5303 if (i == (ssize_t) argc)
5304 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5305 if (IsGeometry(argv[i]) == MagickFalse)
5306 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5309 if (LocaleCompare(
"level-colors",option+1) == 0)
5312 if (i == (ssize_t) argc)
5313 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5316 if (LocaleCompare(
"linewidth",option+1) == 0)
5321 if (i == (ssize_t) argc)
5322 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5323 if (IsGeometry(argv[i]) == MagickFalse)
5324 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5327 if (LocaleCompare(
"limit",option+1) == 0)
5341 if (i == (ssize_t) argc)
5342 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5343 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5346 ThrowMogrifyException(OptionError,
"UnrecognizedResourceType",
5349 if (i == (ssize_t) argc)
5350 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5351 value=StringToDouble(argv[i],&p);
5353 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
5354 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5357 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
5360 if (i == (ssize_t) argc)
5361 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5362 if (IsGeometry(argv[i]) == MagickFalse)
5363 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5366 if (LocaleCompare(
"list",option+1) == 0)
5374 if (i == (ssize_t) argc)
5375 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5376 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5378 ThrowMogrifyException(OptionError,
"UnrecognizedListType",argv[i]);
5379 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
5381 return(status == 0 ? MagickFalse : MagickTrue);
5383 if (LocaleCompare(
"local-contrast",option+1) == 0)
5386 if (i == (ssize_t) argc)
5387 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5388 if (IsGeometry(argv[i]) == MagickFalse)
5389 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5392 if (LocaleCompare(
"log",option+1) == 0)
5397 if ((i == (ssize_t) argc) ||
5398 (strchr(argv[i],
'%') == (
char *) NULL))
5399 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5402 if (LocaleCompare(
"loop",option+1) == 0)
5407 if (i == (ssize_t) argc)
5408 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5409 if (IsGeometry(argv[i]) == MagickFalse)
5410 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5413 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5417 if (LocaleCompare(
"magnify",option+1) == 0)
5419 if (LocaleCompare(
"map",option+1) == 0)
5421 global_colormap=(*option ==
'+') ? MagickTrue : MagickFalse;
5425 if (i == (ssize_t) argc)
5426 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5429 if (LocaleCompare(
"mask",option+1) == 0)
5434 if (i == (ssize_t) argc)
5435 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5438 if (LocaleCompare(
"matte",option+1) == 0)
5440 if (LocaleCompare(
"mattecolor",option+1) == 0)
5445 if (i == (ssize_t) argc)
5446 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5449 if (LocaleCompare(
"metric",option+1) == 0)
5457 if (i == (ssize_t) argc)
5458 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5459 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5461 ThrowMogrifyException(OptionError,
"UnrecognizedMetricType",
5465 if (LocaleCompare(
"maximum",option+1) == 0)
5467 if (LocaleCompare(
"mean-shift",option+1) == 0)
5472 if (i == (ssize_t) argc)
5473 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5474 if (IsGeometry(argv[i]) == MagickFalse)
5475 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5478 if (LocaleCompare(
"median",option+1) == 0)
5483 if (i == (ssize_t) argc)
5484 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5485 if (IsGeometry(argv[i]) == MagickFalse)
5486 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5489 if (LocaleCompare(
"minimum",option+1) == 0)
5491 if (LocaleCompare(
"modulate",option+1) == 0)
5496 if (i == (ssize_t) argc)
5497 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5498 if (IsGeometry(argv[i]) == MagickFalse)
5499 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5502 if (LocaleCompare(
"mode",option+1) == 0)
5507 if (i == (ssize_t) argc)
5508 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5509 if (IsGeometry(argv[i]) == MagickFalse)
5510 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5513 if (LocaleCompare(
"monitor",option+1) == 0)
5515 if (LocaleCompare(
"monochrome",option+1) == 0)
5517 if (LocaleCompare(
"morph",option+1) == 0)
5522 if (i == (ssize_t) argc)
5523 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5524 if (IsGeometry(argv[i]) == MagickFalse)
5525 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5528 if (LocaleCompare(
"morphology",option+1) == 0)
5531 token[MaxTextExtent];
5540 if (i == (ssize_t) argc)
5541 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5542 (void) GetNextToken(argv[i],(
const char **) NULL,MaxTextExtent,token);
5543 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5545 ThrowMogrifyException(OptionError,
"UnrecognizedMorphologyMethod",
5548 if (i == (ssize_t) argc)
5549 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5550 kernel_info=AcquireKernelInfo(argv[i]);
5551 if (kernel_info == (KernelInfo *) NULL)
5552 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5553 kernel_info=DestroyKernelInfo(kernel_info);
5556 if (LocaleCompare(
"mosaic",option+1) == 0)
5558 if (LocaleCompare(
"motion-blur",option+1) == 0)
5563 if (i == (ssize_t) argc)
5564 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5565 if (IsGeometry(argv[i]) == MagickFalse)
5566 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5569 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5573 if (LocaleCompare(
"negate",option+1) == 0)
5575 if (LocaleCompare(
"noise",option+1) == 0)
5578 if (i == (ssize_t) argc)
5579 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5585 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5587 ThrowMogrifyException(OptionError,
"UnrecognizedNoiseType",
5591 if (IsGeometry(argv[i]) == MagickFalse)
5592 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5595 if (LocaleCompare(
"noop",option+1) == 0)
5597 if (LocaleCompare(
"normalize",option+1) == 0)
5599 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5603 if (LocaleCompare(
"opaque",option+1) == 0)
5606 if (i == (ssize_t) argc)
5607 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5610 if (LocaleCompare(
"ordered-dither",option+1) == 0)
5615 if (i == (ssize_t) argc)
5616 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5619 if (LocaleCompare(
"orient",option+1) == 0)
5624 orientation=UndefinedOrientation;
5628 if (i == (ssize_t) argc)
5629 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5630 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5632 if (orientation < 0)
5633 ThrowMogrifyException(OptionError,
"UnrecognizedImageOrientation",
5637 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5641 if (LocaleCompare(
"page",option+1) == 0)
5646 if (i == (ssize_t) argc)
5647 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5650 if (LocaleCompare(
"paint",option+1) == 0)
5655 if (i == (ssize_t) argc)
5656 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5657 if (IsGeometry(argv[i]) == MagickFalse)
5658 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5661 if (LocaleCompare(
"path",option+1) == 0)
5663 (void) CloneString(&path,(
char *) NULL);
5667 if (i == (ssize_t) argc)
5668 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5669 (void) CloneString(&path,argv[i]);
5672 if (LocaleCompare(
"perceptible",option+1) == 0)
5677 if (i == (ssize_t) argc)
5678 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5679 if (IsGeometry(argv[i]) == MagickFalse)
5680 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5683 if (LocaleCompare(
"pointsize",option+1) == 0)
5688 if (i == (ssize_t) argc)
5689 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5690 if (IsGeometry(argv[i]) == MagickFalse)
5691 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5694 if (LocaleCompare(
"polaroid",option+1) == 0)
5699 if (i == (ssize_t) argc)
5700 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5701 if (IsGeometry(argv[i]) == MagickFalse)
5702 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5705 if (LocaleCompare(
"poly",option+1) == 0)
5710 if (i == (ssize_t) argc)
5711 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5712 if (IsGeometry(argv[i]) == MagickFalse)
5713 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5716 if (LocaleCompare(
"posterize",option+1) == 0)
5721 if (i == (ssize_t) argc)
5722 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5723 if (IsGeometry(argv[i]) == MagickFalse)
5724 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5727 if (LocaleCompare(
"precision",option+1) == 0)
5732 if (i == (ssize_t) argc)
5733 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5734 if (IsGeometry(argv[i]) == MagickFalse)
5735 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5738 if (LocaleCompare(
"print",option+1) == 0)
5743 if (i == (ssize_t) argc)
5744 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5747 if (LocaleCompare(
"process",option+1) == 0)
5752 if (i == (ssize_t) argc)
5753 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5756 if (LocaleCompare(
"profile",option+1) == 0)
5759 if (i == (ssize_t) argc)
5760 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5763 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5767 if (LocaleCompare(
"quality",option+1) == 0)
5772 if (i == (ssize_t) argc)
5773 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5774 if (IsGeometry(argv[i]) == MagickFalse)
5775 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5778 if (LocaleCompare(
"quantize",option+1) == 0)
5786 if (i == (ssize_t) argc)
5787 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5788 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5791 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
5795 if (LocaleCompare(
"quiet",option+1) == 0)
5797 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5801 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
5802 LocaleCompare(
"rotational-blur",option+1) == 0)
5805 if (i == (ssize_t) argc)
5806 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5807 if (IsGeometry(argv[i]) == MagickFalse)
5808 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5811 if (LocaleCompare(
"raise",option+1) == 0)
5814 if (i == (ssize_t) argc)
5815 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5816 if (IsGeometry(argv[i]) == MagickFalse)
5817 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5820 if (LocaleCompare(
"random-threshold",option+1) == 0)
5825 if (i == (ssize_t) argc)
5826 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5827 if (IsGeometry(argv[i]) == MagickFalse)
5828 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5831 if (LocaleCompare(
"recolor",option+1) == 0)
5836 if (i == (ssize_t) argc)
5837 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5838 if (IsGeometry(argv[i]) == MagickFalse)
5839 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5842 if (LocaleCompare(
"red-primary",option+1) == 0)
5847 if (i == (ssize_t) argc)
5848 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5849 if (IsGeometry(argv[i]) == MagickFalse)
5850 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5852 if (LocaleCompare(
"regard-warnings",option+1) == 0)
5854 if (LocaleCompare(
"region",option+1) == 0)
5859 if (i == (ssize_t) argc)
5860 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5861 if (IsGeometry(argv[i]) == MagickFalse)
5862 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5865 if (LocaleCompare(
"remap",option+1) == 0)
5870 if (i == (ssize_t) argc)
5871 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5874 if (LocaleCompare(
"render",option+1) == 0)
5876 if (LocaleCompare(
"repage",option+1) == 0)
5881 if (i == (ssize_t) argc)
5882 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5883 if (IsGeometry(argv[i]) == MagickFalse)
5884 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5887 if (LocaleCompare(
"resample",option+1) == 0)
5892 if (i == (ssize_t) argc)
5893 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5894 if (IsGeometry(argv[i]) == MagickFalse)
5895 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5898 if (LocaleCompare(
"resize",option+1) == 0)
5903 if (i == (ssize_t) argc)
5904 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5905 if (IsGeometry(argv[i]) == MagickFalse)
5906 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5909 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
5911 respect_parenthesis=(*option ==
'-') ? MagickTrue : MagickFalse;
5914 if (LocaleCompare(
"reverse",option+1) == 0)
5916 if (LocaleCompare(
"roll",option+1) == 0)
5921 if (i == (ssize_t) argc)
5922 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5923 if (IsGeometry(argv[i]) == MagickFalse)
5924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5927 if (LocaleCompare(
"rotate",option+1) == 0)
5930 if (i == (ssize_t) argc)
5931 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5932 if (IsGeometry(argv[i]) == MagickFalse)
5933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5936 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5940 if (LocaleCompare(
"sample",option+1) == 0)
5945 if (i == (ssize_t) argc)
5946 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5947 if (IsGeometry(argv[i]) == MagickFalse)
5948 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5951 if (LocaleCompare(
"sampling-factor",option+1) == 0)
5956 if (i == (ssize_t) argc)
5957 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5958 if (IsGeometry(argv[i]) == MagickFalse)
5959 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5962 if (LocaleCompare(
"scale",option+1) == 0)
5967 if (i == (ssize_t) argc)
5968 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5969 if (IsGeometry(argv[i]) == MagickFalse)
5970 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5973 if (LocaleCompare(
"scene",option+1) == 0)
5978 if (i == (ssize_t) argc)
5979 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5980 if (IsGeometry(argv[i]) == MagickFalse)
5981 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5984 if (LocaleCompare(
"seed",option+1) == 0)
5989 if (i == (ssize_t) argc)
5990 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5991 if (IsGeometry(argv[i]) == MagickFalse)
5992 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5995 if (LocaleCompare(
"segment",option+1) == 0)
6000 if (i == (ssize_t) argc)
6001 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6002 if (IsGeometry(argv[i]) == MagickFalse)
6003 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6006 if (LocaleCompare(
"selective-blur",option+1) == 0)
6009 if (i == (ssize_t) argc)
6010 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6011 if (IsGeometry(argv[i]) == MagickFalse)
6012 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6015 if (LocaleCompare(
"separate",option+1) == 0)
6017 if (LocaleCompare(
"sepia-tone",option+1) == 0)
6022 if (i == (ssize_t) argc)
6023 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6024 if (IsGeometry(argv[i]) == MagickFalse)
6025 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6028 if (LocaleCompare(
"set",option+1) == 0)
6031 if (i == (ssize_t) argc)
6032 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6036 if (i == (ssize_t) argc)
6037 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6040 if (LocaleCompare(
"shade",option+1) == 0)
6043 if (i == (ssize_t) argc)
6044 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6045 if (IsGeometry(argv[i]) == MagickFalse)
6046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6049 if (LocaleCompare(
"shadow",option+1) == 0)
6054 if (i == (ssize_t) argc)
6055 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6056 if (IsGeometry(argv[i]) == MagickFalse)
6057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6060 if (LocaleCompare(
"sharpen",option+1) == 0)
6063 if (i == (ssize_t) argc)
6064 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6065 if (IsGeometry(argv[i]) == MagickFalse)
6066 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6069 if (LocaleCompare(
"shave",option+1) == 0)
6074 if (i == (ssize_t) argc)
6075 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6076 if (IsGeometry(argv[i]) == MagickFalse)
6077 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6080 if (LocaleCompare(
"shear",option+1) == 0)
6083 if (i == (ssize_t) argc)
6084 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6085 if (IsGeometry(argv[i]) == MagickFalse)
6086 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6089 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
6092 if (i == (ssize_t) argc)
6093 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6094 if (IsGeometry(argv[i]) == MagickFalse)
6095 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6098 if (LocaleCompare(
"size",option+1) == 0)
6103 if (i == (ssize_t) argc)
6104 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6105 if (IsGeometry(argv[i]) == MagickFalse)
6106 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6109 if (LocaleCompare(
"sketch",option+1) == 0)
6114 if (i == (ssize_t) argc)
6115 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6116 if (IsGeometry(argv[i]) == MagickFalse)
6117 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6120 if (LocaleCompare(
"smush",option+1) == 0)
6123 if (i == (ssize_t) argc)
6124 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6125 if (IsGeometry(argv[i]) == MagickFalse)
6126 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6130 if (LocaleCompare(
"solarize",option+1) == 0)
6135 if (i == (ssize_t) argc)
6136 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6137 if (IsGeometry(argv[i]) == MagickFalse)
6138 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6141 if (LocaleCompare(
"sparse-color",option+1) == 0)
6147 if (i == (ssize_t) argc)
6148 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6149 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6151 ThrowMogrifyException(OptionError,
"UnrecognizedSparseColorMethod",
6154 if (i == (ssize_t) argc)
6155 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6158 if (LocaleCompare(
"splice",option+1) == 0)
6163 if (i == (ssize_t) argc)
6164 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6165 if (IsGeometry(argv[i]) == MagickFalse)
6166 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6169 if (LocaleCompare(
"spread",option+1) == 0)
6174 if (i == (ssize_t) argc)
6175 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6176 if (IsGeometry(argv[i]) == MagickFalse)
6177 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6180 if (LocaleCompare(
"statistic",option+1) == 0)
6188 if (i == (ssize_t) argc)
6189 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6190 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6192 ThrowMogrifyException(OptionError,
"UnrecognizedStatisticType",
6195 if (i == (ssize_t) argc)
6196 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6197 if (IsGeometry(argv[i]) == MagickFalse)
6198 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6201 if (LocaleCompare(
"stretch",option+1) == 0)
6209 if (i == (ssize_t) argc)
6210 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6211 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
6213 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6217 if (LocaleCompare(
"strip",option+1) == 0)
6219 if (LocaleCompare(
"stroke",option+1) == 0)
6224 if (i == (ssize_t) argc)
6225 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6228 if (LocaleCompare(
"strokewidth",option+1) == 0)
6233 if (i == (ssize_t) argc)
6234 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6235 if (IsGeometry(argv[i]) == MagickFalse)
6236 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6239 if (LocaleCompare(
"style",option+1) == 0)
6247 if (i == (ssize_t) argc)
6248 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6249 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6251 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6255 if (LocaleCompare(
"swap",option+1) == 0)
6260 if (i == (ssize_t) argc)
6261 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6262 if (IsGeometry(argv[i]) == MagickFalse)
6263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6266 if (LocaleCompare(
"swirl",option+1) == 0)
6271 if (i == (ssize_t) argc)
6272 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6273 if (IsGeometry(argv[i]) == MagickFalse)
6274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6277 if (LocaleCompare(
"synchronize",option+1) == 0)
6279 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6283 if (LocaleCompare(
"taint",option+1) == 0)
6285 if (LocaleCompare(
"texture",option+1) == 0)
6290 if (i == (ssize_t) argc)
6291 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6294 if (LocaleCompare(
"tile",option+1) == 0)
6299 if (i == (ssize_t) argc)
6300 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6303 if (LocaleCompare(
"tile-offset",option+1) == 0)
6308 if (i == (ssize_t) argc)
6309 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6310 if (IsGeometry(argv[i]) == MagickFalse)
6311 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6314 if (LocaleCompare(
"tint",option+1) == 0)
6319 if (i == (ssize_t) argc)
6320 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6321 if (IsGeometry(argv[i]) == MagickFalse)
6322 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6325 if (LocaleCompare(
"transform",option+1) == 0)
6327 if (LocaleCompare(
"transpose",option+1) == 0)
6329 if (LocaleCompare(
"transverse",option+1) == 0)
6331 if (LocaleCompare(
"threshold",option+1) == 0)
6336 if (i == (ssize_t) argc)
6337 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6338 if (IsGeometry(argv[i]) == MagickFalse)
6339 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6342 if (LocaleCompare(
"thumbnail",option+1) == 0)
6347 if (i == (ssize_t) argc)
6348 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6349 if (IsGeometry(argv[i]) == MagickFalse)
6350 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6353 if (LocaleCompare(
"transparent",option+1) == 0)
6356 if (i == (ssize_t) argc)
6357 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6360 if (LocaleCompare(
"transparent-color",option+1) == 0)
6365 if (i == (ssize_t) argc)
6366 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6369 if (LocaleCompare(
"treedepth",option+1) == 0)
6374 if (i == (ssize_t) argc)
6375 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6376 if (IsGeometry(argv[i]) == MagickFalse)
6377 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6380 if (LocaleCompare(
"trim",option+1) == 0)
6382 if (LocaleCompare(
"type",option+1) == 0)
6390 if (i == (ssize_t) argc)
6391 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6392 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6394 ThrowMogrifyException(OptionError,
"UnrecognizedImageType",
6398 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6402 if (LocaleCompare(
"undercolor",option+1) == 0)
6407 if (i == (ssize_t) argc)
6408 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6411 if (LocaleCompare(
"unique-colors",option+1) == 0)
6413 if (LocaleCompare(
"units",option+1) == 0)
6421 if (i == (ssize_t) argc)
6422 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6423 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6426 ThrowMogrifyException(OptionError,
"UnrecognizedUnitsType",
6430 if (LocaleCompare(
"unsharp",option+1) == 0)
6433 if (i == (ssize_t) argc)
6434 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6435 if (IsGeometry(argv[i]) == MagickFalse)
6436 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6439 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6443 if (LocaleCompare(
"verbose",option+1) == 0)
6445 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
6448 if ((LocaleCompare(
"version",option+1) == 0) ||
6449 (LocaleCompare(
"-version",option+1) == 0))
6451 ListMagickVersion(stdout);
6454 if (LocaleCompare(
"view",option+1) == 0)
6459 if (i == (ssize_t) argc)
6460 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6463 if (LocaleCompare(
"vignette",option+1) == 0)
6468 if (i == (ssize_t) argc)
6469 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6470 if (IsGeometry(argv[i]) == MagickFalse)
6471 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6474 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
6482 if (i == (ssize_t) argc)
6483 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6484 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6487 ThrowMogrifyException(OptionError,
6488 "UnrecognizedVirtualPixelMethod",argv[i]);
6491 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6495 if (LocaleCompare(
"wave",option+1) == 0)
6498 if (i == (ssize_t) argc)
6499 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6500 if (IsGeometry(argv[i]) == MagickFalse)
6501 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6504 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
6507 if (i == (ssize_t) argc)
6508 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6509 if (IsGeometry(argv[i]) == MagickFalse)
6510 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6513 if (LocaleCompare(
"weight",option+1) == 0)
6518 if (i == (ssize_t) argc)
6519 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6522 if (LocaleCompare(
"white-point",option+1) == 0)
6527 if (i == (ssize_t) argc)
6528 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6529 if (IsGeometry(argv[i]) == MagickFalse)
6530 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6533 if (LocaleCompare(
"white-threshold",option+1) == 0)
6538 if (i == (ssize_t) argc)
6539 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6540 if (IsGeometry(argv[i]) == MagickFalse)
6541 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6544 if (LocaleCompare(
"write",option+1) == 0)
6547 if (i == (ssize_t) argc)
6548 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6551 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6556 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6558 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6559 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6560 if (fire != MagickFalse)
6561 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6564 ThrowMogrifyException(OptionError,
"UnbalancedParenthesis",argv[i]);
6565 if (i != (ssize_t) argc)
6566 ThrowMogrifyException(OptionError,
"MissingAnImageFilename",argv[i]);
6568 return(status != 0 ? MagickTrue : MagickFalse);
6603 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6604 const int argc,
const char **argv,ExceptionInfo *exception)
6621 assert(image_info != (ImageInfo *) NULL);
6622 assert(image_info->signature == MagickCoreSignature);
6623 if (IsEventLogging() != MagickFalse)
6624 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
6625 image_info->filename);
6631 for (i=0; i < (ssize_t) argc; i++)
6634 if (IsCommandOption(option) == MagickFalse)
6636 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6637 count=MagickMax(count,0L);
6638 if ((i+count) >= (ssize_t) argc)
6640 switch (*(option+1))
6644 if (LocaleCompare(
"adjoin",option+1) == 0)
6646 image_info->adjoin=(*option ==
'-') ? MagickTrue : MagickFalse;
6649 if (LocaleCompare(
"antialias",option+1) == 0)
6651 image_info->antialias=(*option ==
'-') ? MagickTrue : MagickFalse;
6654 if (LocaleCompare(
"attenuate",option+1) == 0)
6658 (void) DeleteImageOption(image_info,option+1);
6661 (void) SetImageOption(image_info,option+1,argv[i+1]);
6664 if (LocaleCompare(
"authenticate",option+1) == 0)
6667 (void) CloneString(&image_info->authenticate,(
char *) NULL);
6669 (
void) CloneString(&image_info->authenticate,argv[i+1]);
6676 if (LocaleCompare(
"background",option+1) == 0)
6680 (void) DeleteImageOption(image_info,option+1);
6681 (void) QueryColorDatabase(MogrifyBackgroundColor,
6682 &image_info->background_color,exception);
6685 (void) SetImageOption(image_info,option+1,argv[i+1]);
6686 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6690 if (LocaleCompare(
"bias",option+1) == 0)
6694 (void) SetImageOption(image_info,option+1,
"0.0");
6697 (void) SetImageOption(image_info,option+1,argv[i+1]);
6700 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
6704 (void) SetImageOption(image_info,option+1,
"false");
6707 (void) SetImageOption(image_info,option+1,
"true");
6710 if (LocaleCompare(
"blue-primary",option+1) == 0)
6714 (void) SetImageOption(image_info,option+1,
"0.0");
6717 (void) SetImageOption(image_info,option+1,argv[i+1]);
6720 if (LocaleCompare(
"bordercolor",option+1) == 0)
6724 (void) DeleteImageOption(image_info,option+1);
6725 (void) QueryColorDatabase(MogrifyBorderColor,
6726 &image_info->border_color,exception);
6729 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6731 (void) SetImageOption(image_info,option+1,argv[i+1]);
6734 if (LocaleCompare(
"box",option+1) == 0)
6738 (void) SetImageOption(image_info,
"undercolor",
"none");
6741 (void) SetImageOption(image_info,
"undercolor",argv[i+1]);
6748 if (LocaleCompare(
"cache",option+1) == 0)
6753 limit=MagickResourceInfinity;
6754 if (LocaleCompare(
"unlimited",argv[i+1]) != 0)
6755 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],100.0);
6756 (void) SetMagickResourceLimit(MemoryResource,limit);
6757 (void) SetMagickResourceLimit(MapResource,2*limit);
6760 if (LocaleCompare(
"caption",option+1) == 0)
6764 (void) DeleteImageOption(image_info,option+1);
6767 (void) SetImageOption(image_info,option+1,argv[i+1]);
6770 if (LocaleCompare(
"channel",option+1) == 0)
6774 image_info->channel=DefaultChannels;
6777 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6780 if (LocaleCompare(
"colors",option+1) == 0)
6782 image_info->colors=StringToUnsignedLong(argv[i+1]);
6785 if (LocaleCompare(
"colorspace",option+1) == 0)
6789 image_info->colorspace=UndefinedColorspace;
6790 (void) SetImageOption(image_info,option+1,
"undefined");
6793 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6794 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6795 (void) SetImageOption(image_info,option+1,argv[i+1]);
6798 if (LocaleCompare(
"comment",option+1) == 0)
6802 (void) DeleteImageOption(image_info,option+1);
6805 (void) SetImageOption(image_info,option+1,argv[i+1]);
6808 if (LocaleCompare(
"compose",option+1) == 0)
6812 (void) SetImageOption(image_info,option+1,
"undefined");
6815 (void) SetImageOption(image_info,option+1,argv[i+1]);
6818 if (LocaleCompare(
"compress",option+1) == 0)
6822 image_info->compression=UndefinedCompression;
6823 (void) SetImageOption(image_info,option+1,
"undefined");
6826 image_info->compression=(CompressionType) ParseCommandOption(
6827 MagickCompressOptions,MagickFalse,argv[i+1]);
6828 (void) SetImageOption(image_info,option+1,argv[i+1]);
6835 if (LocaleCompare(
"debug",option+1) == 0)
6838 (void) SetLogEventMask(
"none");
6840 (
void) SetLogEventMask(argv[i+1]);
6841 image_info->debug=IsEventLogging();
6844 if (LocaleCompare(
"define",option+1) == 0)
6848 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6849 (void) DeleteImageRegistry(argv[i+1]+9);
6851 (
void) DeleteImageOption(image_info,argv[i+1]);
6854 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6856 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6860 (void) DefineImageOption(image_info,argv[i+1]);
6863 if (LocaleCompare(
"delay",option+1) == 0)
6867 (void) SetImageOption(image_info,option+1,
"0");
6870 (void) SetImageOption(image_info,option+1,argv[i+1]);
6873 if (LocaleCompare(
"density",option+1) == 0)
6880 if (image_info->density != (
char *) NULL)
6881 image_info->density=DestroyString(image_info->density);
6882 (void) SetImageOption(image_info,option+1,
"72");
6885 (void) CloneString(&image_info->density,argv[i+1]);
6886 (void) SetImageOption(image_info,option+1,argv[i+1]);
6889 if (LocaleCompare(
"depth",option+1) == 0)
6893 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6896 image_info->depth=StringToUnsignedLong(argv[i+1]);
6899 if (LocaleCompare(
"direction",option+1) == 0)
6903 (void) SetImageOption(image_info,option+1,
"undefined");
6906 (void) SetImageOption(image_info,option+1,argv[i+1]);
6909 if (LocaleCompare(
"display",option+1) == 0)
6913 if (image_info->server_name != (
char *) NULL)
6914 image_info->server_name=DestroyString(
6915 image_info->server_name);
6918 (void) CloneString(&image_info->server_name,argv[i+1]);
6921 if (LocaleCompare(
"dispose",option+1) == 0)
6925 (void) SetImageOption(image_info,option+1,
"undefined");
6928 (void) SetImageOption(image_info,option+1,argv[i+1]);
6931 if (LocaleCompare(
"dither",option+1) == 0)
6935 image_info->dither=MagickFalse;
6936 (void) SetImageOption(image_info,option+1,
"none");
6939 (void) SetImageOption(image_info,option+1,argv[i+1]);
6940 image_info->dither=MagickTrue;
6947 if (LocaleCompare(
"encoding",option+1) == 0)
6951 (void) SetImageOption(image_info,option+1,
"undefined");
6954 (void) SetImageOption(image_info,option+1,argv[i+1]);
6957 if (LocaleCompare(
"endian",option+1) == 0)
6961 image_info->endian=UndefinedEndian;
6962 (void) SetImageOption(image_info,option+1,
"undefined");
6965 image_info->endian=(EndianType) ParseCommandOption(
6966 MagickEndianOptions,MagickFalse,argv[i+1]);
6967 (void) SetImageOption(image_info,option+1,argv[i+1]);
6970 if (LocaleCompare(
"extract",option+1) == 0)
6977 if (image_info->extract != (
char *) NULL)
6978 image_info->extract=DestroyString(image_info->extract);
6981 (void) CloneString(&image_info->extract,argv[i+1]);
6988 if (LocaleCompare(
"family",option+1) == 0)
6991 (void) SetImageOption(image_info,option+1,argv[i+1]);
6994 if (LocaleCompare(
"fill",option+1) == 0)
6998 (void) SetImageOption(image_info,option+1,
"none");
7001 (void) SetImageOption(image_info,option+1,argv[i+1]);
7004 if (LocaleCompare(
"filter",option+1) == 0)
7008 (void) SetImageOption(image_info,option+1,
"undefined");
7011 (void) SetImageOption(image_info,option+1,argv[i+1]);
7014 if (LocaleCompare(
"font",option+1) == 0)
7018 if (image_info->font != (
char *) NULL)
7019 image_info->font=DestroyString(image_info->font);
7022 (void) CloneString(&image_info->font,argv[i+1]);
7025 if (LocaleCompare(
"format",option+1) == 0)
7027 (void) SetImageOption(image_info,option+1,argv[i+1]);
7030 if (LocaleCompare(
"fuzz",option+1) == 0)
7034 image_info->fuzz=0.0;
7035 (void) SetImageOption(image_info,option+1,
"0");
7038 image_info->fuzz=StringToDoubleInterval(argv[i+1],(
double)
7040 (void) SetImageOption(image_info,option+1,argv[i+1]);
7047 if (LocaleCompare(
"gravity",option+1) == 0)
7051 (void) SetImageOption(image_info,option+1,
"undefined");
7054 (void) SetImageOption(image_info,option+1,argv[i+1]);
7057 if (LocaleCompare(
"green-primary",option+1) == 0)
7061 (void) SetImageOption(image_info,option+1,
"0.0");
7064 (void) SetImageOption(image_info,option+1,argv[i+1]);
7071 if (LocaleCompare(
"intensity",option+1) == 0)
7075 (void) SetImageOption(image_info,option+1,
"undefined");
7078 (void) SetImageOption(image_info,option+1,argv[i+1]);
7081 if (LocaleCompare(
"intent",option+1) == 0)
7085 (void) SetImageOption(image_info,option+1,
"undefined");
7088 (void) SetImageOption(image_info,option+1,argv[i+1]);
7091 if (LocaleCompare(
"interlace",option+1) == 0)
7095 image_info->interlace=UndefinedInterlace;
7096 (void) SetImageOption(image_info,option+1,
"undefined");
7099 image_info->interlace=(InterlaceType) ParseCommandOption(
7100 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7101 (void) SetImageOption(image_info,option+1,argv[i+1]);
7104 if (LocaleCompare(
"interline-spacing",option+1) == 0)
7108 (void) SetImageOption(image_info,option+1,
"undefined");
7111 (void) SetImageOption(image_info,option+1,argv[i+1]);
7114 if (LocaleCompare(
"interpolate",option+1) == 0)
7118 (void) SetImageOption(image_info,option+1,
"undefined");
7121 (void) SetImageOption(image_info,option+1,argv[i+1]);
7124 if (LocaleCompare(
"interword-spacing",option+1) == 0)
7128 (void) SetImageOption(image_info,option+1,
"undefined");
7131 (void) SetImageOption(image_info,option+1,argv[i+1]);
7138 if (LocaleCompare(
"kerning",option+1) == 0)
7142 (void) SetImageOption(image_info,option+1,
"undefined");
7145 (void) SetImageOption(image_info,option+1,argv[i+1]);
7152 if (LocaleCompare(
"label",option+1) == 0)
7156 (void) DeleteImageOption(image_info,option+1);
7159 (void) SetImageOption(image_info,option+1,argv[i+1]);
7162 if (LocaleCompare(
"limit",option+1) == 0)
7172 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7173 MagickFalse,argv[i+1]);
7174 limit=MagickResourceInfinity;
7175 if (LocaleCompare(
"unlimited",argv[i+2]) != 0)
7176 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7177 (void) SetMagickResourceLimit(type,limit);
7180 if (LocaleCompare(
"list",option+1) == 0)
7188 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7191 case MagickCoderOptions:
7193 (void) ListCoderInfo((FILE *) NULL,exception);
7196 case MagickColorOptions:
7198 (void) ListColorInfo((FILE *) NULL,exception);
7201 case MagickConfigureOptions:
7203 (void) ListConfigureInfo((FILE *) NULL,exception);
7206 case MagickDelegateOptions:
7208 (void) ListDelegateInfo((FILE *) NULL,exception);
7211 case MagickFontOptions:
7213 (void) ListTypeInfo((FILE *) NULL,exception);
7216 case MagickFormatOptions:
7218 (void) ListMagickInfo((FILE *) NULL,exception);
7221 case MagickLocaleOptions:
7223 (void) ListLocaleInfo((FILE *) NULL,exception);
7226 case MagickLogOptions:
7228 (void) ListLogInfo((FILE *) NULL,exception);
7231 case MagickMagicOptions:
7233 (void) ListMagicInfo((FILE *) NULL,exception);
7236 case MagickMimeOptions:
7238 (void) ListMimeInfo((FILE *) NULL,exception);
7241 case MagickModuleOptions:
7243 (void) ListModuleInfo((FILE *) NULL,exception);
7246 case MagickPagesizeOptions:
7248 (void) ListPagesizes((FILE *) NULL,exception);
7251 case MagickPolicyOptions:
7253 (void) ListPolicyInfo((FILE *) NULL,exception);
7256 case MagickResourceOptions:
7258 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7261 case MagickThresholdOptions:
7263 (void) ListThresholdMaps((FILE *) NULL,exception);
7268 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7275 if (LocaleCompare(
"log",option+1) == 0)
7279 (void) SetLogFormat(argv[i+1]);
7282 if (LocaleCompare(
"loop",option+1) == 0)
7286 (void) SetImageOption(image_info,option+1,
"0");
7289 (void) SetImageOption(image_info,option+1,argv[i+1]);
7296 if (LocaleCompare(
"matte",option+1) == 0)
7300 (void) SetImageOption(image_info,option+1,
"false");
7303 (void) SetImageOption(image_info,option+1,
"true");
7306 if (LocaleCompare(
"mattecolor",option+1) == 0)
7310 (void) SetImageOption(image_info,option+1,argv[i+1]);
7311 (void) QueryColorDatabase(MogrifyMatteColor,
7312 &image_info->matte_color,exception);
7315 (void) SetImageOption(image_info,option+1,argv[i+1]);
7316 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7320 if (LocaleCompare(
"metric",option+1) == 0)
7324 (void) DeleteImageOption(image_info,option+1);
7327 (void) SetImageOption(image_info,option+1,argv[i+1]);
7330 if (LocaleCompare(
"monitor",option+1) == 0)
7332 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7336 if (LocaleCompare(
"monochrome",option+1) == 0)
7338 image_info->monochrome=(*option ==
'-') ? MagickTrue : MagickFalse;
7345 if (LocaleCompare(
"orient",option+1) == 0)
7349 image_info->orientation=UndefinedOrientation;
7350 (void) SetImageOption(image_info,option+1,
"undefined");
7353 image_info->orientation=(OrientationType) ParseCommandOption(
7354 MagickOrientationOptions,MagickFalse,argv[i+1]);
7355 (void) SetImageOption(image_info,option+1,argv[i+1]);
7362 if (LocaleCompare(
"page",option+1) == 0)
7366 page[MaxTextExtent];
7379 (void) DeleteImageOption(image_info,option+1);
7380 (void) CloneString(&image_info->page,(
char *) NULL);
7383 (void) memset(&geometry,0,
sizeof(geometry));
7384 image_option=GetImageOption(image_info,
"page");
7385 if (image_option != (
const char *) NULL)
7386 (void) ParseAbsoluteGeometry(image_option,&geometry);
7387 canonical_page=GetPageGeometry(argv[i+1]);
7388 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7389 canonical_page=DestroyString(canonical_page);
7390 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu",
7391 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
7392 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7393 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu%+ld%+ld",
7394 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
7395 (
long) geometry.x,(long) geometry.y);
7396 (void) SetImageOption(image_info,option+1,page);
7397 (void) CloneString(&image_info->page,page);
7400 if (LocaleCompare(
"pen",option+1) == 0)
7404 (void) SetImageOption(image_info,option+1,
"none");
7407 (void) SetImageOption(image_info,option+1,argv[i+1]);
7410 if (LocaleCompare(
"ping",option+1) == 0)
7412 image_info->ping=(*option ==
'-') ? MagickTrue : MagickFalse;
7415 if (LocaleCompare(
"pointsize",option+1) == 0)
7418 geometry_info.rho=0.0;
7420 (
void) ParseGeometry(argv[i+1],&geometry_info);
7421 image_info->pointsize=geometry_info.rho;
7424 if (LocaleCompare(
"precision",option+1) == 0)
7426 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7429 if (LocaleCompare(
"preview",option+1) == 0)
7436 image_info->preview_type=UndefinedPreview;
7439 image_info->preview_type=(PreviewType) ParseCommandOption(
7440 MagickPreviewOptions,MagickFalse,argv[i+1]);
7447 if (LocaleCompare(
"quality",option+1) == 0)
7454 image_info->quality=UndefinedCompressionQuality;
7455 (void) SetImageOption(image_info,option+1,
"0");
7458 image_info->quality=StringToUnsignedLong(argv[i+1]);
7459 (void) SetImageOption(image_info,option+1,argv[i+1]);
7462 if (LocaleCompare(
"quiet",option+1) == 0)
7464 static WarningHandler
7465 warning_handler = (WarningHandler) NULL;
7472 warning_handler=SetWarningHandler(warning_handler);
7478 warning_handler=SetWarningHandler((WarningHandler) NULL);
7485 if (LocaleCompare(
"red-primary",option+1) == 0)
7489 (void) SetImageOption(image_info,option+1,
"0.0");
7492 (void) SetImageOption(image_info,option+1,argv[i+1]);
7499 if (LocaleCompare(
"sampling-factor",option+1) == 0)
7506 if (image_info->sampling_factor != (
char *) NULL)
7507 image_info->sampling_factor=DestroyString(
7508 image_info->sampling_factor);
7511 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7514 if (LocaleCompare(
"scene",option+1) == 0)
7521 image_info->scene=0;
7522 (void) SetImageOption(image_info,option+1,
"0");
7525 image_info->scene=StringToUnsignedLong(argv[i+1]);
7526 (void) SetImageOption(image_info,option+1,argv[i+1]);
7529 if (LocaleCompare(
"seed",option+1) == 0)
7536 seed=(
unsigned long) time((time_t *) NULL);
7537 SetRandomSecretKey(seed);
7540 seed=StringToUnsignedLong(argv[i+1]);
7541 SetRandomSecretKey(seed);
7544 if (LocaleCompare(
"size",option+1) == 0)
7548 if (image_info->size != (
char *) NULL)
7549 image_info->size=DestroyString(image_info->size);
7552 (void) CloneString(&image_info->size,argv[i+1]);
7555 if (LocaleCompare(
"stroke",option+1) == 0)
7558 (void) SetImageOption(image_info,option+1,
"none");
7560 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7563 if (LocaleCompare(
"strokewidth",option+1) == 0)
7566 (void) SetImageOption(image_info,option+1,
"0");
7568 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7571 if (LocaleCompare(
"style",option+1) == 0)
7574 (void) SetImageOption(image_info,option+1,
"none");
7576 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7579 if (LocaleCompare(
"synchronize",option+1) == 0)
7583 image_info->synchronize=MagickFalse;
7586 image_info->synchronize=MagickTrue;
7593 if (LocaleCompare(
"taint",option+1) == 0)
7597 (void) SetImageOption(image_info,option+1,
"false");
7600 (void) SetImageOption(image_info,option+1,
"true");
7603 if (LocaleCompare(
"texture",option+1) == 0)
7607 if (image_info->texture != (
char *) NULL)
7608 image_info->texture=DestroyString(image_info->texture);
7611 (void) CloneString(&image_info->texture,argv[i+1]);
7614 if (LocaleCompare(
"tile-offset",option+1) == 0)
7618 (void) SetImageOption(image_info,option+1,
"0");
7621 (void) SetImageOption(image_info,option+1,argv[i+1]);
7624 if (LocaleCompare(
"transparent-color",option+1) == 0)
7628 (void) QueryColorDatabase(
"none",&image_info->transparent_color, exception);
7629 (void) SetImageOption(image_info,option+1,
"none");
7632 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7634 (void) SetImageOption(image_info,option+1,argv[i+1]);
7637 if (LocaleCompare(
"type",option+1) == 0)
7641 image_info->type=UndefinedType;
7642 (void) SetImageOption(image_info,option+1,
"undefined");
7645 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7646 MagickFalse,argv[i+1]);
7647 (void) SetImageOption(image_info,option+1,argv[i+1]);
7654 if (LocaleCompare(
"undercolor",option+1) == 0)
7658 (void) DeleteImageOption(image_info,option+1);
7661 (void) SetImageOption(image_info,option+1,argv[i+1]);
7664 if (LocaleCompare(
"units",option+1) == 0)
7668 image_info->units=UndefinedResolution;
7669 (void) SetImageOption(image_info,option+1,
"undefined");
7672 image_info->units=(ResolutionType) ParseCommandOption(
7673 MagickResolutionOptions,MagickFalse,argv[i+1]);
7674 (void) SetImageOption(image_info,option+1,argv[i+1]);
7681 if (LocaleCompare(
"verbose",option+1) == 0)
7685 image_info->verbose=MagickFalse;
7688 image_info->verbose=MagickTrue;
7689 image_info->ping=MagickFalse;
7692 if (LocaleCompare(
"view",option+1) == 0)
7696 if (image_info->view != (
char *) NULL)
7697 image_info->view=DestroyString(image_info->view);
7700 (void) CloneString(&image_info->view,argv[i+1]);
7703 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
7707 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7708 (void) SetImageOption(image_info,option+1,
"undefined");
7711 image_info->virtual_pixel_method=(VirtualPixelMethod)
7712 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7714 (void) SetImageOption(image_info,option+1,argv[i+1]);
7721 if (LocaleCompare(
"weight",option+1) == 0)
7724 (void) SetImageOption(image_info,option+1,
"0");
7726 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7729 if (LocaleCompare(
"white-point",option+1) == 0)
7733 (void) SetImageOption(image_info,option+1,
"0.0");
7736 (void) SetImageOption(image_info,option+1,argv[i+1]);
7783 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7784 const int argc,
const char **argv,Image **images,ExceptionInfo *exception)
7811 assert(image_info != (ImageInfo *) NULL);
7812 assert(image_info->signature == MagickCoreSignature);
7813 assert(images != (Image **) NULL);
7814 assert((*images)->previous == (Image *) NULL);
7815 assert((*images)->signature == MagickCoreSignature);
7816 if (IsEventLogging() != MagickFalse)
7817 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
7818 (*images)->filename);
7819 if ((argc <= 0) || (*argv == (
char *) NULL))
7821 mogrify_info=CloneImageInfo(image_info);
7822 quantize_info=AcquireQuantizeInfo(mogrify_info);
7823 channel=mogrify_info->channel;
7825 for (i=0; i < (ssize_t) argc; i++)
7827 if (*images == (Image *) NULL)
7830 if (IsCommandOption(option) == MagickFalse)
7832 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7833 count=MagickMax(count,0L);
7834 if ((i+count) >= (ssize_t) argc)
7836 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
7837 switch (*(option+1))
7841 if (LocaleCompare(
"affinity",option+1) == 0)
7843 (void) SyncImagesSettings(mogrify_info,*images);
7846 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7847 InheritException(exception,&(*images)->exception);
7853 if (LocaleCompare(
"append",option+1) == 0)
7858 (void) SyncImagesSettings(mogrify_info,*images);
7859 append_image=AppendImages(*images,*option ==
'-' ? MagickTrue :
7860 MagickFalse,exception);
7861 if (append_image == (Image *) NULL)
7866 *images=DestroyImageList(*images);
7867 *images=append_image;
7870 if (LocaleCompare(
"average",option+1) == 0)
7878 (void) SyncImagesSettings(mogrify_info,*images);
7879 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7881 if (average_image == (Image *) NULL)
7886 *images=DestroyImageList(*images);
7887 *images=average_image;
7894 if (LocaleCompare(
"channel",option+1) == 0)
7898 channel=DefaultChannels;
7901 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7904 if (LocaleCompare(
"clut",option+1) == 0)
7910 (void) SyncImagesSettings(mogrify_info,*images);
7911 image=RemoveFirstImageFromList(images);
7912 clut_image=RemoveFirstImageFromList(images);
7913 if (clut_image == (Image *) NULL)
7915 (void) ThrowMagickException(exception,GetMagickModule(),
7916 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7917 image=DestroyImage(image);
7921 (void) ClutImageChannel(image,channel,clut_image);
7922 clut_image=DestroyImage(clut_image);
7923 InheritException(exception,&image->exception);
7924 *images=DestroyImageList(*images);
7928 if (LocaleCompare(
"coalesce",option+1) == 0)
7933 (void) SyncImagesSettings(mogrify_info,*images);
7934 coalesce_image=CoalesceImages(*images,exception);
7935 if (coalesce_image == (Image *) NULL)
7940 *images=DestroyImageList(*images);
7941 *images=coalesce_image;
7944 if (LocaleCompare(
"combine",option+1) == 0)
7949 (void) SyncImagesSettings(mogrify_info,*images);
7950 combine_image=CombineImages(*images,channel,exception);
7951 if (combine_image == (Image *) NULL)
7956 *images=DestroyImageList(*images);
7957 *images=combine_image;
7960 if (LocaleCompare(
"compare",option+1) == 0)
7977 (void) SyncImagesSettings(mogrify_info,*images);
7978 image=RemoveFirstImageFromList(images);
7979 reconstruct_image=RemoveFirstImageFromList(images);
7980 if (reconstruct_image == (Image *) NULL)
7982 (void) ThrowMagickException(exception,GetMagickModule(),
7983 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7984 image=DestroyImage(image);
7988 metric=UndefinedMetric;
7989 option=GetImageOption(image_info,
"metric");
7990 if (option != (
const char *) NULL)
7991 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7992 MagickFalse,option);
7993 difference_image=CompareImageChannels(image,reconstruct_image,
7994 channel,metric,&distortion,exception);
7995 if (difference_image == (Image *) NULL)
7997 reconstruct_image=DestroyImage(reconstruct_image);
7998 image=DestroyImage(image);
7999 if (*images != (Image *) NULL)
8000 *images=DestroyImageList(*images);
8001 *images=difference_image;
8004 if (LocaleCompare(
"complex",option+1) == 0)
8012 (void) SyncImageSettings(mogrify_info,*images);
8013 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
8014 MagickFalse,argv[i+1]);
8015 complex_images=ComplexImages(*images,op,exception);
8016 if (complex_images == (Image *) NULL)
8021 *images=DestroyImageList(*images);
8022 *images=complex_images;
8025 if (LocaleCompare(
"composite",option+1) == 0)
8035 (void) SyncImagesSettings(mogrify_info,*images);
8036 image=RemoveFirstImageFromList(images);
8037 composite_image=RemoveFirstImageFromList(images);
8038 if (composite_image == (Image *) NULL)
8040 (void) ThrowMagickException(exception,GetMagickModule(),
8041 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8042 image=DestroyImage(image);
8046 (void) TransformImage(&composite_image,(
char *) NULL,
8047 composite_image->geometry);
8048 SetGeometry(composite_image,&geometry);
8049 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
8050 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8052 mask_image=RemoveFirstImageFromList(images);
8053 if (mask_image != (Image *) NULL)
8055 if ((image->compose == DisplaceCompositeOp) ||
8056 (image->compose == DistortCompositeOp))
8061 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8063 mask_image=DestroyImage(mask_image);
8070 if (image->mask != (Image *) NULL)
8071 image->mask=DestroyImage(image->mask);
8072 image->mask=mask_image;
8073 (void) NegateImage(image->mask,MagickFalse);
8076 (void) CompositeImageChannel(image,channel,image->compose,
8077 composite_image,geometry.x,geometry.y);
8078 if (mask_image != (Image *) NULL)
8080 image->mask=DestroyImage(image->mask);
8081 mask_image=image->mask;
8083 composite_image=DestroyImage(composite_image);
8084 InheritException(exception,&image->exception);
8085 *images=DestroyImageList(*images);
8089 if (LocaleCompare(
"copy",option+1) == 0)
8103 (void) SyncImageSettings(mogrify_info,*images);
8104 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8105 offset.x=geometry.x;
8106 offset.y=geometry.y;
8107 source_image=(*images);
8108 if (source_image->next != (Image *) NULL)
8109 source_image=source_image->next;
8110 (
void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8112 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8120 if (LocaleCompare(
"deconstruct",option+1) == 0)
8125 (void) SyncImagesSettings(mogrify_info,*images);
8126 deconstruct_image=DeconstructImages(*images,exception);
8127 if (deconstruct_image == (Image *) NULL)
8132 *images=DestroyImageList(*images);
8133 *images=deconstruct_image;
8136 if (LocaleCompare(
"delete",option+1) == 0)
8139 DeleteImages(images,
"-1",exception);
8141 DeleteImages(images,argv[i+1],exception);
8144 if (LocaleCompare(
"dither",option+1) == 0)
8148 quantize_info->dither=MagickFalse;
8151 quantize_info->dither=MagickTrue;
8152 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8153 MagickDitherOptions,MagickFalse,argv[i+1]);
8156 if (LocaleCompare(
"duplicate",option+1) == 0)
8162 duplicate_images=DuplicateImages(*images,1,
"-1",exception);
8171 number_duplicates=(size_t) StringToLong(argv[i+1]);
8172 p=strchr(argv[i+1],
',');
8173 if (p == (
const char *) NULL)
8174 duplicate_images=DuplicateImages(*images,number_duplicates,
8177 duplicate_images=DuplicateImages(*images,number_duplicates,
8180 AppendImageToList(images, duplicate_images);
8181 (void) SyncImagesSettings(mogrify_info,*images);
8188 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
8193 MagickEvaluateOperator
8196 (void) SyncImageSettings(mogrify_info,*images);
8197 op=(MagickEvaluateOperator) ParseCommandOption(
8198 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8199 evaluate_image=EvaluateImages(*images,op,exception);
8200 if (evaluate_image == (Image *) NULL)
8205 *images=DestroyImageList(*images);
8206 *images=evaluate_image;
8213 if (LocaleCompare(
"fft",option+1) == 0)
8221 (void) SyncImageSettings(mogrify_info,*images);
8222 fourier_image=ForwardFourierTransformImage(*images,*option ==
'-' ?
8223 MagickTrue : MagickFalse,exception);
8224 if (fourier_image == (Image *) NULL)
8226 *images=DestroyImageList(*images);
8227 *images=fourier_image;
8230 if (LocaleCompare(
"flatten",option+1) == 0)
8235 (void) SyncImagesSettings(mogrify_info,*images);
8236 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8237 if (flatten_image == (Image *) NULL)
8239 *images=DestroyImageList(*images);
8240 *images=flatten_image;
8243 if (LocaleCompare(
"fx",option+1) == 0)
8248 (void) SyncImagesSettings(mogrify_info,*images);
8249 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
8250 if (fx_image == (Image *) NULL)
8255 *images=DestroyImageList(*images);
8263 if (LocaleCompare(
"hald-clut",option+1) == 0)
8269 (void) SyncImagesSettings(mogrify_info,*images);
8270 image=RemoveFirstImageFromList(images);
8271 hald_image=RemoveFirstImageFromList(images);
8272 if (hald_image == (Image *) NULL)
8274 (void) ThrowMagickException(exception,GetMagickModule(),
8275 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8276 image=DestroyImage(image);
8280 (void) HaldClutImageChannel(image,channel,hald_image);
8281 hald_image=DestroyImage(hald_image);
8282 InheritException(exception,&image->exception);
8283 if (*images != (Image *) NULL)
8284 *images=DestroyImageList(*images);
8292 if (LocaleCompare(
"ift",option+1) == 0)
8302 (void) SyncImagesSettings(mogrify_info,*images);
8303 magnitude_image=RemoveFirstImageFromList(images);
8304 phase_image=RemoveFirstImageFromList(images);
8305 if (phase_image == (Image *) NULL)
8307 (void) ThrowMagickException(exception,GetMagickModule(),
8308 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8309 magnitude_image=DestroyImage(magnitude_image);
8313 fourier_image=InverseFourierTransformImage(magnitude_image,
8314 phase_image,*option ==
'-' ? MagickTrue : MagickFalse,exception);
8315 magnitude_image=DestroyImage(magnitude_image);
8316 phase_image=DestroyImage(phase_image);
8317 if (fourier_image == (Image *) NULL)
8319 if (*images != (Image *) NULL)
8320 *images=DestroyImageList(*images);
8321 *images=fourier_image;
8324 if (LocaleCompare(
"insert",option+1) == 0)
8332 index=(ssize_t) StringToLong(argv[i+1]);
8333 p=RemoveLastImageFromList(images);
8334 if (p == (Image *) NULL)
8336 (void) ThrowMagickException(exception,GetMagickModule(),
8337 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8343 PrependImageToList(images,q);
8345 if (index == (ssize_t) GetImageListLength(*images))
8346 AppendImageToList(images,q);
8349 q=GetImageFromList(*images,index-1);
8350 if (q == (Image *) NULL)
8353 (void) ThrowMagickException(exception,GetMagickModule(),
8354 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8358 InsertImageInList(&q,p);
8360 *images=GetFirstImageInList(q);
8367 if (LocaleCompare(
"layers",option+1) == 0)
8375 (void) SyncImagesSettings(mogrify_info,*images);
8376 layers=(Image *) NULL;
8377 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
8378 MagickFalse,argv[i+1]);
8383 layers=CoalesceImages(*images,exception);
8386 case CompareAnyLayer:
8387 case CompareClearLayer:
8388 case CompareOverlayLayer:
8391 layers=CompareImageLayers(*images,method,exception);
8397 case TrimBoundsLayer:
8399 layers=MergeImageLayers(*images,method,exception);
8404 layers=DisposeImages(*images,exception);
8407 case OptimizeImageLayer:
8409 layers=OptimizeImageLayers(*images,exception);
8412 case OptimizePlusLayer:
8414 layers=OptimizePlusImageLayers(*images,exception);
8417 case OptimizeTransLayer:
8419 OptimizeImageTransparency(*images,exception);
8422 case RemoveDupsLayer:
8424 RemoveDuplicateLayers(images,exception);
8427 case RemoveZeroLayer:
8429 RemoveZeroDelayLayers(images,exception);
8437 layers=CoalesceImages(*images,exception);
8438 if (layers == (Image *) NULL)
8443 InheritException(exception,&layers->exception);
8444 *images=DestroyImageList(*images);
8446 layers=OptimizeImageLayers(*images,exception);
8447 if (layers == (Image *) NULL)
8452 InheritException(exception,&layers->exception);
8453 *images=DestroyImageList(*images);
8455 layers=(Image *) NULL;
8456 OptimizeImageTransparency(*images,exception);
8457 InheritException(exception,&(*images)->exception);
8458 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8461 case CompositeLayer:
8476 while (source != (Image *) NULL)
8478 source=GetNextImageInList(source);
8479 if ((source != (Image *) NULL) &&
8480 (LocaleCompare(source->magick,
"NULL") == 0))
8483 if (source != (Image *) NULL)
8485 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8486 (GetNextImageInList(source) == (Image *) NULL))
8487 source=(Image *) NULL;
8493 source=SplitImageList(source->previous);
8494 DeleteImageFromList(&source);
8497 if (source == (Image *) NULL)
8499 (void) ThrowMagickException(exception,GetMagickModule(),
8500 OptionError,
"MissingNullSeparator",
"layers Composite");
8507 SetGeometry(*images,&geometry);
8508 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8509 geometry.width=source->page.width != 0 ?
8510 source->page.width : source->columns;
8511 geometry.height=source->page.height != 0 ?
8512 source->page.height : source->rows;
8513 GravityAdjustGeometry((*images)->page.width != 0 ?
8514 (*images)->page.width : (*images)->columns,
8515 (*images)->page.height != 0 ? (*images)->page.height :
8516 (*images)->rows,(*images)->gravity,&geometry);
8517 compose=OverCompositeOp;
8518 option=GetImageOption(mogrify_info,
"compose");
8519 if (option != (
const char *) NULL)
8520 compose=(CompositeOperator) ParseCommandOption(
8521 MagickComposeOptions,MagickFalse,option);
8522 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8524 source=DestroyImageList(source);
8528 if (layers == (Image *) NULL)
8530 InheritException(exception,&layers->exception);
8531 *images=DestroyImageList(*images);
8539 if (LocaleCompare(
"map",option+1) == 0)
8541 (void) SyncImagesSettings(mogrify_info,*images);
8544 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8545 InheritException(exception,&(*images)->exception);
8551 if (LocaleCompare(
"maximum",option+1) == 0)
8559 (void) SyncImagesSettings(mogrify_info,*images);
8560 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8561 if (maximum_image == (Image *) NULL)
8566 *images=DestroyImageList(*images);
8567 *images=maximum_image;
8570 if (LocaleCompare(
"minimum",option+1) == 0)
8578 (void) SyncImagesSettings(mogrify_info,*images);
8579 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8580 if (minimum_image == (Image *) NULL)
8585 *images=DestroyImageList(*images);
8586 *images=minimum_image;
8589 if (LocaleCompare(
"morph",option+1) == 0)
8594 (void) SyncImagesSettings(mogrify_info,*images);
8595 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8597 if (morph_image == (Image *) NULL)
8602 *images=DestroyImageList(*images);
8603 *images=morph_image;
8606 if (LocaleCompare(
"mosaic",option+1) == 0)
8611 (void) SyncImagesSettings(mogrify_info,*images);
8612 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8613 if (mosaic_image == (Image *) NULL)
8618 *images=DestroyImageList(*images);
8619 *images=mosaic_image;
8626 if (LocaleCompare(
"poly",option+1) == 0)
8630 token[MaxTextExtent];
8650 (void) SyncImageSettings(mogrify_info,*images);
8651 args=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8652 InheritException(exception,&(*images)->exception);
8653 if (args == (
char *) NULL)
8656 for (x=0; *p !=
'\0'; x++)
8658 (void) GetNextToken(p,&p,MaxTextExtent,token);
8660 (void) GetNextToken(p,&p,MaxTextExtent,token);
8662 number_arguments=(size_t) x;
8663 arguments=(
double *) AcquireQuantumMemory(number_arguments,
8664 sizeof(*arguments));
8665 if (arguments == (
double *) NULL)
8666 ThrowWandFatalException(ResourceLimitFatalError,
8667 "MemoryAllocationFailed",(*images)->filename);
8668 (void) memset(arguments,0,number_arguments*
8669 sizeof(*arguments));
8671 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
8673 (void) GetNextToken(p,&p,MaxTextExtent,token);
8675 (void) GetNextToken(p,&p,MaxTextExtent,token);
8676 arguments[x]=StringToDouble(token,(
char **) NULL);
8678 args=DestroyString(args);
8679 polynomial_image=PolynomialImageChannel(*images,channel,
8680 number_arguments >> 1,arguments,exception);
8681 arguments=(
double *) RelinquishMagickMemory(arguments);
8682 if (polynomial_image == (Image *) NULL)
8687 *images=DestroyImageList(*images);
8688 *images=polynomial_image;
8691 if (LocaleCompare(
"print",option+1) == 0)
8696 (void) SyncImagesSettings(mogrify_info,*images);
8697 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8698 if (
string == (
char *) NULL)
8700 InheritException(exception,&(*images)->exception);
8701 (void) FormatLocaleFile(stdout,
"%s",
string);
8702 string=DestroyString(
string);
8704 if (LocaleCompare(
"process",option+1) == 0)
8713 (void) SyncImagesSettings(mogrify_info,*images);
8714 arguments=StringToArgv(argv[i+1],&number_arguments);
8715 if ((arguments == (
char **) NULL) || (number_arguments == 1))
8717 if ((argc > 1) && (strchr(arguments[1],
'=') != (
char *) NULL))
8740 length=strlen(argv[i+1]);
8741 token=(
char *) NULL;
8742 if (~length >= (MaxTextExtent-1))
8743 token=(
char *) AcquireQuantumMemory(length+MaxTextExtent,
8745 if (token == (
char *) NULL)
8748 arguments=argv[i+1];
8749 token_info=AcquireTokenInfo();
8750 status=Tokenizer(token_info,0,token,length,arguments,
"",
"=",
8751 "\"",
'\0',&breaker,&next,"e);
8752 token_info=DestroyTokenInfo(token_info);
8758 argv=(&(arguments[next]));
8759 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8762 token=DestroyString(token);
8765 (void) SubstituteString(&arguments[1],
"-",
"");
8766 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8767 number_arguments-2,(
const char **) arguments+2,exception);
8768 for (j=0; j < number_arguments; j++)
8769 arguments[j]=DestroyString(arguments[j]);
8770 arguments=(
char **) RelinquishMagickMemory(arguments);
8777 if (LocaleCompare(
"reverse",option+1) == 0)
8779 ReverseImageList(images);
8780 InheritException(exception,&(*images)->exception);
8787 if (LocaleCompare(
"smush",option+1) == 0)
8795 (void) SyncImagesSettings(mogrify_info,*images);
8796 offset=(ssize_t) StringToLong(argv[i+1]);
8797 smush_image=SmushImages(*images,*option ==
'-' ? MagickTrue :
8798 MagickFalse,offset,exception);
8799 if (smush_image == (Image *) NULL)
8804 *images=DestroyImageList(*images);
8805 *images=smush_image;
8808 if (LocaleCompare(
"swap",option+1) == 0)
8830 flags=ParseGeometry(argv[i+1],&geometry_info);
8831 index=(ssize_t) geometry_info.rho;
8832 if ((flags & SigmaValue) != 0)
8833 swap_index=(ssize_t) geometry_info.sigma;
8835 p=GetImageFromList(*images,index);
8836 q=GetImageFromList(*images,swap_index);
8837 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8839 (void) ThrowMagickException(exception,GetMagickModule(),
8840 OptionError,
"NoSuchImage",
"`%s'",(*images)->filename);
8846 u=CloneImage(p,0,0,MagickTrue,exception);
8847 if (u == (Image *) NULL)
8849 v=CloneImage(q,0,0,MagickTrue,exception);
8850 if (v == (Image *) NULL)
8855 ReplaceImageInList(&p,v);
8856 ReplaceImageInList(&q,u);
8857 *images=GetFirstImageInList(q);
8864 if (LocaleCompare(
"write",option+1) == 0)
8875 (void) SyncImagesSettings(mogrify_info,*images);
8876 (void) FormatLocaleString(key,MaxTextExtent,
"cache:%s",argv[i+1]);
8877 (void) DeleteImageRegistry(key);
8878 write_images=CloneImageList(*images,exception);
8879 write_info=CloneImageInfo(mogrify_info);
8880 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8881 write_info=DestroyImageInfo(write_info);
8882 write_images=DestroyImageList(write_images);
8892 quantize_info=DestroyQuantizeInfo(quantize_info);
8893 mogrify_info=DestroyImageInfo(mogrify_info);
8894 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8895 return(status != 0 ? MagickTrue : MagickFalse);
8935 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8936 const MagickBooleanType post,
const int argc,
const char **argv,
8937 Image **images,ExceptionInfo *exception)
8939 #define MogrifyImageTag "Mogrify/Image"
8953 assert(image_info != (ImageInfo *) NULL);
8954 assert(image_info->signature == MagickCoreSignature);
8955 if (images == (Image **) NULL)
8956 return(MogrifyImage(image_info,argc,argv,images,exception));
8957 assert((*images)->previous == (Image *) NULL);
8958 assert((*images)->signature == MagickCoreSignature);
8959 if (IsEventLogging() != MagickFalse)
8960 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
8961 (*images)->filename);
8962 if ((argc <= 0) || (*argv == (
char *) NULL))
8964 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8968 (void) FormatLocaleFile(stderr,
"mogrify start %s %d (%s)\n",argv[0],argc,
8974 if (post == MagickFalse)
8975 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8980 n=GetImageListLength(*images);
8984 (void) FormatLocaleFile(stderr,
"mogrify %ld of %ld\n",(
long)
8985 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8987 status&=MogrifyImage(image_info,argc,argv,images,exception);
8988 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8989 if (proceed == MagickFalse)
8991 if ((*images)->next == (Image *) NULL)
8993 *images=(*images)->next;
8996 assert(*images != (Image *) NULL);
8998 (void) FormatLocaleFile(stderr,
"mogrify end %ld of %ld\n",(
long)
8999 GetImageIndexInList(*images),(long)GetImageListLength(*images));
9004 *images=GetFirstImageInList(*images);
9005 if (post != MagickFalse)
9006 status&=MogrifyImageList(image_info,argc,argv,images,exception);
9007 return(status != 0 ? MagickTrue : MagickFalse);