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/image-private.h"
54 #include "magick/monitor-private.h"
55 #include "magick/pixel-private.h"
56 #include "magick/thread-private.h"
57 #include "magick/string-private.h"
58 #include "magick/timer-private.h"
59 #include "magick/utility-private.h"
60 #if defined(MAGICKCORE_HAVE_UTIME_H)
67 #define UndefinedCompressionQuality 0UL
73 MogrifyBackgroundColor[] =
"#fff",
74 MogrifyBorderColor[] =
"#dfdfdf",
75 MogrifyMatteColor[] =
"#bdbdbd";
117 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
118 MagickCommand command,
int argc,
char **argv,
char **metadata,
119 ExceptionInfo *exception)
143 (void) setlocale(LC_ALL,
"");
144 (void) setlocale(LC_NUMERIC,
"C");
145 concurrent=MagickFalse;
149 regard_warnings=MagickFalse;
150 for (i=1; i < (ssize_t) (argc-1); i++)
153 if ((strlen(option) == 1) || ((*option !=
'-') && (*option !=
'+')))
155 if (LocaleCompare(
"bench",option+1) == 0)
156 iterations=StringToUnsignedLong(argv[++i]);
157 if (LocaleCompare(
"concurrent",option+1) == 0)
158 concurrent=MagickTrue;
159 if (LocaleCompare(
"debug",option+1) == 0)
160 (
void) SetLogEventMask(argv[++i]);
161 if (LocaleCompare(
"distribute-cache",option+1) == 0)
163 DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
166 if (LocaleCompare(
"duration",option+1) == 0)
167 duration=StringToDouble(argv[++i],(
char **) NULL);
168 if (LocaleCompare(
"regard-warnings",option+1) == 0)
169 regard_warnings=MagickTrue;
173 status=command(image_info,argc,argv,metadata,exception);
174 if (exception->severity != UndefinedException)
176 if ((exception->severity > ErrorException) ||
177 (regard_warnings != MagickFalse))
179 CatchException(exception);
181 if ((metadata != (
char **) NULL) && (*metadata != (
char *) NULL))
183 (void) fputs(*metadata,stdout);
184 *metadata=DestroyString(*metadata);
188 number_threads=GetOpenMPMaximumThreads();
190 for (n=1; n <= (ssize_t) number_threads; n++)
200 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
201 timer=AcquireTimerInfo();
202 if (concurrent == MagickFalse)
204 for (i=0; i < (ssize_t) iterations; i++)
206 if (status == MagickFalse)
210 if (GetElapsedTime(timer) > duration)
212 (void) ContinueTimer(timer);
214 status=command(image_info,argc,argv,metadata,exception);
215 if (exception->severity != UndefinedException)
217 if ((exception->severity > ErrorException) ||
218 (regard_warnings != MagickFalse))
220 CatchException(exception);
222 if ((metadata != (
char **) NULL) && (*metadata != (
char *) NULL))
224 (void) fputs(*metadata,stdout);
225 *metadata=DestroyString(*metadata);
232 #if defined(MAGICKCORE_OPENMP_SUPPORT)
233 # pragma omp parallel for shared(status)
235 for (i=0; i < (ssize_t) iterations; i++)
237 if (status == MagickFalse)
241 if (GetElapsedTime(timer) > duration)
243 (void) ContinueTimer(timer);
245 status=command(image_info,argc,argv,metadata,exception);
246 #if defined(MAGICKCORE_OPENMP_SUPPORT)
247 # pragma omp critical (MagickCore_MagickCommandGenesis)
250 if (exception->severity != UndefinedException)
252 if ((exception->severity > ErrorException) ||
253 (regard_warnings != MagickFalse))
255 CatchException(exception);
257 if ((metadata != (
char **) NULL) && (*metadata != (
char *) NULL))
259 (void) fputs(*metadata,stdout);
260 *metadata=DestroyString(*metadata);
265 user_time=GetUserTime(timer);
266 parallel=GetElapsedTime(timer);
271 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
272 (
double) n)))-(1.0/(
double) n))/(1.0-1.0/(double) n);
273 (void) FormatLocaleFile(stderr,
274 " Performance[%.20g]: %.20gi %0.3fips %0.6fe %0.6fu %lu:%02lu.%03lu\n",
275 (
double) n,(double) iterations,(
double) iterations/parallel,e,user_time,
276 (
unsigned long) (parallel/60.0),(
unsigned long) floor(fmod(parallel,
277 60.0)),(
unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
278 timer=DestroyTimerInfo(timer);
342 static inline Image *GetImageCache(const ImageInfo *image_info,const
char *path,
343 ExceptionInfo *exception)
361 (void) FormatLocaleString(key,MaxTextExtent,
"cache:%s",path);
362 sans_exception=AcquireExceptionInfo();
363 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
364 sans_exception=DestroyExceptionInfo(sans_exception);
365 if (image != (Image *) NULL)
367 read_info=CloneImageInfo(image_info);
368 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
369 image=ReadImage(read_info,exception);
370 read_info=DestroyImageInfo(read_info);
371 if (image != (Image *) NULL)
372 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
376 static inline MagickBooleanType IsPathWritable(
const char *path)
378 if (IsPathAccessible(path) == MagickFalse)
380 if (access_utf8(path,W_OK) != 0)
385 static MagickBooleanType MonitorProgress(
const char *text,
386 const MagickOffsetType offset,
const MagickSizeType extent,
387 void *wand_unused(client_data))
390 message[MaxTextExtent],
399 wand_unreferenced(client_data);
401 if ((extent <= 1) || (offset < 0) || (offset >= (MagickOffsetType) extent))
403 if ((offset != (MagickOffsetType) (extent-1)) && ((offset % 50) != 0))
405 (void) CopyMagickString(tag,text,MaxTextExtent);
407 if (p != (
char *) NULL)
409 (void) FormatLocaleString(message,MaxTextExtent,
"Monitor/%s",tag);
410 locale_message=GetLocaleMessage(message);
411 if (locale_message == message)
413 if (p == (
char *) NULL)
414 (void) FormatLocaleFile(stderr,
"%s: %ld of %lu, %02ld%% complete\r",
415 locale_message,(
long) offset,(
unsigned long) extent,(
long)
416 (100L*offset/(extent-1)));
418 (
void) FormatLocaleFile(stderr,
"%s[%s]: %ld of %lu, %02ld%% complete\r",
419 locale_message,p+1,(
long) offset,(
unsigned long) extent,(
long)
420 (100L*offset/(extent-1)));
421 if (offset == (MagickOffsetType) (extent-1))
422 (void) FormatLocaleFile(stderr,
"\n");
423 (void) fflush(stderr);
427 static Image *SparseColorOption(
const Image *image,
const ChannelType channel,
428 const SparseColorMethod method,
const char *arguments,
429 const MagickBooleanType color_from_image,ExceptionInfo *exception)
435 token[MaxTextExtent];
466 assert(image != (Image *) NULL);
467 assert(image->signature == MagickCoreSignature);
468 assert(exception != (ExceptionInfo *) NULL);
469 assert(exception->signature == MagickCoreSignature);
470 if (IsEventLogging() != MagickFalse)
471 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
476 if (image->colorspace != CMYKColorspace)
477 channels=(ChannelType) (channels & ~IndexChannel);
478 if (image->matte == MagickFalse)
479 channels=(ChannelType) (channels & ~OpacityChannel);
481 if ((channels & RedChannel) != 0)
483 if ((channels & GreenChannel) != 0)
485 if ((channels & BlueChannel) != 0)
487 if ((channels & IndexChannel) != 0)
489 if ((channels & OpacityChannel) != 0)
499 (void) GetNextToken(p,&p,MaxTextExtent,token);
500 if ( *token ==
',' )
continue;
501 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
502 if ( color_from_image ) {
503 (void) ThrowMagickException(exception,GetMagickModule(),
504 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
505 "Color arg given, when colors are coming from image");
506 return( (Image *) NULL);
515 if ( color_from_image ) {
517 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
518 number_arguments=(x/2)*(2+number_colors);
522 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
526 (void) ThrowMagickException(exception,GetMagickModule(),
527 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
528 "Invalid number of Arguments");
529 return( (Image *) NULL);
533 sparse_arguments=(
double *) AcquireQuantumMemory(number_arguments,
534 sizeof(*sparse_arguments));
535 if (sparse_arguments == (
double *) NULL) {
536 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
537 " MemoryAllocationFailed\n""%s",
"SparseColorOption");
538 return( (Image *) NULL);
540 (void) memset(sparse_arguments,0,number_arguments*
541 sizeof(*sparse_arguments));
544 while( *p !=
'\0' && x < number_arguments ) {
547 while ( *token ==
',' )
548 (void) GetNextToken(p,&p,MaxTextExtent,token);
549 if ( *token ==
'\0' )
break;
550 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
551 (void) ThrowMagickException(exception,GetMagickModule(),
552 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
553 "Color found, instead of X-coord");
557 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
559 *token=
',';
while ( *token ==
',' ) GetNextToken(p,&p,MaxTextExtent,token);
560 if ( *token ==
'\0' )
break;
561 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
562 (void) ThrowMagickException(exception,GetMagickModule(),
563 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
564 "Color found, instead of Y-coord");
568 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
571 if ( (color_from_image ) {
580 while ( *token ==
',' )
581 (
void) GetNextToken(p,&p,MaxTextExtent,token);
582 if ( *token ==
'\0' )
break;
583 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
585 (void) QueryMagickColor(token,&color,exception);
586 if ( channels & RedChannel )
587 sparse_arguments[x++] = QuantumScale*color.red;
588 if ( channels & GreenChannel )
589 sparse_arguments[x++] = QuantumScale*color.green;
590 if ( channels & BlueChannel )
591 sparse_arguments[x++] = QuantumScale*color.blue;
592 if ( channels & IndexChannel )
593 sparse_arguments[x++] = QuantumScale*color.index;
594 if ( channels & OpacityChannel )
595 sparse_arguments[x++] = QuantumScale*color.opacity;
600 if ( channels & RedChannel ) {
601 while ( *token ==
',' )
602 (void) GetNextToken(p,&p,MaxTextExtent,token);
603 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
605 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
608 if ( channels & GreenChannel ) {
609 while ( *token ==
',' )
610 (void) GetNextToken(p,&p,MaxTextExtent,token);
611 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
613 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
616 if ( channels & BlueChannel ) {
617 while ( *token ==
',' )
618 (void) GetNextToken(p,&p,MaxTextExtent,token);
619 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
621 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
624 if ( channels & IndexChannel ) {
625 while ( *token ==
',' )
626 (void) GetNextToken(p,&p,MaxTextExtent,token);
627 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
629 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
632 if ( channels & OpacityChannel ) {
633 while ( *token ==
',' )
634 (void) GetNextToken(p,&p,MaxTextExtent,token);
635 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
637 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
643 if ( number_arguments != x && !error ) {
644 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
645 " InvalidArgument",
"`%s': %s",
"sparse-color",
"Argument Parsing Error");
646 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
647 return( (Image *) NULL);
650 return( (Image *) NULL);
653 sparse_image=SparseColorImage(image,channels,method,number_arguments,
654 sparse_arguments,exception);
655 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
656 return( sparse_image );
659 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,
const int argc,
660 const char **argv,Image **image,ExceptionInfo *exception)
703 assert(image_info != (
const ImageInfo *) NULL);
704 assert(image_info->signature == MagickCoreSignature);
705 assert(image != (Image **) NULL);
706 assert((*image)->signature == MagickCoreSignature);
707 if (IsEventLogging() != MagickFalse)
708 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
711 mogrify_info=CloneImageInfo(image_info);
712 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
713 quantize_info=AcquireQuantizeInfo(mogrify_info);
714 SetGeometryInfo(&geometry_info);
715 GetMagickPixelPacket(*image,&fill);
716 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
718 channel=mogrify_info->channel;
719 format=GetImageOption(mogrify_info,
"format");
720 SetGeometry(*image,®ion_geometry);
721 region_image=NewImageList();
725 for (i=0; i < (ssize_t) argc; i++)
734 if (IsCommandOption(option) == MagickFalse)
736 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
738 if ((i+count) >= (ssize_t) argc)
740 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
741 mogrify_image=(Image *) NULL;
746 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
751 (void) SyncImageSettings(mogrify_info,*image);
752 flags=ParseGeometry(argv[i+1],&geometry_info);
753 if ((flags & SigmaValue) == 0)
754 geometry_info.sigma=1.0;
755 mogrify_image=AdaptiveBlurImageChannel(*image,channel,
756 geometry_info.rho,geometry_info.sigma,exception);
759 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
764 (void) SyncImageSettings(mogrify_info,*image);
765 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
766 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
767 geometry.height,exception);
770 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
775 (void) SyncImageSettings(mogrify_info,*image);
776 flags=ParseGeometry(argv[i+1],&geometry_info);
777 if ((flags & SigmaValue) == 0)
778 geometry_info.sigma=1.0;
779 mogrify_image=AdaptiveSharpenImageChannel(*image,channel,
780 geometry_info.rho,geometry_info.sigma,exception);
783 if (LocaleCompare(
"affine",option+1) == 0)
790 GetAffineMatrix(&draw_info->affine);
793 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
796 if (LocaleCompare(
"alpha",option+1) == 0)
801 (void) SyncImageSettings(mogrify_info,*image);
802 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
803 MagickFalse,argv[i+1]);
804 (void) SetImageAlphaChannel(*image,alpha_type);
805 InheritException(exception,&(*image)->exception);
808 if (LocaleCompare(
"annotate",option+1) == 0)
812 geometry[MaxTextExtent];
817 (void) SyncImageSettings(mogrify_info,*image);
818 SetGeometryInfo(&geometry_info);
819 flags=ParseGeometry(argv[i+1],&geometry_info);
820 if ((flags & SigmaValue) == 0)
821 geometry_info.sigma=geometry_info.rho;
822 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
823 InheritException(exception,&(*image)->exception);
824 if (text == (
char *) NULL)
826 (void) CloneString(&draw_info->text,text);
827 text=DestroyString(text);
828 (void) FormatLocaleString(geometry,MaxTextExtent,
"%+f%+f",
829 geometry_info.xi,geometry_info.psi);
830 (void) CloneString(&draw_info->geometry,geometry);
831 draw_info->affine.sx=cos(DegreesToRadians(
832 fmod(geometry_info.rho,360.0)));
833 draw_info->affine.rx=sin(DegreesToRadians(
834 fmod(geometry_info.rho,360.0)));
835 draw_info->affine.ry=(-sin(DegreesToRadians(
836 fmod(geometry_info.sigma,360.0))));
837 draw_info->affine.sy=cos(DegreesToRadians(
838 fmod(geometry_info.sigma,360.0)));
839 (void) AnnotateImage(*image,draw_info);
840 InheritException(exception,&(*image)->exception);
843 if (LocaleCompare(
"antialias",option+1) == 0)
845 draw_info->stroke_antialias=(*option ==
'-') ? MagickTrue :
847 draw_info->text_antialias=(*option ==
'-') ? MagickTrue :
851 if (LocaleCompare(
"auto-gamma",option+1) == 0)
856 (void) SyncImageSettings(mogrify_info,*image);
857 (void) AutoGammaImageChannel(*image,channel);
860 if (LocaleCompare(
"auto-level",option+1) == 0)
865 (void) SyncImageSettings(mogrify_info,*image);
866 (void) AutoLevelImageChannel(*image,channel);
869 if (LocaleCompare(
"auto-orient",option+1) == 0)
871 (void) SyncImageSettings(mogrify_info,*image);
872 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
880 if (LocaleCompare(
"black-threshold",option+1) == 0)
885 (void) SyncImageSettings(mogrify_info,*image);
886 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
888 InheritException(exception,&(*image)->exception);
891 if (LocaleCompare(
"blue-shift",option+1) == 0)
896 (void) SyncImageSettings(mogrify_info,*image);
897 geometry_info.rho=1.5;
899 flags=ParseGeometry(argv[i+1],&geometry_info);
900 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
903 if (LocaleCompare(
"blur",option+1) == 0)
908 (void) SyncImageSettings(mogrify_info,*image);
909 flags=ParseGeometry(argv[i+1],&geometry_info);
910 if ((flags & SigmaValue) == 0)
911 geometry_info.sigma=1.0;
912 mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho,
913 geometry_info.sigma,exception);
916 if (LocaleCompare(
"border",option+1) == 0)
921 (void) SyncImageSettings(mogrify_info,*image);
922 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
923 mogrify_image=BorderImage(*image,&geometry,exception);
926 if (LocaleCompare(
"bordercolor",option+1) == 0)
930 (void) QueryColorDatabase(MogrifyBorderColor,
931 &draw_info->border_color,exception);
934 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
938 if (LocaleCompare(
"box",option+1) == 0)
940 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
944 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
959 (void) SyncImageSettings(mogrify_info,*image);
960 flags=ParseGeometry(argv[i+1],&geometry_info);
961 brightness=geometry_info.rho;
963 if ((flags & SigmaValue) != 0)
964 contrast=geometry_info.sigma;
965 (void) BrightnessContrastImageChannel(*image,channel,brightness,
967 InheritException(exception,&(*image)->exception);
974 if (LocaleCompare(
"canny",option+1) == 0)
979 (void) SyncImageSettings(mogrify_info,*image);
980 flags=ParseGeometry(argv[i+1],&geometry_info);
981 if ((flags & SigmaValue) == 0)
982 geometry_info.sigma=1.0;
983 if ((flags & XiValue) == 0)
984 geometry_info.xi=0.10;
985 if ((flags & PsiValue) == 0)
986 geometry_info.psi=0.30;
987 if ((flags & PercentValue) != 0)
989 geometry_info.xi/=100.0;
990 geometry_info.psi/=100.0;
992 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
993 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
996 if (LocaleCompare(
"cdl",option+1) == 0)
999 *color_correction_collection;
1004 (void) SyncImageSettings(mogrify_info,*image);
1005 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
1006 if (color_correction_collection == (
char *) NULL)
1008 (void) ColorDecisionListImage(*image,color_correction_collection);
1009 InheritException(exception,&(*image)->exception);
1012 if (LocaleCompare(
"channel",option+1) == 0)
1015 channel=DefaultChannels;
1017 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1020 if (LocaleCompare(
"charcoal",option+1) == 0)
1025 (void) SyncImageSettings(mogrify_info,*image);
1026 flags=ParseGeometry(argv[i+1],&geometry_info);
1027 if ((flags & SigmaValue) == 0)
1028 geometry_info.sigma=1.0;
1029 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1030 geometry_info.sigma,exception);
1033 if (LocaleCompare(
"chop",option+1) == 0)
1038 (void) SyncImageSettings(mogrify_info,*image);
1039 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1040 mogrify_image=ChopImage(*image,&geometry,exception);
1043 if (LocaleCompare(
"clamp",option+1) == 0)
1048 (void) SyncImageSettings(mogrify_info,*image);
1049 (void) ClampImageChannel(*image,channel);
1050 InheritException(exception,&(*image)->exception);
1053 if (LocaleCompare(
"clip",option+1) == 0)
1055 (void) SyncImageSettings(mogrify_info,*image);
1058 (void) SetImageClipMask(*image,(Image *) NULL);
1059 InheritException(exception,&(*image)->exception);
1062 (void) ClipImage(*image);
1063 InheritException(exception,&(*image)->exception);
1066 if (LocaleCompare(
"clip-mask",option+1) == 0)
1083 (void) SyncImageSettings(mogrify_info,*image);
1089 (void) SetImageMask(*image,(Image *) NULL);
1090 InheritException(exception,&(*image)->exception);
1097 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1098 if (mask_image == (Image *) NULL)
1100 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1101 return(MagickFalse);
1102 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1103 for (y=0; y < (ssize_t) mask_image->rows; y++)
1105 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1107 if (q == (PixelPacket *) NULL)
1109 for (x=0; x < (ssize_t) mask_image->columns; x++)
1111 if (mask_image->matte == MagickFalse)
1112 SetPixelOpacity(q,ClampToQuantum(GetPixelIntensity(mask_image,
1114 SetPixelRed(q,GetPixelOpacity(q));
1115 SetPixelGreen(q,GetPixelOpacity(q));
1116 SetPixelBlue(q,GetPixelOpacity(q));
1119 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1122 mask_view=DestroyCacheView(mask_view);
1123 mask_image->matte=MagickTrue;
1124 (void) SetImageClipMask(*image,mask_image);
1125 mask_image=DestroyImage(mask_image);
1126 InheritException(exception,&(*image)->exception);
1129 if (LocaleCompare(
"clip-path",option+1) == 0)
1131 (void) SyncImageSettings(mogrify_info,*image);
1132 (void) ClipImagePath(*image,argv[i+1],*option ==
'-' ? MagickTrue :
1134 InheritException(exception,&(*image)->exception);
1137 if (LocaleCompare(
"colorize",option+1) == 0)
1142 (void) SyncImageSettings(mogrify_info,*image);
1143 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1147 if (LocaleCompare(
"color-matrix",option+1) == 0)
1152 (void) SyncImageSettings(mogrify_info,*image);
1153 kernel=AcquireKernelInfo(argv[i+1]);
1154 if (kernel == (KernelInfo *) NULL)
1156 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1157 kernel=DestroyKernelInfo(kernel);
1160 if (LocaleCompare(
"colors",option+1) == 0)
1165 (void) SyncImageSettings(mogrify_info,*image);
1166 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1167 if (quantize_info->number_colors == 0)
1169 if (((*image)->storage_class == DirectClass) ||
1170 (*image)->colors > quantize_info->number_colors)
1171 (void) QuantizeImage(quantize_info,*image);
1173 (
void) CompressImageColormap(*image);
1174 InheritException(exception,&(*image)->exception);
1177 if (LocaleCompare(
"colorspace",option+1) == 0)
1182 (void) SyncImageSettings(mogrify_info,*image);
1185 (void) TransformImageColorspace(*image,sRGBColorspace);
1186 InheritException(exception,&(*image)->exception);
1189 colorspace=(ColorspaceType) ParseCommandOption(
1190 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1191 (void) TransformImageColorspace(*image,colorspace);
1192 InheritException(exception,&(*image)->exception);
1195 if (LocaleCompare(
"connected-components",option+1) == 0)
1197 (void) SyncImageSettings(mogrify_info,*image);
1198 mogrify_image=ConnectedComponentsImage(*image,
1199 (
size_t) StringToInteger(argv[i+1]),exception);
1202 if (LocaleCompare(
"contrast",option+1) == 0)
1204 (void) SyncImageSettings(mogrify_info,*image);
1205 (void) ContrastImage(*image,(*option ==
'-') ? MagickTrue :
1207 InheritException(exception,&(*image)->exception);
1210 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
1222 (void) SyncImageSettings(mogrify_info,*image);
1223 flags=ParseGeometry(argv[i+1],&geometry_info);
1224 black_point=geometry_info.rho;
1225 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1227 if ((flags & PercentValue) != 0)
1229 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1230 white_point*=(
double) (*image)->columns*(*image)->rows/100.0;
1232 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1234 (
void) ContrastStretchImageChannel(*image,channel,black_point,
1236 InheritException(exception,&(*image)->exception);
1239 if (LocaleCompare(
"convolve",option+1) == 0)
1253 (void) SyncImageSettings(mogrify_info,*image);
1254 kernel_info=AcquireKernelInfo(argv[i+1]);
1255 if (kernel_info == (KernelInfo *) NULL)
1257 extent=kernel_info->width*kernel_info->height;
1259 for (j=0; j < (ssize_t) extent; j++)
1260 gamma+=kernel_info->values[j];
1261 gamma=1.0/(fabs((
double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1262 for (j=0; j < (ssize_t) extent; j++)
1263 kernel_info->values[j]*=gamma;
1264 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1265 kernel_info,exception);
1266 kernel_info=DestroyKernelInfo(kernel_info);
1269 if (LocaleCompare(
"crop",option+1) == 0)
1274 (void) SyncImageSettings(mogrify_info,*image);
1276 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1277 if (((geometry.width != 0) || (geometry.height != 0)) &&
1278 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1282 mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
1283 mogrify_image->next = mogrify_image->previous = (Image *) NULL;
1284 (void) TransformImage(&mogrify_image,argv[i+1],(
char *) NULL);
1285 InheritException(exception,&mogrify_image->exception);
1287 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1291 if (LocaleCompare(
"cycle",option+1) == 0)
1296 (void) SyncImageSettings(mogrify_info,*image);
1297 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]));
1298 InheritException(exception,&(*image)->exception);
1305 if (LocaleCompare(
"decipher",option+1) == 0)
1313 (void) SyncImageSettings(mogrify_info,*image);
1314 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1315 if (passkey != (StringInfo *) NULL)
1317 (void) PasskeyDecipherImage(*image,passkey,exception);
1318 passkey=DestroyStringInfo(passkey);
1322 if (LocaleCompare(
"density",option+1) == 0)
1327 (void) CloneString(&draw_info->density,argv[i+1]);
1330 if (LocaleCompare(
"depth",option+1) == 0)
1332 (void) SyncImageSettings(mogrify_info,*image);
1335 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1338 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1341 if (LocaleCompare(
"deskew",option+1) == 0)
1349 (void) SyncImageSettings(mogrify_info,*image);
1351 threshold=40.0*QuantumRange/100.0;
1353 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
1355 mogrify_image=DeskewImage(*image,threshold,exception);
1358 if (LocaleCompare(
"despeckle",option+1) == 0)
1363 (void) SyncImageSettings(mogrify_info,*image);
1364 mogrify_image=DespeckleImage(*image,exception);
1367 if (LocaleCompare(
"display",option+1) == 0)
1369 (void) CloneString(&draw_info->server_name,argv[i+1]);
1372 if (LocaleCompare(
"distort",option+1) == 0)
1376 token[MaxTextExtent];
1396 (void) SyncImageSettings(mogrify_info,*image);
1397 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1398 MagickFalse,argv[i+1]);
1399 if (method == ResizeDistortion)
1407 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1409 resize_args[0]=(double) geometry.width;
1410 resize_args[1]=(
double) geometry.height;
1411 mogrify_image=DistortImage(*image,method,(
size_t) 2,
1412 resize_args,MagickTrue,exception);
1415 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1416 InheritException(exception,&(*image)->exception);
1417 if (args == (
char *) NULL)
1420 for (x=0; *p !=
'\0'; x++)
1422 (void) GetNextToken(p,&p,MaxTextExtent,token);
1424 (void) GetNextToken(p,&p,MaxTextExtent,token);
1426 number_arguments=(size_t) x;
1427 arguments=(
double *) AcquireQuantumMemory(number_arguments,
1428 sizeof(*arguments));
1429 if (arguments == (
double *) NULL)
1430 ThrowWandFatalException(ResourceLimitFatalError,
1431 "MemoryAllocationFailed",(*image)->filename);
1432 (void) memset(arguments,0,number_arguments*
sizeof(*arguments));
1434 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
1436 (void) GetNextToken(p,&p,MaxTextExtent,token);
1438 (void) GetNextToken(p,&p,MaxTextExtent,token);
1439 arguments[x]=StringToDouble(token,(
char **) NULL);
1441 args=DestroyString(args);
1442 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1443 (*option ==
'+') ? MagickTrue : MagickFalse,exception);
1444 arguments=(
double *) RelinquishMagickMemory(arguments);
1447 if (LocaleCompare(
"dither",option+1) == 0)
1451 quantize_info->dither=MagickFalse;
1454 quantize_info->dither=MagickTrue;
1455 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1456 MagickDitherOptions,MagickFalse,argv[i+1]);
1457 if (quantize_info->dither_method == NoDitherMethod)
1458 quantize_info->dither=MagickFalse;
1461 if (LocaleCompare(
"draw",option+1) == 0)
1466 (void) SyncImageSettings(mogrify_info,*image);
1467 (void) CloneString(&draw_info->primitive,argv[i+1]);
1468 (void) DrawImage(*image,draw_info);
1469 InheritException(exception,&(*image)->exception);
1476 if (LocaleCompare(
"edge",option+1) == 0)
1481 (void) SyncImageSettings(mogrify_info,*image);
1482 flags=ParseGeometry(argv[i+1],&geometry_info);
1483 if ((flags & SigmaValue) == 0)
1484 geometry_info.sigma=1.0;
1485 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1488 if (LocaleCompare(
"emboss",option+1) == 0)
1493 (void) SyncImageSettings(mogrify_info,*image);
1494 flags=ParseGeometry(argv[i+1],&geometry_info);
1495 if ((flags & SigmaValue) == 0)
1496 geometry_info.sigma=1.0;
1497 mogrify_image=EmbossImage(*image,geometry_info.rho,
1498 geometry_info.sigma,exception);
1501 if (LocaleCompare(
"encipher",option+1) == 0)
1509 (void) SyncImageSettings(mogrify_info,*image);
1510 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1511 if (passkey != (StringInfo *) NULL)
1513 (void) PasskeyEncipherImage(*image,passkey,exception);
1514 passkey=DestroyStringInfo(passkey);
1518 if (LocaleCompare(
"encoding",option+1) == 0)
1520 (void) CloneString(&draw_info->encoding,argv[i+1]);
1523 if (LocaleCompare(
"enhance",option+1) == 0)
1528 (void) SyncImageSettings(mogrify_info,*image);
1529 mogrify_image=EnhanceImage(*image,exception);
1532 if (LocaleCompare(
"equalize",option+1) == 0)
1537 (void) SyncImageSettings(mogrify_info,*image);
1538 (void) EqualizeImageChannel(*image,channel);
1539 InheritException(exception,&(*image)->exception);
1542 if (LocaleCompare(
"evaluate",option+1) == 0)
1547 MagickEvaluateOperator
1550 (void) SyncImageSettings(mogrify_info,*image);
1551 op=(MagickEvaluateOperator) ParseCommandOption(
1552 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1553 constant=StringToDoubleInterval(argv[i+2],(
double) QuantumRange+
1555 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1558 if (LocaleCompare(
"extent",option+1) == 0)
1563 (void) SyncImageSettings(mogrify_info,*image);
1564 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1565 if (geometry.width == 0)
1566 geometry.width=(*image)->columns;
1567 if (geometry.height == 0)
1568 geometry.height=(*image)->rows;
1569 mogrify_image=ExtentImage(*image,&geometry,exception);
1576 if (LocaleCompare(
"family",option+1) == 0)
1580 if (draw_info->family != (
char *) NULL)
1581 draw_info->family=DestroyString(draw_info->family);
1584 (void) CloneString(&draw_info->family,argv[i+1]);
1587 if (LocaleCompare(
"features",option+1) == 0)
1591 (void) DeleteImageArtifact(*image,
"identify:features");
1594 (void) SetImageArtifact(*image,
"identify:features",argv[i+1]);
1595 (void) SetImageArtifact(*image,
"verbose",
"true");
1598 if (LocaleCompare(
"fill",option+1) == 0)
1603 GetMagickPixelPacket(*image,&fill);
1606 (void) QueryMagickColor(
"none",&fill,exception);
1607 (void) QueryColorDatabase(
"none",&draw_info->fill,exception);
1608 if (draw_info->fill_pattern != (Image *) NULL)
1609 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1612 sans=AcquireExceptionInfo();
1613 (void) QueryMagickColor(argv[i+1],&fill,sans);
1614 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1615 sans=DestroyExceptionInfo(sans);
1616 if (status == MagickFalse)
1617 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1621 if (LocaleCompare(
"flip",option+1) == 0)
1626 (void) SyncImageSettings(mogrify_info,*image);
1627 mogrify_image=FlipImage(*image,exception);
1630 if (LocaleCompare(
"floodfill",option+1) == 0)
1638 (void) SyncImageSettings(mogrify_info,*image);
1639 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1640 (void) QueryMagickColor(argv[i+2],&target,exception);
1641 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1642 geometry.x,geometry.y,*option ==
'-' ? MagickFalse : MagickTrue);
1643 InheritException(exception,&(*image)->exception);
1646 if (LocaleCompare(
"flop",option+1) == 0)
1651 (void) SyncImageSettings(mogrify_info,*image);
1652 mogrify_image=FlopImage(*image,exception);
1655 if (LocaleCompare(
"font",option+1) == 0)
1659 if (draw_info->font != (
char *) NULL)
1660 draw_info->font=DestroyString(draw_info->font);
1663 (void) CloneString(&draw_info->font,argv[i+1]);
1666 if (LocaleCompare(
"format",option+1) == 0)
1671 if (LocaleCompare(
"frame",option+1) == 0)
1679 (void) SyncImageSettings(mogrify_info,*image);
1680 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1681 frame_info.width=geometry.width;
1682 frame_info.height=geometry.height;
1683 frame_info.outer_bevel=geometry.x;
1684 frame_info.inner_bevel=geometry.y;
1685 frame_info.x=(ssize_t) frame_info.width;
1686 frame_info.y=(ssize_t) frame_info.height;
1687 frame_info.width=(*image)->columns+2*frame_info.width;
1688 frame_info.height=(*image)->rows+2*frame_info.height;
1689 mogrify_image=FrameImage(*image,&frame_info,exception);
1692 if (LocaleCompare(
"function",option+1) == 0)
1696 token[MaxTextExtent];
1716 (void) SyncImageSettings(mogrify_info,*image);
1717 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1718 MagickFalse,argv[i+1]);
1719 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1720 InheritException(exception,&(*image)->exception);
1721 if (arguments == (
char *) NULL)
1723 p=(
char *) arguments;
1724 for (x=0; *p !=
'\0'; x++)
1726 (void) GetNextToken(p,&p,MaxTextExtent,token);
1728 (void) GetNextToken(p,&p,MaxTextExtent,token);
1730 number_parameters=(size_t) x;
1731 parameters=(
double *) AcquireQuantumMemory(number_parameters,
1732 sizeof(*parameters));
1733 if (parameters == (
double *) NULL)
1734 ThrowWandFatalException(ResourceLimitFatalError,
1735 "MemoryAllocationFailed",(*image)->filename);
1736 (void) memset(parameters,0,number_parameters*
1737 sizeof(*parameters));
1738 p=(
char *) arguments;
1739 for (x=0; (x < (ssize_t) number_parameters) && (*p !=
'\0'); x++)
1741 (void) GetNextToken(p,&p,MaxTextExtent,token);
1743 (void) GetNextToken(p,&p,MaxTextExtent,token);
1744 parameters[x]=StringToDouble(token,(
char **) NULL);
1746 arguments=DestroyString(arguments);
1747 (void) FunctionImageChannel(*image,channel,
function,
1748 number_parameters,parameters,exception);
1749 parameters=(
double *) RelinquishMagickMemory(parameters);
1756 if (LocaleCompare(
"gamma",option+1) == 0)
1761 (void) SyncImageSettings(mogrify_info,*image);
1763 (*image)->gamma=StringToDouble(argv[i+1],(
char **) NULL);
1766 if (strchr(argv[i+1],
',') != (
char *) NULL)
1767 (void) GammaImage(*image,argv[i+1]);
1769 (
void) GammaImageChannel(*image,channel,
1770 StringToDouble(argv[i+1],(
char **) NULL));
1771 InheritException(exception,&(*image)->exception);
1775 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
1776 (LocaleCompare(
"gaussian",option+1) == 0))
1781 (void) SyncImageSettings(mogrify_info,*image);
1782 flags=ParseGeometry(argv[i+1],&geometry_info);
1783 if ((flags & SigmaValue) == 0)
1784 geometry_info.sigma=1.0;
1785 mogrify_image=GaussianBlurImageChannel(*image,channel,
1786 geometry_info.rho,geometry_info.sigma,exception);
1789 if (LocaleCompare(
"geometry",option+1) == 0)
1794 (void) SyncImageSettings(mogrify_info,*image);
1797 if ((*image)->geometry != (
char *) NULL)
1798 (*image)->geometry=DestroyString((*image)->geometry);
1801 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1802 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1803 (void) CloneString(&(*image)->geometry,argv[i+1]);
1805 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1806 (*image)->filter,(*image)->blur,exception);
1809 if (LocaleCompare(
"gravity",option+1) == 0)
1813 draw_info->gravity=UndefinedGravity;
1816 draw_info->gravity=(GravityType) ParseCommandOption(
1817 MagickGravityOptions,MagickFalse,argv[i+1]);
1820 if (LocaleCompare(
"grayscale",option+1) == 0)
1822 PixelIntensityMethod
1825 (void) SyncImagesSettings(mogrify_info,*image);
1826 method=(PixelIntensityMethod) ParseCommandOption(
1827 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1828 (void) GrayscaleImage(*image,method);
1829 InheritException(exception,&(*image)->exception);
1836 if (LocaleCompare(
"highlight-color",option+1) == 0)
1838 (void) SetImageArtifact(*image,
"compare:highlight-color",argv[i+1]);
1841 if (LocaleCompare(
"hough-lines",option+1) == 0)
1846 (void) SyncImageSettings(mogrify_info,*image);
1847 flags=ParseGeometry(argv[i+1],&geometry_info);
1848 if ((flags & SigmaValue) == 0)
1849 geometry_info.sigma=geometry_info.rho;
1850 if ((flags & XiValue) == 0)
1851 geometry_info.xi=40;
1852 mogrify_image=HoughLineImage(*image,(
size_t) geometry_info.rho,
1853 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,exception);
1860 if (LocaleCompare(
"identify",option+1) == 0)
1865 (void) SyncImageSettings(mogrify_info,*image);
1866 if (format == (
char *) NULL)
1868 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1869 InheritException(exception,&(*image)->exception);
1872 text=InterpretImageProperties(mogrify_info,*image,format);
1873 InheritException(exception,&(*image)->exception);
1874 if (text == (
char *) NULL)
1876 (void) fputs(text,stdout);
1877 text=DestroyString(text);
1880 if (LocaleCompare(
"implode",option+1) == 0)
1885 (void) SyncImageSettings(mogrify_info,*image);
1886 (void) ParseGeometry(argv[i+1],&geometry_info);
1887 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1890 if (LocaleCompare(
"interline-spacing",option+1) == 0)
1893 (void) ParseGeometry(
"0",&geometry_info);
1895 (
void) ParseGeometry(argv[i+1],&geometry_info);
1896 draw_info->interline_spacing=geometry_info.rho;
1899 if (LocaleCompare(
"interword-spacing",option+1) == 0)
1902 (void) ParseGeometry(
"0",&geometry_info);
1904 (
void) ParseGeometry(argv[i+1],&geometry_info);
1905 draw_info->interword_spacing=geometry_info.rho;
1908 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
1913 (void) SyncImageSettings(mogrify_info,*image);
1914 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1915 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1916 geometry.height,(*image)->interpolate,exception);
1923 if (LocaleCompare(
"kerning",option+1) == 0)
1926 (void) ParseGeometry(
"0",&geometry_info);
1928 (
void) ParseGeometry(argv[i+1],&geometry_info);
1929 draw_info->kerning=geometry_info.rho;
1932 if (LocaleCompare(
"kuwahara",option+1) == 0)
1937 (void) SyncImageSettings(mogrify_info,*image);
1938 flags=ParseGeometry(argv[i+1],&geometry_info);
1939 if ((flags & SigmaValue) == 0)
1940 geometry_info.sigma=geometry_info.rho-0.5;
1941 mogrify_image=KuwaharaImageChannel(*image,channel,geometry_info.rho,
1942 geometry_info.sigma,exception);
1949 if (LocaleCompare(
"lat",option+1) == 0)
1954 (void) SyncImageSettings(mogrify_info,*image);
1955 flags=ParseGeometry(argv[i+1],&geometry_info);
1956 if ((flags & SigmaValue) == 0)
1957 geometry_info.sigma=1.0;
1958 if ((flags & PercentValue) != 0)
1959 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1960 mogrify_image=AdaptiveThresholdImage(*image,(
size_t)
1961 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1962 geometry_info.xi,exception);
1965 if (LocaleCompare(
"level",option+1) == 0)
1978 (void) SyncImageSettings(mogrify_info,*image);
1979 flags=ParseGeometry(argv[i+1],&geometry_info);
1980 black_point=geometry_info.rho;
1981 white_point=(MagickRealType) QuantumRange;
1982 if ((flags & SigmaValue) != 0)
1983 white_point=geometry_info.sigma;
1985 if ((flags & XiValue) != 0)
1986 gamma=geometry_info.xi;
1987 if ((flags & PercentValue) != 0)
1989 black_point*=(MagickRealType) (QuantumRange/100.0);
1990 white_point*=(MagickRealType) (QuantumRange/100.0);
1992 if ((flags & SigmaValue) == 0)
1993 white_point=(MagickRealType) QuantumRange-black_point;
1994 if ((*option ==
'+') || ((flags & AspectValue) != 0))
1995 (
void) LevelizeImageChannel(*image,channel,black_point,
1998 (
void) LevelImageChannel(*image,channel,black_point,white_point,
2000 InheritException(exception,&(*image)->exception);
2003 if (LocaleCompare(
"level-colors",option+1) == 0)
2006 token[MaxTextExtent];
2015 p=(
const char *) argv[i+1];
2016 (void) GetNextToken(p,&p,MaxTextExtent,token);
2017 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2018 (void) QueryMagickColor(token,&black_point,exception);
2020 (
void) QueryMagickColor(
"#000000",&black_point,exception);
2021 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
2022 (void) GetNextToken(p,&p,MaxTextExtent,token);
2024 white_point=black_point;
2027 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
2028 (
void) GetNextToken(p,&p,MaxTextExtent,token);
2029 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2030 (void) QueryMagickColor(token,&white_point,exception);
2032 (
void) QueryMagickColor(
"#ffffff",&white_point,exception);
2034 (void) LevelColorsImageChannel(*image,channel,&black_point,
2035 &white_point,*option ==
'+' ? MagickTrue : MagickFalse);
2038 if (LocaleCompare(
"linear-stretch",option+1) == 0)
2047 (void) SyncImageSettings(mogrify_info,*image);
2048 flags=ParseGeometry(argv[i+1],&geometry_info);
2049 black_point=geometry_info.rho;
2050 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2051 if ((flags & SigmaValue) != 0)
2052 white_point=geometry_info.sigma;
2053 if ((flags & PercentValue) != 0)
2055 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2056 white_point*=(
double) (*image)->columns*(*image)->rows/100.0;
2058 if ((flags & SigmaValue) == 0)
2059 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2061 (void) LinearStretchImage(*image,black_point,white_point);
2062 InheritException(exception,&(*image)->exception);
2065 if (LocaleCompare(
"linewidth",option+1) == 0)
2067 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
2070 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
2075 (void) SyncImageSettings(mogrify_info,*image);
2076 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2077 if ((flags & XValue) == 0)
2079 if ((flags & YValue) == 0)
2081 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2082 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2085 if (LocaleCompare(
"local-contrast",option+1) == 0)
2090 (void) SyncImageSettings(mogrify_info,*image);
2091 flags=ParseGeometry(argv[i+1],&geometry_info);
2092 if ((flags & RhoValue) == 0)
2093 geometry_info.rho=10;
2094 if ((flags & SigmaValue) == 0)
2095 geometry_info.sigma=12.5;
2096 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
2097 geometry_info.sigma,exception);
2100 if (LocaleCompare(
"lowlight-color",option+1) == 0)
2102 (void) SetImageArtifact(*image,
"compare:lowlight-color",argv[i+1]);
2109 if (LocaleCompare(
"magnify",option+1) == 0)
2114 (void) SyncImageSettings(mogrify_info,*image);
2115 mogrify_image=MagnifyImage(*image,exception);
2118 if (LocaleCompare(
"map",option+1) == 0)
2126 (void) SyncImageSettings(mogrify_info,*image);
2129 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2130 if (remap_image == (Image *) NULL)
2132 (void) RemapImage(quantize_info,*image,remap_image);
2133 InheritException(exception,&(*image)->exception);
2134 remap_image=DestroyImage(remap_image);
2137 if (LocaleCompare(
"mask",option+1) == 0)
2142 (void) SyncImageSettings(mogrify_info,*image);
2148 (void) SetImageMask(*image,(Image *) NULL);
2149 InheritException(exception,&(*image)->exception);
2155 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2156 if (mask == (Image *) NULL)
2158 (void) SetImageMask(*image,mask);
2159 mask=DestroyImage(mask);
2160 InheritException(exception,&(*image)->exception);
2163 if (LocaleCompare(
"matte",option+1) == 0)
2165 (void) SetImageAlphaChannel(*image,(*option ==
'-') ?
2166 SetAlphaChannel : DeactivateAlphaChannel );
2167 InheritException(exception,&(*image)->exception);
2170 if (LocaleCompare(
"mean-shift",option+1) == 0)
2175 (void) SyncImageSettings(mogrify_info,*image);
2176 flags=ParseGeometry(argv[i+1],&geometry_info);
2177 if ((flags & SigmaValue) == 0)
2178 geometry_info.sigma=geometry_info.rho;
2179 if ((flags & XiValue) == 0)
2180 geometry_info.xi=0.10*QuantumRange;
2181 if ((flags & PercentValue) != 0)
2182 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2183 mogrify_image=MeanShiftImage(*image,(
size_t) geometry_info.rho,
2184 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2187 if (LocaleCompare(
"median",option+1) == 0)
2192 (void) SyncImageSettings(mogrify_info,*image);
2193 (void) ParseGeometry(argv[i+1],&geometry_info);
2194 mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic,
2195 (
size_t) geometry_info.rho,(
size_t) geometry_info.rho,exception);
2198 if (LocaleCompare(
"mode",option+1) == 0)
2203 (void) SyncImageSettings(mogrify_info,*image);
2204 (void) ParseGeometry(argv[i+1],&geometry_info);
2205 mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic,
2206 (
size_t) geometry_info.rho,(
size_t) geometry_info.rho,exception);
2209 if (LocaleCompare(
"modulate",option+1) == 0)
2211 (void) SyncImageSettings(mogrify_info,*image);
2212 (void) ModulateImage(*image,argv[i+1]);
2213 InheritException(exception,&(*image)->exception);
2216 if (LocaleCompare(
"moments",option+1) == 0)
2220 (void) DeleteImageArtifact(*image,
"identify:moments");
2223 (void) SetImageArtifact(*image,
"identify:moments",argv[i+1]);
2224 (void) SetImageArtifact(*image,
"verbose",
"true");
2227 if (LocaleCompare(
"monitor",option+1) == 0)
2231 (void) SetImageProgressMonitor(*image,
2232 (MagickProgressMonitor) NULL,(
void *) NULL);
2235 (void) SetImageProgressMonitor(*image,MonitorProgress,
2239 if (LocaleCompare(
"monochrome",option+1) == 0)
2241 (void) SyncImageSettings(mogrify_info,*image);
2242 (void) SetImageType(*image,BilevelType);
2243 InheritException(exception,&(*image)->exception);
2246 if (LocaleCompare(
"morphology",option+1) == 0)
2249 token[MaxTextExtent];
2266 (void) SyncImageSettings(mogrify_info,*image);
2268 (void) GetNextToken(p,&p,MaxTextExtent,token);
2269 method=(MorphologyMethod) ParseCommandOption(
2270 MagickMorphologyOptions,MagickFalse,token);
2272 (void) GetNextToken(p,&p,MaxTextExtent,token);
2273 if ((*p ==
':') || (*p ==
','))
2274 (void) GetNextToken(p,&p,MaxTextExtent,token);
2276 iterations=(ssize_t) StringToLong(p);
2277 kernel=AcquireKernelInfo(argv[i+2]);
2278 if (kernel == (KernelInfo *) NULL)
2280 (void) ThrowMagickException(exception,GetMagickModule(),
2281 OptionError,
"UnabletoParseKernel",
"morphology");
2285 mogrify_image=MorphologyImageChannel(*image,channel,method,
2286 iterations,kernel,exception);
2287 kernel=DestroyKernelInfo(kernel);
2290 if (LocaleCompare(
"motion-blur",option+1) == 0)
2295 (void) SyncImageSettings(mogrify_info,*image);
2296 flags=ParseGeometry(argv[i+1],&geometry_info);
2297 if ((flags & SigmaValue) == 0)
2298 geometry_info.sigma=1.0;
2299 mogrify_image=MotionBlurImageChannel(*image,channel,
2300 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2307 if (LocaleCompare(
"negate",option+1) == 0)
2309 (void) SyncImageSettings(mogrify_info,*image);
2310 (void) NegateImageChannel(*image,channel,*option ==
'+' ?
2311 MagickTrue : MagickFalse);
2312 InheritException(exception,&(*image)->exception);
2315 if (LocaleCompare(
"noise",option+1) == 0)
2317 (void) SyncImageSettings(mogrify_info,*image);
2320 flags=ParseGeometry(argv[i+1],&geometry_info);
2321 if ((flags & SigmaValue) == 0)
2322 geometry_info.sigma=geometry_info.rho;
2323 mogrify_image=StatisticImageChannel(*image,channel,
2324 NonpeakStatistic,(
size_t) geometry_info.rho,(
size_t)
2325 geometry_info.sigma,exception);
2332 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2333 MagickFalse,argv[i+1]);
2334 mogrify_image=AddNoiseImageChannel(*image,channel,noise,
2339 if (LocaleCompare(
"normalize",option+1) == 0)
2341 (void) SyncImageSettings(mogrify_info,*image);
2342 (void) NormalizeImageChannel(*image,channel);
2343 InheritException(exception,&(*image)->exception);
2350 if (LocaleCompare(
"opaque",option+1) == 0)
2355 (void) SyncImageSettings(mogrify_info,*image);
2356 (void) QueryMagickColor(argv[i+1],&target,exception);
2357 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2358 *option ==
'-' ? MagickFalse : MagickTrue);
2361 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2363 (void) SyncImageSettings(mogrify_info,*image);
2364 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2372 if (LocaleCompare(
"paint",option+1) == 0)
2374 (void) SyncImageSettings(mogrify_info,*image);
2375 (void) ParseGeometry(argv[i+1],&geometry_info);
2376 mogrify_image=OilPaintImage(*image,geometry_info.rho,exception);
2379 if (LocaleCompare(
"pen",option+1) == 0)
2383 (void) QueryColorDatabase(
"none",&draw_info->fill,exception);
2386 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2389 if (LocaleCompare(
"perceptible",option+1) == 0)
2394 (void) SyncImageSettings(mogrify_info,*image);
2395 (void) PerceptibleImageChannel(*image,channel,StringToDouble(
2396 argv[i+1],(
char **) NULL));
2397 InheritException(exception,&(*image)->exception);
2400 if (LocaleCompare(
"pointsize",option+1) == 0)
2403 (void) ParseGeometry(
"12",&geometry_info);
2405 (
void) ParseGeometry(argv[i+1],&geometry_info);
2406 draw_info->pointsize=geometry_info.rho;
2409 if (LocaleCompare(
"polaroid",option+1) == 0)
2420 (void) SyncImageSettings(mogrify_info,*image);
2421 random_info=AcquireRandomInfo();
2422 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2423 random_info=DestroyRandomInfo(random_info);
2426 SetGeometryInfo(&geometry_info);
2427 flags=ParseGeometry(argv[i+1],&geometry_info);
2428 angle=geometry_info.rho;
2430 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2433 if (LocaleCompare(
"posterize",option+1) == 0)
2438 (void) SyncImageSettings(mogrify_info,*image);
2439 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2440 quantize_info->dither);
2441 InheritException(exception,&(*image)->exception);
2444 if (LocaleCompare(
"preview",option+1) == 0)
2452 (void) SyncImageSettings(mogrify_info,*image);
2454 preview_type=UndefinedPreview;
2456 preview_type=(PreviewType) ParseCommandOption(
2457 MagickPreviewOptions,MagickFalse,argv[i+1]);
2458 mogrify_image=PreviewImage(*image,preview_type,exception);
2461 if (LocaleCompare(
"profile",option+1) == 0)
2478 (void) SyncImageSettings(mogrify_info,*image);
2484 (void) ProfileImage(*image,argv[i+1],(
const unsigned char *)
2486 InheritException(exception,&(*image)->exception);
2492 profile_info=CloneImageInfo(mogrify_info);
2493 profile=GetImageProfile(*image,
"iptc");
2494 if (profile != (StringInfo *) NULL)
2495 profile_info->profile=(
void *) CloneStringInfo(profile);
2496 sans_exception=AcquireExceptionInfo();
2497 profile_image=GetImageCache(profile_info,argv[i+1],sans_exception);
2498 sans_exception=DestroyExceptionInfo(sans_exception);
2499 profile_info=DestroyImageInfo(profile_info);
2500 if (profile_image == (Image *) NULL)
2505 profile_info=CloneImageInfo(mogrify_info);
2506 (void) CopyMagickString(profile_info->filename,argv[i+1],
2508 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2509 if (profile != (StringInfo *) NULL)
2511 (void) SetImageInfo(profile_info,0,exception);
2512 (void) ProfileImage(*image,profile_info->magick,
2513 GetStringInfoDatum(profile),(size_t)
2514 GetStringInfoLength(profile),MagickFalse);
2515 profile=DestroyStringInfo(profile);
2517 profile_info=DestroyImageInfo(profile_info);
2520 ResetImageProfileIterator(profile_image);
2521 name=GetNextImageProfile(profile_image);
2522 while (name != (
const char *) NULL)
2524 profile=GetImageProfile(profile_image,name);
2525 if (profile != (StringInfo *) NULL)
2526 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2527 (size_t) GetStringInfoLength(profile),MagickFalse);
2528 name=GetNextImageProfile(profile_image);
2530 profile_image=DestroyImage(profile_image);
2537 if (LocaleCompare(
"quantize",option+1) == 0)
2541 quantize_info->colorspace=UndefinedColorspace;
2544 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2545 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2552 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
2553 LocaleCompare(
"rotational-blur",option+1) == 0)
2558 (void) SyncImageSettings(mogrify_info,*image);
2559 mogrify_image=RotationalBlurImageChannel(*image,channel,
2560 StringToDouble(argv[i+1],(
char **) NULL),exception);
2563 if (LocaleCompare(
"raise",option+1) == 0)
2568 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2569 (void) RaiseImage(*image,&geometry,*option ==
'-' ? MagickTrue :
2571 InheritException(exception,&(*image)->exception);
2574 if (LocaleCompare(
"random-threshold",option+1) == 0)
2579 (void) SyncImageSettings(mogrify_info,*image);
2580 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2584 if (LocaleCompare(
"recolor",option+1) == 0)
2589 (void) SyncImageSettings(mogrify_info,*image);
2590 kernel=AcquireKernelInfo(argv[i+1]);
2591 if (kernel == (KernelInfo *) NULL)
2593 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2594 kernel=DestroyKernelInfo(kernel);
2597 if (LocaleCompare(
"region",option+1) == 0)
2599 (void) SyncImageSettings(mogrify_info,*image);
2600 if (region_image != (Image *) NULL)
2605 (void) CompositeImage(region_image,region_image->matte !=
2606 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2607 region_geometry.x,region_geometry.y);
2608 InheritException(exception,®ion_image->exception);
2609 *image=DestroyImage(*image);
2610 *image=region_image;
2611 region_image=(Image *) NULL;
2618 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2620 mogrify_image=CropImage(*image,®ion_geometry,exception);
2621 if (mogrify_image == (Image *) NULL)
2623 region_image=(*image);
2624 *image=mogrify_image;
2625 mogrify_image=(Image *) NULL;
2628 if (LocaleCompare(
"render",option+1) == 0)
2630 (void) SyncImageSettings(mogrify_info,*image);
2631 draw_info->render=(*option ==
'+') ? MagickTrue : MagickFalse;
2634 if (LocaleCompare(
"remap",option+1) == 0)
2642 (void) SyncImageSettings(mogrify_info,*image);
2645 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2646 if (remap_image == (Image *) NULL)
2648 (void) RemapImage(quantize_info,*image,remap_image);
2649 InheritException(exception,&(*image)->exception);
2650 remap_image=DestroyImage(remap_image);
2653 if (LocaleCompare(
"repage",option+1) == 0)
2657 (void) ParseAbsoluteGeometry(
"0x0+0+0",&(*image)->page);
2660 (void) ResetImagePage(*image,argv[i+1]);
2661 InheritException(exception,&(*image)->exception);
2664 if (LocaleCompare(
"resample",option+1) == 0)
2669 (void) SyncImageSettings(mogrify_info,*image);
2670 flags=ParseGeometry(argv[i+1],&geometry_info);
2671 if ((flags & SigmaValue) == 0)
2672 geometry_info.sigma=geometry_info.rho;
2673 mogrify_image=ResampleImage(*image,geometry_info.rho,
2674 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2677 if (LocaleCompare(
"resize",option+1) == 0)
2682 (void) SyncImageSettings(mogrify_info,*image);
2683 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2684 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2685 (*image)->filter,(*image)->blur,exception);
2688 if (LocaleCompare(
"roll",option+1) == 0)
2693 (void) SyncImageSettings(mogrify_info,*image);
2694 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2695 if ((flags & PercentValue) != 0)
2697 geometry.x*=(double) (*image)->columns/100.0;
2698 geometry.y*=(
double) (*image)->rows/100.0;
2700 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2703 if (LocaleCompare(
"rotate",option+1) == 0)
2711 (void) SyncImageSettings(mogrify_info,*image);
2712 if (strchr(argv[i+1],
'>') != (
char *) NULL)
2713 if ((*image)->columns <= (*image)->rows)
2715 if (strchr(argv[i+1],
'<') != (
char *) NULL)
2716 if ((*image)->columns >= (*image)->rows)
2721 geometry=ConstantString(argv[i+1]);
2722 (void) SubstituteString(&geometry,
">",
"");
2723 (void) SubstituteString(&geometry,
"<",
"");
2724 (void) ParseGeometry(geometry,&geometry_info);
2725 geometry=DestroyString(geometry);
2726 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2733 if (LocaleCompare(
"sample",option+1) == 0)
2738 (void) SyncImageSettings(mogrify_info,*image);
2739 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2740 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2744 if (LocaleCompare(
"scale",option+1) == 0)
2749 (void) SyncImageSettings(mogrify_info,*image);
2750 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2751 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2755 if (LocaleCompare(
"selective-blur",option+1) == 0)
2760 (void) SyncImageSettings(mogrify_info,*image);
2761 flags=ParseGeometry(argv[i+1],&geometry_info);
2762 if ((flags & PercentValue) != 0)
2763 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2764 mogrify_image=SelectiveBlurImageChannel(*image,channel,
2765 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2768 if (LocaleCompare(
"separate",option+1) == 0)
2774 (void) SyncImageSettings(mogrify_info,*image);
2775 mogrify_image=SeparateImages(*image,channel,exception);
2778 if (LocaleCompare(
"sepia-tone",option+1) == 0)
2786 (void) SyncImageSettings(mogrify_info,*image);
2787 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2789 mogrify_image=SepiaToneImage(*image,threshold,exception);
2792 if (LocaleCompare(
"segment",option+1) == 0)
2797 (void) SyncImageSettings(mogrify_info,*image);
2798 flags=ParseGeometry(argv[i+1],&geometry_info);
2799 if ((flags & SigmaValue) == 0)
2800 geometry_info.sigma=1.0;
2801 (void) SegmentImage(*image,(*image)->colorspace,
2802 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2803 InheritException(exception,&(*image)->exception);
2806 if (LocaleCompare(
"set",option+1) == 0)
2816 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2817 (void) DeleteImageRegistry(argv[i+1]+9);
2819 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2821 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2822 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2825 (
void) DeleteImageProperty(*image,argv[i+1]);
2828 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2829 InheritException(exception,&(*image)->exception);
2830 if (value == (
char *) NULL)
2832 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2833 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2836 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2838 (void) SetImageOption(image_info,argv[i+1]+7,value);
2839 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2840 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2843 (
void) SetImageProperty(*image,argv[i+1],value);
2844 value=DestroyString(value);
2847 if (LocaleCompare(
"shade",option+1) == 0)
2852 (void) SyncImageSettings(mogrify_info,*image);
2853 flags=ParseGeometry(argv[i+1],&geometry_info);
2854 if ((flags & SigmaValue) == 0)
2855 geometry_info.sigma=1.0;
2856 mogrify_image=ShadeImage(*image,(*option ==
'-') ? MagickTrue :
2857 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2860 if (LocaleCompare(
"shadow",option+1) == 0)
2865 (void) SyncImageSettings(mogrify_info,*image);
2866 flags=ParseGeometry(argv[i+1],&geometry_info);
2867 if ((flags & SigmaValue) == 0)
2868 geometry_info.sigma=1.0;
2869 if ((flags & XiValue) == 0)
2870 geometry_info.xi=4.0;
2871 if ((flags & PsiValue) == 0)
2872 geometry_info.psi=4.0;
2873 mogrify_image=ShadowImage(*image,geometry_info.rho,
2874 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2875 ceil(geometry_info.psi-0.5),exception);
2878 if (LocaleCompare(
"sharpen",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 mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2888 geometry_info.sigma,exception);
2891 if (LocaleCompare(
"shave",option+1) == 0)
2896 (void) SyncImageSettings(mogrify_info,*image);
2897 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2898 mogrify_image=ShaveImage(*image,&geometry,exception);
2901 if (LocaleCompare(
"shear",option+1) == 0)
2906 (void) SyncImageSettings(mogrify_info,*image);
2907 flags=ParseGeometry(argv[i+1],&geometry_info);
2908 if ((flags & SigmaValue) == 0)
2909 geometry_info.sigma=geometry_info.rho;
2910 mogrify_image=ShearImage(*image,geometry_info.rho,
2911 geometry_info.sigma,exception);
2914 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
2919 (void) SyncImageSettings(mogrify_info,*image);
2920 flags=ParseGeometry(argv[i+1],&geometry_info);
2921 if ((flags & SigmaValue) == 0)
2922 geometry_info.sigma=(double) QuantumRange/2.0;
2923 if ((flags & PercentValue) != 0)
2924 geometry_info.sigma=(
double) QuantumRange*geometry_info.sigma/
2926 (void) SigmoidalContrastImageChannel(*image,channel,
2927 (*option ==
'-') ? MagickTrue : MagickFalse,geometry_info.rho,
2928 geometry_info.sigma);
2929 InheritException(exception,&(*image)->exception);
2932 if (LocaleCompare(
"sketch",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=1.0;
2941 mogrify_image=SketchImage(*image,geometry_info.rho,
2942 geometry_info.sigma,geometry_info.xi,exception);
2945 if (LocaleCompare(
"solarize",option+1) == 0)
2950 (void) SyncImageSettings(mogrify_info,*image);
2951 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2953 (void) SolarizeImageChannel(*image,channel,threshold,exception);
2956 if (LocaleCompare(
"sparse-color",option+1) == 0)
2967 (void) SyncImageSettings(mogrify_info,*image);
2968 method=(SparseColorMethod) ParseCommandOption(
2969 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2970 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2971 InheritException(exception,&(*image)->exception);
2972 if (arguments == (
char *) NULL)
2974 mogrify_image=SparseColorOption(*image,channel,method,arguments,
2975 option[0] ==
'+' ? MagickTrue : MagickFalse,exception);
2976 arguments=DestroyString(arguments);
2979 if (LocaleCompare(
"splice",option+1) == 0)
2984 (void) SyncImageSettings(mogrify_info,*image);
2985 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2986 mogrify_image=SpliceImage(*image,&geometry,exception);
2989 if (LocaleCompare(
"spread",option+1) == 0)
2994 (void) SyncImageSettings(mogrify_info,*image);
2995 (void) ParseGeometry(argv[i+1],&geometry_info);
2996 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
2999 if (LocaleCompare(
"statistic",option+1) == 0)
3004 (void) SyncImageSettings(mogrify_info,*image);
3005 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
3006 MagickFalse,argv[i+1]);
3007 (void) ParseGeometry(argv[i+2],&geometry_info);
3008 mogrify_image=StatisticImageChannel(*image,channel,type,(
size_t)
3009 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
3012 if (LocaleCompare(
"stretch",option+1) == 0)
3016 draw_info->stretch=UndefinedStretch;
3019 draw_info->stretch=(StretchType) ParseCommandOption(
3020 MagickStretchOptions,MagickFalse,argv[i+1]);
3023 if (LocaleCompare(
"strip",option+1) == 0)
3028 (void) SyncImageSettings(mogrify_info,*image);
3029 (void) StripImage(*image);
3030 InheritException(exception,&(*image)->exception);
3033 if (LocaleCompare(
"stroke",option+1) == 0)
3040 (void) QueryColorDatabase(
"none",&draw_info->stroke,exception);
3041 if (draw_info->stroke_pattern != (Image *) NULL)
3042 draw_info->stroke_pattern=DestroyImage(
3043 draw_info->stroke_pattern);
3046 sans=AcquireExceptionInfo();
3047 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3048 sans=DestroyExceptionInfo(sans);
3049 if (status == MagickFalse)
3050 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3054 if (LocaleCompare(
"strokewidth",option+1) == 0)
3056 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
3059 if (LocaleCompare(
"style",option+1) == 0)
3063 draw_info->style=UndefinedStyle;
3066 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3067 MagickFalse,argv[i+1]);
3070 if (LocaleCompare(
"swirl",option+1) == 0)
3075 (void) SyncImageSettings(mogrify_info,*image);
3076 (void) ParseGeometry(argv[i+1],&geometry_info);
3077 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
3084 if (LocaleCompare(
"threshold",option+1) == 0)
3092 (void) SyncImageSettings(mogrify_info,*image);
3094 threshold=(double) QuantumRange/2;
3096 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
3098 (void) BilevelImageChannel(*image,channel,threshold);
3099 InheritException(exception,&(*image)->exception);
3102 if (LocaleCompare(
"thumbnail",option+1) == 0)
3107 (void) SyncImageSettings(mogrify_info,*image);
3108 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3109 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3113 if (LocaleCompare(
"tile",option+1) == 0)
3117 if (draw_info->fill_pattern != (Image *) NULL)
3118 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3121 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3125 if (LocaleCompare(
"tint",option+1) == 0)
3130 (void) SyncImageSettings(mogrify_info,*image);
3131 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3134 if (LocaleCompare(
"transform",option+1) == 0)
3139 (void) SyncImageSettings(mogrify_info,*image);
3140 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3144 if (LocaleCompare(
"transparent",option+1) == 0)
3149 (void) SyncImageSettings(mogrify_info,*image);
3150 (void) QueryMagickColor(argv[i+1],&target,exception);
3151 (void) TransparentPaintImage(*image,&target,(Quantum)
3152 TransparentOpacity,*option ==
'-' ? MagickFalse : MagickTrue);
3153 InheritException(exception,&(*image)->exception);
3156 if (LocaleCompare(
"transpose",option+1) == 0)
3161 (void) SyncImageSettings(mogrify_info,*image);
3162 mogrify_image=TransposeImage(*image,exception);
3165 if (LocaleCompare(
"transverse",option+1) == 0)
3170 (void) SyncImageSettings(mogrify_info,*image);
3171 mogrify_image=TransverseImage(*image,exception);
3174 if (LocaleCompare(
"treedepth",option+1) == 0)
3176 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3179 if (LocaleCompare(
"trim",option+1) == 0)
3184 (void) SyncImageSettings(mogrify_info,*image);
3185 mogrify_image=TrimImage(*image,exception);
3188 if (LocaleCompare(
"type",option+1) == 0)
3193 (void) SyncImageSettings(mogrify_info,*image);
3197 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3199 (*image)->type=UndefinedType;
3200 (void) SetImageType(*image,type);
3201 InheritException(exception,&(*image)->exception);
3208 if (LocaleCompare(
"undercolor",option+1) == 0)
3210 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3214 if (LocaleCompare(
"unique",option+1) == 0)
3218 (void) DeleteImageArtifact(*image,
"identify:unique-colors");
3221 (void) SetImageArtifact(*image,
"identify:unique-colors",
"true");
3222 (void) SetImageArtifact(*image,
"verbose",
"true");
3225 if (LocaleCompare(
"unique-colors",option+1) == 0)
3230 (void) SyncImageSettings(mogrify_info,*image);
3231 mogrify_image=UniqueImageColors(*image,exception);
3234 if (LocaleCompare(
"unsharp",option+1) == 0)
3239 (void) SyncImageSettings(mogrify_info,*image);
3240 flags=ParseGeometry(argv[i+1],&geometry_info);
3241 if ((flags & SigmaValue) == 0)
3242 geometry_info.sigma=1.0;
3243 if ((flags & XiValue) == 0)
3244 geometry_info.xi=1.0;
3245 if ((flags & PsiValue) == 0)
3246 geometry_info.psi=0.05;
3247 mogrify_image=UnsharpMaskImageChannel(*image,channel,
3248 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3249 geometry_info.psi,exception);
3256 if (LocaleCompare(
"verbose",option+1) == 0)
3258 (void) SetImageArtifact(*image,option+1,
3259 *option ==
'+' ?
"false" :
"true");
3262 if (LocaleCompare(
"vignette",option+1) == 0)
3267 (void) SyncImageSettings(mogrify_info,*image);
3268 flags=ParseGeometry(argv[i+1],&geometry_info);
3269 if ((flags & SigmaValue) == 0)
3270 geometry_info.sigma=1.0;
3271 if ((flags & XiValue) == 0)
3272 geometry_info.xi=0.1*(*image)->columns;
3273 if ((flags & PsiValue) == 0)
3274 geometry_info.psi=0.1*(*image)->rows;
3275 if ((flags & PercentValue) != 0)
3277 geometry_info.xi*=(double) (*image)->columns/100.0;
3278 geometry_info.psi*=(
double) (*image)->rows/100.0;
3280 mogrify_image=VignetteImage(*image,geometry_info.rho,
3281 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3282 ceil(geometry_info.psi-0.5),exception);
3285 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
3289 (void) SetImageVirtualPixelMethod(*image,
3290 UndefinedVirtualPixelMethod);
3293 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3294 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3302 if (LocaleCompare(
"wave",option+1) == 0)
3307 (void) SyncImageSettings(mogrify_info,*image);
3308 flags=ParseGeometry(argv[i+1],&geometry_info);
3309 if ((flags & SigmaValue) == 0)
3310 geometry_info.sigma=1.0;
3311 mogrify_image=WaveImage(*image,geometry_info.rho,
3312 geometry_info.sigma,exception);
3315 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3320 (void) SyncImageSettings(mogrify_info,*image);
3321 flags=ParseGeometry(argv[i+1],&geometry_info);
3322 if ((flags & PercentValue) != 0)
3324 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
3325 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
3327 if ((flags & SigmaValue) == 0)
3328 geometry_info.sigma=0.0;
3329 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3330 geometry_info.sigma,exception);
3333 if (LocaleCompare(
"weight",option+1) == 0)
3338 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3341 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3342 draw_info->weight=(size_t) weight;
3345 if (LocaleCompare(
"white-threshold",option+1) == 0)
3350 (void) SyncImageSettings(mogrify_info,*image);
3351 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3353 InheritException(exception,&(*image)->exception);
3364 if (mogrify_image != (Image *) NULL)
3365 ReplaceImageInListReturnLast(image,mogrify_image);
3368 if (region_image != (Image *) NULL)
3373 (void) SyncImageSettings(mogrify_info,*image);
3374 (void) CompositeImage(region_image,region_image->matte != MagickFalse ?
3375 CopyCompositeOp : OverCompositeOp,*image,region_geometry.x,
3377 InheritException(exception,®ion_image->exception);
3378 *image=DestroyImage(*image);
3379 *image=region_image;
3380 region_image = (Image *) NULL;
3385 quantize_info=DestroyQuantizeInfo(quantize_info);
3386 draw_info=DestroyDrawInfo(draw_info);
3387 mogrify_info=DestroyImageInfo(mogrify_info);
3388 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3389 return(status == 0 ? MagickFalse : MagickTrue);
3426 static MagickBooleanType MogrifyUsage(
void)
3430 " -debug events display copious debugging information\n"
3431 " -distribute-cache port\n"
3432 " distributed pixel cache spanning one or more servers\n"
3433 " -help print program options\n"
3434 " -list type print a list of supported option arguments\n"
3435 " -log format format of debugging information\n"
3436 " -version print version information",
3438 " -adaptive-blur geometry\n"
3439 " adaptively blur pixels; decrease effect near edges\n"
3440 " -adaptive-resize geometry\n"
3441 " adaptively resize image using 'mesh' interpolation\n"
3442 " -adaptive-sharpen geometry\n"
3443 " adaptively sharpen pixels; increase effect near edges\n"
3444 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3445 " transparent, extract, background, or shape\n"
3446 " -annotate geometry text\n"
3447 " annotate the image with text\n"
3448 " -auto-gamma automagically adjust gamma level of image\n"
3449 " -auto-level automagically adjust color levels of image\n"
3450 " -auto-orient automagically orient (rotate) image\n"
3451 " -bench iterations measure performance\n"
3452 " -black-threshold value\n"
3453 " force all pixels below the threshold into black\n"
3454 " -blue-shift simulate a scene at nighttime in the moonlight\n"
3455 " -blur geometry reduce image noise and reduce detail levels\n"
3456 " -border geometry surround image with a border of color\n"
3457 " -bordercolor color border color\n"
3458 " -brightness-contrast geometry\n"
3459 " improve brightness / contrast of the image\n"
3460 " -canny geometry detect edges in the image\n"
3461 " -cdl filename color correct with a color decision list\n"
3462 " -charcoal radius simulate a charcoal drawing\n"
3463 " -chop geometry remove pixels from the image interior\n"
3464 " -clamp keep pixel values in range (0-QuantumRange)\n"
3465 " -clip clip along the first path from the 8BIM profile\n"
3466 " -clip-mask filename associate a clip mask with the image\n"
3467 " -clip-path id clip along a named path from the 8BIM profile\n"
3468 " -colorize value colorize the image with the fill color\n"
3469 " -color-matrix matrix apply color correction to the image\n"
3470 " -connected-components connectivity\n"
3471 " connected-components uniquely labeled\n"
3472 " -contrast enhance or reduce the image contrast\n"
3473 " -contrast-stretch geometry\n"
3474 " improve contrast by `stretching' the intensity range\n"
3475 " -convolve coefficients\n"
3476 " apply a convolution kernel to the image\n"
3477 " -cycle amount cycle the image colormap\n"
3478 " -decipher filename convert cipher pixels to plain pixels\n"
3479 " -deskew threshold straighten an image\n"
3480 " -despeckle reduce the speckles within an image\n"
3481 " -distort method args\n"
3482 " distort images according to given method ad args\n"
3483 " -draw string annotate the image with a graphic primitive\n"
3484 " -edge radius apply a filter to detect edges in the image\n"
3485 " -encipher filename convert plain pixels to cipher pixels\n"
3486 " -emboss radius emboss an image\n"
3487 " -enhance apply a digital filter to enhance a noisy image\n"
3488 " -equalize perform histogram equalization to an image\n"
3489 " -evaluate operator value\n"
3490 " evaluate an arithmetic, relational, or logical expression\n"
3491 " -extent geometry set the image size\n"
3492 " -extract geometry extract area from image\n"
3493 " -hough-lines geometry\n"
3494 " identify lines in the image\n"
3495 " -features distance analyze image features (e.g. contrast, correlation)\n"
3496 " -fft implements the discrete Fourier transform (DFT)\n"
3497 " -flip flip image vertically\n"
3498 " -floodfill geometry color\n"
3499 " floodfill the image with color\n"
3500 " -flop flop image horizontally\n"
3501 " -frame geometry surround image with an ornamental border\n"
3502 " -function name parameters\n"
3503 " apply function over image values\n"
3504 " -gamma value level of gamma correction\n"
3505 " -gaussian-blur geometry\n"
3506 " reduce image noise and reduce detail levels\n"
3507 " -geometry geometry preferred size or location of the image\n"
3508 " -grayscale method convert image to grayscale\n"
3509 " -help print program options\n"
3510 " -identify identify the format and characteristics of the image\n"
3511 " -ift implements the inverse discrete Fourier transform (DFT)\n"
3512 " -implode amount implode image pixels about the center\n"
3513 " -kuwahara geometry edge preserving noise reduction filter\n"
3514 " -lat geometry local adaptive thresholding\n"
3515 " -layers method optimize, merge, or compare image layers\n"
3516 " -level value adjust the level of image contrast\n"
3517 " -level-colors color,color\n"
3518 " level image with the given colors\n"
3519 " -linear-stretch geometry\n"
3520 " improve contrast by `stretching with saturation'\n"
3521 " -liquid-rescale geometry\n"
3522 " rescale image with seam-carving\n"
3523 " -local-contrast geometry\n"
3524 " enhance local contrast\n"
3525 " -magnify double the size of the image with pixel art scaling\n"
3526 " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3527 " -median geometry apply a median filter to the image\n"
3528 " -mode geometry make each pixel the 'predominant color' of the\n"
3530 " -modulate value vary the brightness, saturation, and hue\n"
3531 " -monochrome transform image to black and white\n"
3532 " -morphology method kernel\n"
3533 " apply a morphology method to the image\n"
3534 " -motion-blur geometry\n"
3535 " simulate motion blur\n"
3536 " -negate replace every pixel with its complementary color \n"
3537 " -noise geometry add or reduce noise in an image\n"
3538 " -normalize transform image to span the full range of colors\n"
3539 " -opaque color change this color to the fill color\n"
3540 " -ordered-dither NxN\n"
3541 " add a noise pattern to the image with specific\n"
3543 " -paint radius simulate an oil painting\n"
3544 " -perceptible epsilon\n"
3545 " pixel value less than |epsilon| become epsilon or\n"
3547 " -polaroid angle simulate a Polaroid picture\n"
3548 " -posterize levels reduce the image to a limited number of color levels\n"
3549 " -profile filename add, delete, or apply an image profile\n"
3550 " -quantize colorspace reduce colors in this colorspace\n"
3551 " -radial-blur angle radial blur the image\n"
3552 " -raise value lighten/darken image edges to create a 3-D effect\n"
3553 " -random-threshold low,high\n"
3554 " random threshold the image\n"
3555 " -region geometry apply options to a portion of the image\n"
3556 " -render render vector graphics\n"
3557 " -resample geometry change the resolution of an image\n"
3558 " -resize geometry resize the image\n"
3559 " -roll geometry roll an image vertically or horizontally\n"
3560 " -rotate degrees apply Paeth rotation to the image\n"
3561 " -sample geometry scale image with pixel sampling\n"
3562 " -scale geometry scale the image\n"
3563 " -segment values segment an image\n"
3564 " -selective-blur geometry\n"
3565 " selectively blur pixels within a contrast threshold\n"
3566 " -sepia-tone threshold\n"
3567 " simulate a sepia-toned photo\n"
3568 " -set property value set an image property\n"
3569 " -shade degrees shade the image using a distant light source\n"
3570 " -shadow geometry simulate an image shadow\n"
3571 " -sharpen geometry sharpen the image\n"
3572 " -shave geometry shave pixels from the image edges\n"
3573 " -shear geometry slide one edge of the image along the X or Y axis\n"
3574 " -sigmoidal-contrast geometry\n"
3575 " increase the contrast without saturating highlights or\n"
3577 " -sketch geometry simulate a pencil sketch\n"
3578 " -solarize threshold negate all pixels above the threshold level\n"
3579 " -sparse-color method args\n"
3580 " fill in a image based on a few color points\n"
3581 " -splice geometry splice the background color into the image\n"
3582 " -spread radius displace image pixels by a random amount\n"
3583 " -statistic type radius\n"
3584 " replace each pixel with corresponding statistic from the neighborhood\n"
3585 " -strip strip image of all profiles and comments\n"
3586 " -swirl degrees swirl image pixels about the center\n"
3587 " -threshold value threshold the image\n"
3588 " -thumbnail geometry create a thumbnail of the image\n"
3589 " -tile filename tile image when filling a graphic primitive\n"
3590 " -tint value tint the image with the fill color\n"
3591 " -transform affine transform image\n"
3592 " -transparent color make this color transparent within the image\n"
3593 " -transpose flip image vertically and rotate 90 degrees\n"
3594 " -transverse flop image horizontally and rotate 270 degrees\n"
3595 " -trim trim image edges\n"
3596 " -type type image type\n"
3597 " -unique-colors discard all but one of any pixel color\n"
3598 " -unsharp geometry sharpen the image\n"
3599 " -vignette geometry soften the edges of the image in vignette style\n"
3600 " -wave geometry alter an image along a sine wave\n"
3601 " -wavelet-denoise threshold\n"
3602 " removes noise from the image using a wavelet transform\n"
3603 " -white-threshold value\n"
3604 " force all pixels above the threshold into white",
3605 sequence_operators[] =
3606 " -affinity filename transform image colors to match this set of colors\n"
3607 " -append append an image sequence\n"
3608 " -clut apply a color lookup table to the image\n"
3609 " -coalesce merge a sequence of images\n"
3610 " -combine combine a sequence of images\n"
3611 " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3612 " -complex operator perform complex mathematics on an image sequence\n"
3613 " -composite composite image\n"
3614 " -copy geometry offset\n"
3615 " copy pixels from one area of an image to another\n"
3616 " -crop geometry cut out a rectangular region of the image\n"
3617 " -deconstruct break down an image sequence into constituent parts\n"
3618 " -evaluate-sequence operator\n"
3619 " evaluate an arithmetic, relational, or logical expression\n"
3620 " -flatten flatten a sequence of images\n"
3621 " -fx expression apply mathematical expression to an image channel(s)\n"
3622 " -hald-clut apply a Hald color lookup table to the image\n"
3623 " -layers method optimize, merge, or compare image layers\n"
3624 " -morph value morph an image sequence\n"
3625 " -mosaic create a mosaic from an image sequence\n"
3626 " -poly terms build a polynomial from the image sequence and the corresponding\n"
3627 " terms (coefficients and degree pairs).\n"
3628 " -print string interpret string and print to console\n"
3629 " -process arguments process the image with a custom image filter\n"
3630 " -separate separate an image channel into a grayscale image\n"
3631 " -smush geometry smush an image sequence together\n"
3632 " -write filename write images to this file",
3634 " -adjoin join images into a single multi-image file\n"
3635 " -affine matrix affine transform matrix\n"
3636 " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3637 " -antialias remove pixel-aliasing\n"
3638 " -authenticate password\n"
3639 " decipher image with this password\n"
3640 " -attenuate value lessen (or intensify) when adding noise to an image\n"
3641 " -background color background color\n"
3642 " -bias value add bias when convolving an image\n"
3643 " -black-point-compensation\n"
3644 " use black point compensation\n"
3645 " -blue-primary point chromaticity blue primary point\n"
3646 " -bordercolor color border color\n"
3647 " -caption string assign a caption to an image\n"
3648 " -cdl filename color correct with a color decision list\n"
3649 " -channel type apply option to select image channels\n"
3650 " -colors value preferred number of colors in the image\n"
3651 " -colorspace type alternate image colorspace\n"
3652 " -comment string annotate image with comment\n"
3653 " -compose operator set image composite operator\n"
3654 " -compress type type of pixel compression when writing the image\n"
3655 " -decipher filename convert cipher pixels to plain pixels\n"
3656 " -define format:option\n"
3657 " define one or more image format options\n"
3658 " -delay value display the next image after pausing\n"
3659 " -density geometry horizontal and vertical density of the image\n"
3660 " -depth value image depth\n"
3661 " -direction type render text right-to-left or left-to-right\n"
3662 " -display server get image or font from this X server\n"
3663 " -dispose method layer disposal method\n"
3664 " -dither method apply error diffusion to image\n"
3665 " -encipher filename convert plain pixels to cipher pixels\n"
3666 " -encoding type text encoding type\n"
3667 " -endian type endianness (MSB or LSB) of the image\n"
3668 " -family name render text with this font family\n"
3669 " -features distance analyze image features (e.g. contrast, correlation)\n"
3670 " -fill color color to use when filling a graphic primitive\n"
3671 " -filter type use this filter when resizing an image\n"
3672 " -flatten flatten a sequence of images\n"
3673 " -font name render text with this font\n"
3674 " -format \"string\" output formatted image characteristics\n"
3675 " -function name apply a function to the image\n"
3676 " -fuzz distance colors within this distance are considered equal\n"
3677 " -gravity type horizontal and vertical text placement\n"
3678 " -green-primary point chromaticity green primary point\n"
3679 " -intensity method method to generate intensity value from pixel\n"
3680 " -intent type type of rendering intent when managing the image color\n"
3681 " -interlace type type of image interlacing scheme\n"
3682 " -interline-spacing value\n"
3683 " set the space between two text lines\n"
3684 " -interpolate method pixel color interpolation method\n"
3685 " -interword-spacing value\n"
3686 " set the space between two words\n"
3687 " -kerning value set the space between two letters\n"
3688 " -label string assign a label to an image\n"
3689 " -limit type value pixel cache resource limit\n"
3690 " -loop iterations add Netscape loop extension to your GIF animation\n"
3691 " -mask filename associate a mask with the image\n"
3692 " -matte store matte channel if the image has one\n"
3693 " -mattecolor color frame color\n"
3694 " -monitor monitor progress\n"
3695 " -morphology method kernel\n"
3696 " apply a morphology method to the image\n"
3697 " -orient type image orientation\n"
3698 " -page geometry size and location of an image canvas (setting)\n"
3699 " -path path write images to this path on disk\n"
3700 " -ping efficiently determine image attributes\n"
3701 " -pointsize value font point size\n"
3702 " -precision value maximum number of significant digits to print\n"
3703 " -preview type image preview type\n"
3704 " -quality value JPEG/MIFF/PNG compression level\n"
3705 " -quiet suppress all warning messages\n"
3706 " -red-primary point chromaticity red primary point\n"
3707 " -regard-warnings pay attention to warning messages\n"
3708 " -remap filename transform image colors to match this set of colors\n"
3709 " -repage geometry size and location of an image canvas\n"
3710 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3711 " -sampling-factor geometry\n"
3712 " horizontal and vertical sampling factor\n"
3713 " -scene value image scene number\n"
3714 " -seed value seed a new sequence of pseudo-random numbers\n"
3715 " -size geometry width and height of image\n"
3716 " -stretch type render text with this font stretch\n"
3717 " -stroke color graphic primitive stroke color\n"
3718 " -strokewidth value graphic primitive stroke width\n"
3719 " -style type render text with this font style\n"
3720 " -synchronize synchronize image to storage device\n"
3721 " -taint declare the image as modified\n"
3722 " -texture filename name of texture to tile onto the image background\n"
3723 " -tile-offset geometry\n"
3725 " -treedepth value color tree depth\n"
3726 " -transparent-color color\n"
3727 " transparent color\n"
3728 " -undercolor color annotation bounding box color\n"
3729 " -units type the units of image resolution\n"
3730 " -verbose print detailed information about the image\n"
3731 " -view FlashPix viewing transforms\n"
3732 " -virtual-pixel method\n"
3733 " virtual pixel access method\n"
3734 " -weight type render text with this font weight\n"
3735 " -white-point point chromaticity white point",
3737 " -delete indexes delete the image from the image sequence\n"
3738 " -duplicate count,indexes\n"
3739 " duplicate an image one or more times\n"
3740 " -insert index insert last image into the image sequence\n"
3741 " -reverse reverse image sequence\n"
3742 " -swap indexes swap two images in the image sequence";
3744 ListMagickVersion(stdout);
3745 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
3747 (void) printf(
"\nImage Settings:\n");
3748 (void) puts(settings);
3749 (void) printf(
"\nImage Operators:\n");
3750 (void) puts(operators);
3751 (void) printf(
"\nImage Sequence Operators:\n");
3752 (void) puts(sequence_operators);
3753 (void) printf(
"\nImage Stack Operators:\n");
3754 (void) puts(stack_operators);
3755 (void) printf(
"\nMiscellaneous Options:\n");
3756 (void) puts(miscellaneous);
3758 "\nBy default, the image format of `file' is determined by its magic\n");
3760 "number. To specify a particular image format, precede the filename\n");
3762 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3764 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3765 (void) printf(
"'-' for standard input or output.\n");
3769 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3770 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
3772 #define DestroyMogrify() \
3774 if (format != (char *) NULL) \
3775 format=DestroyString(format); \
3776 if (path != (char *) NULL) \
3777 path=DestroyString(path); \
3778 DestroyImageStack(); \
3779 for (i=0; i < (ssize_t) argc; i++) \
3780 argv[i]=DestroyString(argv[i]); \
3781 argv=(char **) RelinquishMagickMemory(argv); \
3783 #define ThrowMogrifyException(asperity,tag,option) \
3785 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3788 return(MagickFalse); \
3790 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3792 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3793 "InvalidArgument","`%s': %s",argument,option); \
3795 return(MagickFalse); \
3807 image_stack[MaxImageStackDepth+1];
3815 respect_parenthesis;
3827 wand_unreferenced(metadata);
3832 assert(image_info != (ImageInfo *) NULL);
3833 assert(image_info->signature == MagickCoreSignature);
3834 assert(exception != (ExceptionInfo *) NULL);
3835 if (IsEventLogging() != MagickFalse)
3836 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3840 if ((LocaleCompare(
"version",option+1) == 0) ||
3841 (LocaleCompare(
"-version",option+1) == 0))
3843 ListMagickVersion(stdout);
3848 return(MogrifyUsage());
3849 format=(
char *) NULL;
3851 global_colormap=MagickFalse;
3855 option=(
char *) NULL;
3857 respect_parenthesis=MagickFalse;
3862 ReadCommandlLine(argc,&argv);
3863 status=ExpandFilenames(&argc,&argv);
3864 if (status == MagickFalse)
3865 ThrowMogrifyException(ResourceLimitError,
"MemoryAllocationFailed",
3866 GetExceptionMessage(errno));
3867 for (i=1; i < (ssize_t) argc; i++)
3870 if (LocaleCompare(option,
"(") == 0)
3872 FireImageStack(MagickFalse,MagickTrue,pend);
3873 if (k == MaxImageStackDepth)
3874 ThrowMogrifyException(OptionError,
"ParenthesisNestedTooDeeply",
3879 if (LocaleCompare(option,
")") == 0)
3881 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3883 ThrowMogrifyException(OptionError,
"UnableToParseExpression",option);
3887 if (IsCommandOption(option) == MagickFalse)
3890 backup_filename[MaxTextExtent],
3892 magic[MagickPathExtent];
3903 FireImageStack(MagickFalse,MagickFalse,pend);
3905 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
3907 (void) SetImageOption(image_info,
"filename",filename);
3908 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3909 images=ReadImages(image_info,exception);
3910 status&=(images != (Image *) NULL) &&
3911 (exception->severity < ErrorException);
3912 if (images == (Image *) NULL)
3914 properties=(*GetBlobProperties(images));
3915 if (format != (
char *) NULL)
3916 GetPathComponent(images->magick_filename,BasePathSansCompressExtension,
3918 if (path != (
char *) NULL)
3920 GetPathComponent(option,TailPath,filename);
3921 (void) FormatLocaleString(images->filename,MaxTextExtent,
"%s%c%s",
3922 path,*DirectorySeparator,filename);
3924 if (format != (
char *) NULL)
3925 AppendImageFormat(format,images->filename);
3926 AppendImageStack(images);
3927 FinalizeImageSettings(image_info,image,MagickFalse);
3928 if (image == (Image *) NULL)
3930 if (global_colormap != MagickFalse)
3935 quantize_info=AcquireQuantizeInfo(image_info);
3936 (void) RemapImages(quantize_info,images,(Image *) NULL);
3937 quantize_info=DestroyQuantizeInfo(quantize_info);
3939 *backup_filename=
'\0';
3941 GetPathComponent(filename,MagickPath,magic);
3945 filename[MagickPathExtent];
3947 if (format != (
char *) NULL)
3948 (void) CopyMagickString(magic,format,MagickPathExtent);
3949 (void) FormatLocaleString(filename,MagickPathExtent,
"%s:%s",magic,
3951 (void) CopyMagickString(image->filename,filename,MagickPathExtent);
3953 if ((LocaleCompare(image->filename,
"-") != 0) &&
3954 (IsPathWritable(image->filename) != MagickFalse))
3962 (void) CopyMagickString(backup_filename,image->filename,
3964 for (i=0; i < 6; i++)
3966 (void) ConcatenateMagickString(backup_filename,
"~",MaxTextExtent);
3967 if (IsPathAccessible(backup_filename) == MagickFalse)
3970 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3971 (rename_utf8(image->filename,backup_filename) != 0))
3972 *backup_filename=
'\0';
3977 image_info->synchronize=MagickTrue;
3978 status&=WriteImages(image_info,image,image->filename,exception);
3979 if (status != MagickFalse)
3981 #if defined(MAGICKCORE_HAVE_UTIME)
3986 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3987 "preserve-timestamp"));
3988 if (preserve_timestamp != MagickFalse)
3993 timestamp.actime=properties.st_atime;
3994 timestamp.modtime=properties.st_mtime;
3995 (void) utime(image->filename,×tamp);
3999 if (*backup_filename !=
'\0')
4000 (void) remove_utf8(backup_filename);
4002 RemoveAllImageStack();
4005 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4006 switch (*(option+1))
4010 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
4013 if (i == (ssize_t) argc)
4014 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4015 if (IsGeometry(argv[i]) == MagickFalse)
4016 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4019 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
4022 if (i == (ssize_t) argc)
4023 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4024 if (IsGeometry(argv[i]) == MagickFalse)
4025 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4028 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
4031 if (i == (ssize_t) argc)
4032 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4033 if (IsGeometry(argv[i]) == MagickFalse)
4034 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4037 if (LocaleCompare(
"affine",option+1) == 0)
4042 if (i == (ssize_t) argc)
4043 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4044 if (IsGeometry(argv[i]) == MagickFalse)
4045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4048 if (LocaleCompare(
"alpha",option+1) == 0)
4056 if (i == (ssize_t) argc)
4057 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4058 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
4060 ThrowMogrifyException(OptionError,
"UnrecognizedAlphaChannelType",
4064 if (LocaleCompare(
"annotate",option+1) == 0)
4069 if (i == (ssize_t) argc)
4070 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4071 if (IsGeometry(argv[i]) == MagickFalse)
4072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4073 if (i == (ssize_t) argc)
4074 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4078 if (LocaleCompare(
"antialias",option+1) == 0)
4080 if (LocaleCompare(
"append",option+1) == 0)
4082 if (LocaleCompare(
"attenuate",option+1) == 0)
4087 if (i == (ssize_t) argc)
4088 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4089 if (IsGeometry(argv[i]) == MagickFalse)
4090 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4093 if (LocaleCompare(
"authenticate",option+1) == 0)
4098 if (i == (ssize_t) argc)
4099 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4102 if (LocaleCompare(
"auto-gamma",option+1) == 0)
4104 if (LocaleCompare(
"auto-level",option+1) == 0)
4106 if (LocaleCompare(
"auto-orient",option+1) == 0)
4108 if (LocaleCompare(
"average",option+1) == 0)
4110 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4114 if (LocaleCompare(
"background",option+1) == 0)
4119 if (i == (ssize_t) argc)
4120 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4123 if (LocaleCompare(
"bias",option+1) == 0)
4128 if (i == (ssize_t) argc)
4129 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4130 if (IsGeometry(argv[i]) == MagickFalse)
4131 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4134 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
4136 if (LocaleCompare(
"black-threshold",option+1) == 0)
4141 if (i == (ssize_t) argc)
4142 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4143 if (IsGeometry(argv[i]) == MagickFalse)
4144 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4147 if (LocaleCompare(
"blue-primary",option+1) == 0)
4152 if (i == (ssize_t) argc)
4153 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4154 if (IsGeometry(argv[i]) == MagickFalse)
4155 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4158 if (LocaleCompare(
"blue-shift",option+1) == 0)
4161 if (i == (ssize_t) argc)
4162 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4163 if (IsGeometry(argv[i]) == MagickFalse)
4164 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4167 if (LocaleCompare(
"blur",option+1) == 0)
4170 if (i == (ssize_t) argc)
4171 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4172 if (IsGeometry(argv[i]) == MagickFalse)
4173 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4176 if (LocaleCompare(
"border",option+1) == 0)
4181 if (i == (ssize_t) argc)
4182 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4183 if (IsGeometry(argv[i]) == MagickFalse)
4184 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4187 if (LocaleCompare(
"bordercolor",option+1) == 0)
4192 if (i == (ssize_t) argc)
4193 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4196 if (LocaleCompare(
"box",option+1) == 0)
4201 if (i == (ssize_t) argc)
4202 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4205 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
4208 if (i == (ssize_t) argc)
4209 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4210 if (IsGeometry(argv[i]) == MagickFalse)
4211 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4214 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4218 if (LocaleCompare(
"cache",option+1) == 0)
4223 if (i == (ssize_t) argc)
4224 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4225 if (IsGeometry(argv[i]) == MagickFalse)
4226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4229 if (LocaleCompare(
"canny",option+1) == 0)
4234 if (i == (ssize_t) argc)
4235 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4236 if (IsGeometry(argv[i]) == MagickFalse)
4237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4240 if (LocaleCompare(
"caption",option+1) == 0)
4245 if (i == (ssize_t) argc)
4246 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4249 if (LocaleCompare(
"channel",option+1) == 0)
4257 if (i == (ssize_t) argc)
4258 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4259 channel=ParseChannelOption(argv[i]);
4261 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4265 if (LocaleCompare(
"cdl",option+1) == 0)
4270 if (i == (ssize_t) argc)
4271 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4274 if (LocaleCompare(
"charcoal",option+1) == 0)
4279 if (i == (ssize_t) argc)
4280 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4281 if (IsGeometry(argv[i]) == MagickFalse)
4282 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4285 if (LocaleCompare(
"chop",option+1) == 0)
4290 if (i == (ssize_t) argc)
4291 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4292 if (IsGeometry(argv[i]) == MagickFalse)
4293 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4296 if (LocaleCompare(
"clamp",option+1) == 0)
4298 if (LocaleCompare(
"clip",option+1) == 0)
4300 if (LocaleCompare(
"clip-mask",option+1) == 0)
4305 if (i == (ssize_t) argc)
4306 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4309 if (LocaleCompare(
"clut",option+1) == 0)
4311 if (LocaleCompare(
"coalesce",option+1) == 0)
4313 if (LocaleCompare(
"colorize",option+1) == 0)
4318 if (i == (ssize_t) argc)
4319 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4320 if (IsGeometry(argv[i]) == MagickFalse)
4321 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4324 if (LocaleCompare(
"color-matrix",option+1) == 0)
4332 if (i == (ssize_t) argc)
4333 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4334 kernel_info=AcquireKernelInfo(argv[i]);
4335 if (kernel_info == (KernelInfo *) NULL)
4336 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4337 kernel_info=DestroyKernelInfo(kernel_info);
4340 if (LocaleCompare(
"colors",option+1) == 0)
4345 if (i == (ssize_t) argc)
4346 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4347 if (IsGeometry(argv[i]) == MagickFalse)
4348 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4351 if (LocaleCompare(
"colorspace",option+1) == 0)
4359 if (i == (ssize_t) argc)
4360 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4361 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4364 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4368 if (LocaleCompare(
"combine",option+1) == 0)
4373 if (i == (ssize_t) argc)
4374 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4377 if (LocaleCompare(
"comment",option+1) == 0)
4382 if (i == (ssize_t) argc)
4383 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4386 if (LocaleCompare(
"compare",option+1) == 0)
4388 if (LocaleCompare(
"complex",option+1) == 0)
4396 if (i == (ssize_t) argc)
4397 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4398 op=ParseCommandOption(MagickComplexOptions,MagickFalse,argv[i]);
4400 ThrowMogrifyException(OptionError,
"UnrecognizedComplexOperator",
4404 if (LocaleCompare(
"compose",option+1) == 0)
4412 if (i == (ssize_t) argc)
4413 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4414 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4417 ThrowMogrifyException(OptionError,
"UnrecognizedComposeOperator",
4421 if (LocaleCompare(
"composite",option+1) == 0)
4423 if (LocaleCompare(
"compress",option+1) == 0)
4431 if (i == (ssize_t) argc)
4432 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4433 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4436 ThrowMogrifyException(OptionError,
"UnrecognizedImageCompression",
4440 if (LocaleCompare(
"concurrent",option+1) == 0)
4442 if (LocaleCompare(
"connected-components",option+1) == 0)
4445 if (i == (ssize_t) argc)
4446 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4447 if (IsGeometry(argv[i]) == MagickFalse)
4448 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4451 if (LocaleCompare(
"contrast",option+1) == 0)
4453 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
4456 if (i == (ssize_t) argc)
4457 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4458 if (IsGeometry(argv[i]) == MagickFalse)
4459 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4462 if (LocaleCompare(
"convolve",option+1) == 0)
4470 if (i == (ssize_t) argc)
4471 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4472 kernel_info=AcquireKernelInfo(argv[i]);
4473 if (kernel_info == (KernelInfo *) NULL)
4474 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4475 kernel_info=DestroyKernelInfo(kernel_info);
4478 if (LocaleCompare(
"copy",option+1) == 0)
4483 if (i == (ssize_t) argc)
4484 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4485 if (IsGeometry(argv[i]) == MagickFalse)
4486 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4488 if (i == (ssize_t) argc)
4489 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4490 if (IsGeometry(argv[i]) == MagickFalse)
4491 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4494 if (LocaleCompare(
"crop",option+1) == 0)
4499 if (i == (ssize_t) argc)
4500 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4501 if (IsGeometry(argv[i]) == MagickFalse)
4502 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4505 if (LocaleCompare(
"cycle",option+1) == 0)
4510 if (i == (ssize_t) argc)
4511 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4512 if (IsGeometry(argv[i]) == MagickFalse)
4513 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4516 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4520 if (LocaleCompare(
"decipher",option+1) == 0)
4525 if (i == (ssize_t) argc)
4526 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4529 if (LocaleCompare(
"deconstruct",option+1) == 0)
4531 if (LocaleCompare(
"debug",option+1) == 0)
4539 if (i == (ssize_t) argc)
4540 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4541 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4543 ThrowMogrifyException(OptionError,
"UnrecognizedEventType",
4545 (void) SetLogEventMask(argv[i]);
4548 if (LocaleCompare(
"define",option+1) == 0)
4551 if (i == (ssize_t) argc)
4552 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4558 define=GetImageOption(image_info,argv[i]);
4559 if (define == (
const char *) NULL)
4560 ThrowMogrifyException(OptionError,
"NoSuchOption",argv[i]);
4565 if (LocaleCompare(
"delay",option+1) == 0)
4570 if (i == (ssize_t) argc)
4571 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4572 if (IsGeometry(argv[i]) == MagickFalse)
4573 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4576 if (LocaleCompare(
"delete",option+1) == 0)
4581 if (i == (ssize_t) argc)
4582 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4583 if (IsGeometry(argv[i]) == MagickFalse)
4584 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4587 if (LocaleCompare(
"density",option+1) == 0)
4592 if (i == (ssize_t) argc)
4593 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4594 if (IsGeometry(argv[i]) == MagickFalse)
4595 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4598 if (LocaleCompare(
"depth",option+1) == 0)
4603 if (i == (ssize_t) argc)
4604 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4605 if (IsGeometry(argv[i]) == MagickFalse)
4606 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4609 if (LocaleCompare(
"deskew",option+1) == 0)
4614 if (i == (ssize_t) argc)
4615 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4616 if (IsGeometry(argv[i]) == MagickFalse)
4617 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4620 if (LocaleCompare(
"despeckle",option+1) == 0)
4622 if (LocaleCompare(
"dft",option+1) == 0)
4624 if (LocaleCompare(
"direction",option+1) == 0)
4632 if (i == (ssize_t) argc)
4633 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4634 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4637 ThrowMogrifyException(OptionError,
"UnrecognizedDirectionType",
4641 if (LocaleCompare(
"display",option+1) == 0)
4646 if (i == (ssize_t) argc)
4647 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4650 if (LocaleCompare(
"dispose",option+1) == 0)
4658 if (i == (ssize_t) argc)
4659 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4660 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4663 ThrowMogrifyException(OptionError,
"UnrecognizedDisposeMethod",
4667 if (LocaleCompare(
"distort",option+1) == 0)
4673 if (i == (ssize_t) argc)
4674 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4675 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4677 ThrowMogrifyException(OptionError,
"UnrecognizedDistortMethod",
4680 if (i == (ssize_t) argc)
4681 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4684 if (LocaleCompare(
"dither",option+1) == 0)
4692 if (i == (ssize_t) argc)
4693 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4694 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4696 ThrowMogrifyException(OptionError,
"UnrecognizedDitherMethod",
4700 if (LocaleCompare(
"draw",option+1) == 0)
4705 if (i == (ssize_t) argc)
4706 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4709 if (LocaleCompare(
"duplicate",option+1) == 0)
4714 if (i == (ssize_t) argc)
4715 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4716 if (IsGeometry(argv[i]) == MagickFalse)
4717 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4720 if (LocaleCompare(
"duration",option+1) == 0)
4725 if (i == (ssize_t) argc)
4726 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4727 if (IsGeometry(argv[i]) == MagickFalse)
4728 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4731 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4735 if (LocaleCompare(
"edge",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(
"emboss",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 if (LocaleCompare(
"encipher",option+1) == 0)
4762 if (i == (ssize_t) argc)
4763 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4766 if (LocaleCompare(
"encoding",option+1) == 0)
4771 if (i == (ssize_t) argc)
4772 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4775 if (LocaleCompare(
"endian",option+1) == 0)
4783 if (i == (ssize_t) argc)
4784 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4785 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4787 ThrowMogrifyException(OptionError,
"UnrecognizedEndianType",
4791 if (LocaleCompare(
"enhance",option+1) == 0)
4793 if (LocaleCompare(
"equalize",option+1) == 0)
4795 if (LocaleCompare(
"evaluate",option+1) == 0)
4803 if (i == (ssize_t) argc)
4804 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4805 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4807 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4810 if (i == (ssize_t) argc)
4811 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4812 if (IsGeometry(argv[i]) == MagickFalse)
4813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4816 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4824 if (i == (ssize_t) argc)
4825 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4826 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4828 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4832 if (LocaleCompare(
"extent",option+1) == 0)
4837 if (i == (ssize_t) argc)
4838 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4839 if (IsGeometry(argv[i]) == MagickFalse)
4840 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4843 if (LocaleCompare(
"extract",option+1) == 0)
4848 if (i == (ssize_t) argc)
4849 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4850 if (IsGeometry(argv[i]) == MagickFalse)
4851 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4854 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4858 if (LocaleCompare(
"family",option+1) == 0)
4863 if (i == (ssize_t) argc)
4864 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4867 if (LocaleCompare(
"features",option+1) == 0)
4872 if (i == (ssize_t) argc)
4873 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4874 if (IsGeometry(argv[i]) == MagickFalse)
4875 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4878 if (LocaleCompare(
"fill",option+1) == 0)
4883 if (i == (ssize_t) argc)
4884 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4887 if (LocaleCompare(
"filter",option+1) == 0)
4895 if (i == (ssize_t) argc)
4896 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4897 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4899 ThrowMogrifyException(OptionError,
"UnrecognizedImageFilter",
4903 if (LocaleCompare(
"flatten",option+1) == 0)
4905 if (LocaleCompare(
"flip",option+1) == 0)
4907 if (LocaleCompare(
"flop",option+1) == 0)
4909 if (LocaleCompare(
"floodfill",option+1) == 0)
4914 if (i == (ssize_t) argc)
4915 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4916 if (IsGeometry(argv[i]) == MagickFalse)
4917 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4919 if (i == (ssize_t) argc)
4920 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4923 if (LocaleCompare(
"font",option+1) == 0)
4928 if (i == (ssize_t) argc)
4929 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4932 if (LocaleCompare(
"format",option+1) == 0)
4934 (void) CopyMagickString(argv[i]+1,
"sans",MaxTextExtent);
4935 (void) CloneString(&format,(
char *) NULL);
4939 if (i == (ssize_t) argc)
4940 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4941 (void) CloneString(&format,argv[i]);
4942 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4943 (void) ConcatenateMagickString(image_info->filename,
":",
4945 (void) SetImageInfo(image_info,0,exception);
4946 if (*image_info->magick ==
'\0')
4947 ThrowMogrifyException(OptionError,
"UnrecognizedImageFormat",
4951 if (LocaleCompare(
"frame",option+1) == 0)
4956 if (i == (ssize_t) argc)
4957 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4958 if (IsGeometry(argv[i]) == MagickFalse)
4959 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4962 if (LocaleCompare(
"function",option+1) == 0)
4970 if (i == (ssize_t) argc)
4971 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4972 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4974 ThrowMogrifyException(OptionError,
"UnrecognizedFunction",argv[i]);
4976 if (i == (ssize_t) argc)
4977 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4980 if (LocaleCompare(
"fuzz",option+1) == 0)
4985 if (i == (ssize_t) argc)
4986 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4987 if (IsGeometry(argv[i]) == MagickFalse)
4988 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4991 if (LocaleCompare(
"fx",option+1) == 0)
4996 if (i == (ssize_t) argc)
4997 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5000 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5004 if (LocaleCompare(
"gamma",option+1) == 0)
5007 if (i == (ssize_t) argc)
5008 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5009 if (IsGeometry(argv[i]) == MagickFalse)
5010 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5013 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
5014 (LocaleCompare(
"gaussian",option+1) == 0))
5017 if (i == (ssize_t) argc)
5018 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5019 if (IsGeometry(argv[i]) == MagickFalse)
5020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5023 if (LocaleCompare(
"geometry",option+1) == 0)
5028 if (i == (ssize_t) argc)
5029 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5030 if (IsGeometry(argv[i]) == MagickFalse)
5031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5034 if (LocaleCompare(
"gravity",option+1) == 0)
5042 if (i == (ssize_t) argc)
5043 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5044 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5047 ThrowMogrifyException(OptionError,
"UnrecognizedGravityType",
5051 if (LocaleCompare(
"grayscale",option+1) == 0)
5059 if (i == (ssize_t) argc)
5060 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5061 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5064 ThrowMogrifyException(OptionError,
"UnrecognizedIntensityMethod",
5068 if (LocaleCompare(
"green-primary",option+1) == 0)
5073 if (i == (ssize_t) argc)
5074 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5075 if (IsGeometry(argv[i]) == MagickFalse)
5076 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5079 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5083 if (LocaleCompare(
"hald-clut",option+1) == 0)
5085 if (LocaleCompare(
"hough-lines",option+1) == 0)
5090 if (i == (ssize_t) argc)
5091 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5092 if (IsGeometry(argv[i]) == MagickFalse)
5093 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5096 if ((LocaleCompare(
"help",option+1) == 0) ||
5097 (LocaleCompare(
"-help",option+1) == 0))
5100 return(MogrifyUsage());
5102 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5106 if (LocaleCompare(
"identify",option+1) == 0)
5108 if (LocaleCompare(
"idft",option+1) == 0)
5110 if (LocaleCompare(
"implode",option+1) == 0)
5115 if (i == (ssize_t) argc)
5116 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5117 if (IsGeometry(argv[i]) == MagickFalse)
5118 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5121 if (LocaleCompare(
"intensity",option+1) == 0)
5129 if (i == (ssize_t) argc)
5130 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5131 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5132 MagickFalse,argv[i]);
5134 ThrowMogrifyException(OptionError,
5135 "UnrecognizedPixelIntensityMethod",argv[i]);
5138 if (LocaleCompare(
"intent",option+1) == 0)
5146 if (i == (ssize_t) argc)
5147 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5148 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5150 ThrowMogrifyException(OptionError,
"UnrecognizedIntentType",
5154 if (LocaleCompare(
"interlace",option+1) == 0)
5162 if (i == (ssize_t) argc)
5163 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5164 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5167 ThrowMogrifyException(OptionError,
"UnrecognizedInterlaceType",
5171 if (LocaleCompare(
"interline-spacing",option+1) == 0)
5176 if (i == (ssize_t) argc)
5177 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5178 if (IsGeometry(argv[i]) == MagickFalse)
5179 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5182 if (LocaleCompare(
"interpolate",option+1) == 0)
5190 if (i == (ssize_t) argc)
5191 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5192 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5194 if (interpolate < 0)
5195 ThrowMogrifyException(OptionError,
"UnrecognizedInterpolateMethod",
5199 if (LocaleCompare(
"interword-spacing",option+1) == 0)
5204 if (i == (ssize_t) argc)
5205 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5206 if (IsGeometry(argv[i]) == MagickFalse)
5207 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5210 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5214 if (LocaleCompare(
"kerning",option+1) == 0)
5219 if (i == (ssize_t) argc)
5220 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5221 if (IsGeometry(argv[i]) == MagickFalse)
5222 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5225 if (LocaleCompare(
"kuwahara",option+1) == 0)
5228 if (i == (ssize_t) argc)
5229 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5230 if (IsGeometry(argv[i]) == MagickFalse)
5231 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5234 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5238 if (LocaleCompare(
"label",option+1) == 0)
5243 if (i == (ssize_t) argc)
5244 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5247 if (LocaleCompare(
"lat",option+1) == 0)
5252 if (i == (ssize_t) argc)
5253 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5254 if (IsGeometry(argv[i]) == MagickFalse)
5255 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5258 if (LocaleCompare(
"layers",option+1) == 0)
5266 if (i == (ssize_t) argc)
5267 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5268 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5270 ThrowMogrifyException(OptionError,
"UnrecognizedLayerMethod",
5274 if (LocaleCompare(
"level",option+1) == 0)
5277 if (i == (ssize_t) argc)
5278 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5279 if (IsGeometry(argv[i]) == MagickFalse)
5280 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5283 if (LocaleCompare(
"level-colors",option+1) == 0)
5286 if (i == (ssize_t) argc)
5287 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5290 if (LocaleCompare(
"linewidth",option+1) == 0)
5295 if (i == (ssize_t) argc)
5296 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5297 if (IsGeometry(argv[i]) == MagickFalse)
5298 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5301 if (LocaleCompare(
"limit",option+1) == 0)
5315 if (i == (ssize_t) argc)
5316 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5317 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5320 ThrowMogrifyException(OptionError,
"UnrecognizedResourceType",
5323 if (i == (ssize_t) argc)
5324 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5325 value=StringToDouble(argv[i],&p);
5327 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
5328 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5331 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
5334 if (i == (ssize_t) argc)
5335 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5336 if (IsGeometry(argv[i]) == MagickFalse)
5337 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5340 if (LocaleCompare(
"list",option+1) == 0)
5348 if (i == (ssize_t) argc)
5349 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5350 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5352 ThrowMogrifyException(OptionError,
"UnrecognizedListType",argv[i]);
5353 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
5355 return(status == 0 ? MagickFalse : MagickTrue);
5357 if (LocaleCompare(
"local-contrast",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(
"log",option+1) == 0)
5371 if ((i == (ssize_t) argc) ||
5372 (strchr(argv[i],
'%') == (
char *) NULL))
5373 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5376 if (LocaleCompare(
"loop",option+1) == 0)
5381 if (i == (ssize_t) argc)
5382 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5383 if (IsGeometry(argv[i]) == MagickFalse)
5384 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5387 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5391 if (LocaleCompare(
"magnify",option+1) == 0)
5393 if (LocaleCompare(
"map",option+1) == 0)
5395 global_colormap=(*option ==
'+') ? MagickTrue : MagickFalse;
5399 if (i == (ssize_t) argc)
5400 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5403 if (LocaleCompare(
"mask",option+1) == 0)
5408 if (i == (ssize_t) argc)
5409 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5412 if (LocaleCompare(
"matte",option+1) == 0)
5414 if (LocaleCompare(
"mattecolor",option+1) == 0)
5419 if (i == (ssize_t) argc)
5420 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5423 if (LocaleCompare(
"metric",option+1) == 0)
5431 if (i == (ssize_t) argc)
5432 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5433 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5435 ThrowMogrifyException(OptionError,
"UnrecognizedMetricType",
5439 if (LocaleCompare(
"maximum",option+1) == 0)
5441 if (LocaleCompare(
"mean-shift",option+1) == 0)
5446 if (i == (ssize_t) argc)
5447 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5448 if (IsGeometry(argv[i]) == MagickFalse)
5449 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5452 if (LocaleCompare(
"median",option+1) == 0)
5457 if (i == (ssize_t) argc)
5458 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5459 if (IsGeometry(argv[i]) == MagickFalse)
5460 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5463 if (LocaleCompare(
"minimum",option+1) == 0)
5465 if (LocaleCompare(
"modulate",option+1) == 0)
5470 if (i == (ssize_t) argc)
5471 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5472 if (IsGeometry(argv[i]) == MagickFalse)
5473 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5476 if (LocaleCompare(
"mode",option+1) == 0)
5481 if (i == (ssize_t) argc)
5482 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5483 if (IsGeometry(argv[i]) == MagickFalse)
5484 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5487 if (LocaleCompare(
"monitor",option+1) == 0)
5489 if (LocaleCompare(
"monochrome",option+1) == 0)
5491 if (LocaleCompare(
"morph",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(
"morphology",option+1) == 0)
5505 token[MaxTextExtent];
5514 if (i == (ssize_t) argc)
5515 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5516 (void) GetNextToken(argv[i],(
const char **) NULL,MaxTextExtent,token);
5517 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5519 ThrowMogrifyException(OptionError,
"UnrecognizedMorphologyMethod",
5522 if (i == (ssize_t) argc)
5523 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5524 kernel_info=AcquireKernelInfo(argv[i]);
5525 if (kernel_info == (KernelInfo *) NULL)
5526 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5527 kernel_info=DestroyKernelInfo(kernel_info);
5530 if (LocaleCompare(
"mosaic",option+1) == 0)
5532 if (LocaleCompare(
"motion-blur",option+1) == 0)
5537 if (i == (ssize_t) argc)
5538 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5539 if (IsGeometry(argv[i]) == MagickFalse)
5540 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5543 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5547 if (LocaleCompare(
"negate",option+1) == 0)
5549 if (LocaleCompare(
"noise",option+1) == 0)
5552 if (i == (ssize_t) argc)
5553 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5559 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5561 ThrowMogrifyException(OptionError,
"UnrecognizedNoiseType",
5565 if (IsGeometry(argv[i]) == MagickFalse)
5566 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5569 if (LocaleCompare(
"noop",option+1) == 0)
5571 if (LocaleCompare(
"normalize",option+1) == 0)
5573 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5577 if (LocaleCompare(
"opaque",option+1) == 0)
5580 if (i == (ssize_t) argc)
5581 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5584 if (LocaleCompare(
"ordered-dither",option+1) == 0)
5589 if (i == (ssize_t) argc)
5590 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5593 if (LocaleCompare(
"orient",option+1) == 0)
5598 orientation=UndefinedOrientation;
5602 if (i == (ssize_t) argc)
5603 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5604 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5606 if (orientation < 0)
5607 ThrowMogrifyException(OptionError,
"UnrecognizedImageOrientation",
5611 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5615 if (LocaleCompare(
"page",option+1) == 0)
5620 if (i == (ssize_t) argc)
5621 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5624 if (LocaleCompare(
"paint",option+1) == 0)
5629 if (i == (ssize_t) argc)
5630 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5631 if (IsGeometry(argv[i]) == MagickFalse)
5632 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5635 if (LocaleCompare(
"path",option+1) == 0)
5637 (void) CloneString(&path,(
char *) NULL);
5641 if (i == (ssize_t) argc)
5642 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5643 (void) CloneString(&path,argv[i]);
5646 if (LocaleCompare(
"perceptible",option+1) == 0)
5651 if (i == (ssize_t) argc)
5652 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5653 if (IsGeometry(argv[i]) == MagickFalse)
5654 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5657 if (LocaleCompare(
"pointsize",option+1) == 0)
5662 if (i == (ssize_t) argc)
5663 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5664 if (IsGeometry(argv[i]) == MagickFalse)
5665 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5668 if (LocaleCompare(
"polaroid",option+1) == 0)
5673 if (i == (ssize_t) argc)
5674 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5675 if (IsGeometry(argv[i]) == MagickFalse)
5676 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5679 if (LocaleCompare(
"poly",option+1) == 0)
5684 if (i == (ssize_t) argc)
5685 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5686 if (IsGeometry(argv[i]) == MagickFalse)
5687 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5690 if (LocaleCompare(
"posterize",option+1) == 0)
5695 if (i == (ssize_t) argc)
5696 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5697 if (IsGeometry(argv[i]) == MagickFalse)
5698 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5701 if (LocaleCompare(
"precision",option+1) == 0)
5706 if (i == (ssize_t) argc)
5707 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5708 if (IsGeometry(argv[i]) == MagickFalse)
5709 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5712 if (LocaleCompare(
"print",option+1) == 0)
5717 if (i == (ssize_t) argc)
5718 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5721 if (LocaleCompare(
"process",option+1) == 0)
5726 if (i == (ssize_t) argc)
5727 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5730 if (LocaleCompare(
"profile",option+1) == 0)
5733 if (i == (ssize_t) argc)
5734 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5737 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5741 if (LocaleCompare(
"quality",option+1) == 0)
5746 if (i == (ssize_t) argc)
5747 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5748 if (IsGeometry(argv[i]) == MagickFalse)
5749 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5752 if (LocaleCompare(
"quantize",option+1) == 0)
5760 if (i == (ssize_t) argc)
5761 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5762 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5765 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
5769 if (LocaleCompare(
"quiet",option+1) == 0)
5771 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5775 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
5776 LocaleCompare(
"rotational-blur",option+1) == 0)
5779 if (i == (ssize_t) argc)
5780 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5781 if (IsGeometry(argv[i]) == MagickFalse)
5782 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5785 if (LocaleCompare(
"raise",option+1) == 0)
5788 if (i == (ssize_t) argc)
5789 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5790 if (IsGeometry(argv[i]) == MagickFalse)
5791 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5794 if (LocaleCompare(
"random-threshold",option+1) == 0)
5799 if (i == (ssize_t) argc)
5800 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5801 if (IsGeometry(argv[i]) == MagickFalse)
5802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5805 if (LocaleCompare(
"recolor",option+1) == 0)
5810 if (i == (ssize_t) argc)
5811 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5812 if (IsGeometry(argv[i]) == MagickFalse)
5813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5816 if (LocaleCompare(
"red-primary",option+1) == 0)
5821 if (i == (ssize_t) argc)
5822 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5823 if (IsGeometry(argv[i]) == MagickFalse)
5824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5826 if (LocaleCompare(
"regard-warnings",option+1) == 0)
5828 if (LocaleCompare(
"region",option+1) == 0)
5833 if (i == (ssize_t) argc)
5834 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5835 if (IsGeometry(argv[i]) == MagickFalse)
5836 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5839 if (LocaleCompare(
"remap",option+1) == 0)
5844 if (i == (ssize_t) argc)
5845 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5848 if (LocaleCompare(
"render",option+1) == 0)
5850 if (LocaleCompare(
"repage",option+1) == 0)
5855 if (i == (ssize_t) argc)
5856 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5857 if (IsGeometry(argv[i]) == MagickFalse)
5858 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5861 if (LocaleCompare(
"resample",option+1) == 0)
5866 if (i == (ssize_t) argc)
5867 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5868 if (IsGeometry(argv[i]) == MagickFalse)
5869 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5872 if (LocaleCompare(
"resize",option+1) == 0)
5877 if (i == (ssize_t) argc)
5878 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5879 if (IsGeometry(argv[i]) == MagickFalse)
5880 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5883 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
5885 respect_parenthesis=(*option ==
'-') ? MagickTrue : MagickFalse;
5888 if (LocaleCompare(
"reverse",option+1) == 0)
5890 if (LocaleCompare(
"roll",option+1) == 0)
5895 if (i == (ssize_t) argc)
5896 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5897 if (IsGeometry(argv[i]) == MagickFalse)
5898 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5901 if (LocaleCompare(
"rotate",option+1) == 0)
5904 if (i == (ssize_t) argc)
5905 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5906 if (IsGeometry(argv[i]) == MagickFalse)
5907 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5910 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5914 if (LocaleCompare(
"sample",option+1) == 0)
5919 if (i == (ssize_t) argc)
5920 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5921 if (IsGeometry(argv[i]) == MagickFalse)
5922 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5925 if (LocaleCompare(
"sampling-factor",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 if (LocaleCompare(
"scale",option+1) == 0)
5941 if (i == (ssize_t) argc)
5942 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5943 if (IsGeometry(argv[i]) == MagickFalse)
5944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5947 if (LocaleCompare(
"scene",option+1) == 0)
5952 if (i == (ssize_t) argc)
5953 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5954 if (IsGeometry(argv[i]) == MagickFalse)
5955 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5958 if (LocaleCompare(
"seed",option+1) == 0)
5963 if (i == (ssize_t) argc)
5964 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5965 if (IsGeometry(argv[i]) == MagickFalse)
5966 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5969 if (LocaleCompare(
"segment",option+1) == 0)
5974 if (i == (ssize_t) argc)
5975 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5976 if (IsGeometry(argv[i]) == MagickFalse)
5977 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5980 if (LocaleCompare(
"selective-blur",option+1) == 0)
5983 if (i == (ssize_t) argc)
5984 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5985 if (IsGeometry(argv[i]) == MagickFalse)
5986 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5989 if (LocaleCompare(
"separate",option+1) == 0)
5991 if (LocaleCompare(
"sepia-tone",option+1) == 0)
5996 if (i == (ssize_t) argc)
5997 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5998 if (IsGeometry(argv[i]) == MagickFalse)
5999 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6002 if (LocaleCompare(
"set",option+1) == 0)
6005 if (i == (ssize_t) argc)
6006 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6010 if (i == (ssize_t) argc)
6011 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6014 if (LocaleCompare(
"shade",option+1) == 0)
6017 if (i == (ssize_t) argc)
6018 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6019 if (IsGeometry(argv[i]) == MagickFalse)
6020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6023 if (LocaleCompare(
"shadow",option+1) == 0)
6028 if (i == (ssize_t) argc)
6029 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6030 if (IsGeometry(argv[i]) == MagickFalse)
6031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6034 if (LocaleCompare(
"sharpen",option+1) == 0)
6037 if (i == (ssize_t) argc)
6038 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6039 if (IsGeometry(argv[i]) == MagickFalse)
6040 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6043 if (LocaleCompare(
"shave",option+1) == 0)
6048 if (i == (ssize_t) argc)
6049 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6050 if (IsGeometry(argv[i]) == MagickFalse)
6051 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6054 if (LocaleCompare(
"shear",option+1) == 0)
6057 if (i == (ssize_t) argc)
6058 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6059 if (IsGeometry(argv[i]) == MagickFalse)
6060 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6063 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
6066 if (i == (ssize_t) argc)
6067 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6068 if (IsGeometry(argv[i]) == MagickFalse)
6069 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6072 if (LocaleCompare(
"size",option+1) == 0)
6077 if (i == (ssize_t) argc)
6078 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6079 if (IsGeometry(argv[i]) == MagickFalse)
6080 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6083 if (LocaleCompare(
"sketch",option+1) == 0)
6088 if (i == (ssize_t) argc)
6089 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6090 if (IsGeometry(argv[i]) == MagickFalse)
6091 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6094 if (LocaleCompare(
"smush",option+1) == 0)
6097 if (i == (ssize_t) argc)
6098 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6099 if (IsGeometry(argv[i]) == MagickFalse)
6100 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6104 if (LocaleCompare(
"solarize",option+1) == 0)
6109 if (i == (ssize_t) argc)
6110 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6111 if (IsGeometry(argv[i]) == MagickFalse)
6112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6115 if (LocaleCompare(
"sparse-color",option+1) == 0)
6121 if (i == (ssize_t) argc)
6122 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6123 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6125 ThrowMogrifyException(OptionError,
"UnrecognizedSparseColorMethod",
6128 if (i == (ssize_t) argc)
6129 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6132 if (LocaleCompare(
"splice",option+1) == 0)
6137 if (i == (ssize_t) argc)
6138 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6139 if (IsGeometry(argv[i]) == MagickFalse)
6140 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6143 if (LocaleCompare(
"spread",option+1) == 0)
6148 if (i == (ssize_t) argc)
6149 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6150 if (IsGeometry(argv[i]) == MagickFalse)
6151 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6154 if (LocaleCompare(
"statistic",option+1) == 0)
6162 if (i == (ssize_t) argc)
6163 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6164 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6166 ThrowMogrifyException(OptionError,
"UnrecognizedStatisticType",
6169 if (i == (ssize_t) argc)
6170 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6171 if (IsGeometry(argv[i]) == MagickFalse)
6172 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6175 if (LocaleCompare(
"stretch",option+1) == 0)
6183 if (i == (ssize_t) argc)
6184 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6185 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
6187 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6191 if (LocaleCompare(
"strip",option+1) == 0)
6193 if (LocaleCompare(
"stroke",option+1) == 0)
6198 if (i == (ssize_t) argc)
6199 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6202 if (LocaleCompare(
"strokewidth",option+1) == 0)
6207 if (i == (ssize_t) argc)
6208 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6209 if (IsGeometry(argv[i]) == MagickFalse)
6210 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6213 if (LocaleCompare(
"style",option+1) == 0)
6221 if (i == (ssize_t) argc)
6222 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6223 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6225 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6229 if (LocaleCompare(
"swap",option+1) == 0)
6234 if (i == (ssize_t) argc)
6235 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6236 if (IsGeometry(argv[i]) == MagickFalse)
6237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6240 if (LocaleCompare(
"swirl",option+1) == 0)
6245 if (i == (ssize_t) argc)
6246 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6247 if (IsGeometry(argv[i]) == MagickFalse)
6248 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6251 if (LocaleCompare(
"synchronize",option+1) == 0)
6253 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6257 if (LocaleCompare(
"taint",option+1) == 0)
6259 if (LocaleCompare(
"texture",option+1) == 0)
6264 if (i == (ssize_t) argc)
6265 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6268 if (LocaleCompare(
"tile",option+1) == 0)
6273 if (i == (ssize_t) argc)
6274 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6277 if (LocaleCompare(
"tile-offset",option+1) == 0)
6282 if (i == (ssize_t) argc)
6283 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6284 if (IsGeometry(argv[i]) == MagickFalse)
6285 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6288 if (LocaleCompare(
"tint",option+1) == 0)
6293 if (i == (ssize_t) argc)
6294 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6295 if (IsGeometry(argv[i]) == MagickFalse)
6296 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6299 if (LocaleCompare(
"transform",option+1) == 0)
6301 if (LocaleCompare(
"transpose",option+1) == 0)
6303 if (LocaleCompare(
"transverse",option+1) == 0)
6305 if (LocaleCompare(
"threshold",option+1) == 0)
6310 if (i == (ssize_t) argc)
6311 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6312 if (IsGeometry(argv[i]) == MagickFalse)
6313 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6316 if (LocaleCompare(
"thumbnail",option+1) == 0)
6321 if (i == (ssize_t) argc)
6322 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6323 if (IsGeometry(argv[i]) == MagickFalse)
6324 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6327 if (LocaleCompare(
"transparent",option+1) == 0)
6330 if (i == (ssize_t) argc)
6331 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6334 if (LocaleCompare(
"transparent-color",option+1) == 0)
6339 if (i == (ssize_t) argc)
6340 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6343 if (LocaleCompare(
"treedepth",option+1) == 0)
6348 if (i == (ssize_t) argc)
6349 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6350 if (IsGeometry(argv[i]) == MagickFalse)
6351 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6354 if (LocaleCompare(
"trim",option+1) == 0)
6356 if (LocaleCompare(
"type",option+1) == 0)
6364 if (i == (ssize_t) argc)
6365 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6366 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6368 ThrowMogrifyException(OptionError,
"UnrecognizedImageType",
6372 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6376 if (LocaleCompare(
"undercolor",option+1) == 0)
6381 if (i == (ssize_t) argc)
6382 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6385 if (LocaleCompare(
"unique-colors",option+1) == 0)
6387 if (LocaleCompare(
"units",option+1) == 0)
6395 if (i == (ssize_t) argc)
6396 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6397 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6400 ThrowMogrifyException(OptionError,
"UnrecognizedUnitsType",
6404 if (LocaleCompare(
"unsharp",option+1) == 0)
6407 if (i == (ssize_t) argc)
6408 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6409 if (IsGeometry(argv[i]) == MagickFalse)
6410 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6413 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6417 if (LocaleCompare(
"verbose",option+1) == 0)
6419 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
6422 if ((LocaleCompare(
"version",option+1) == 0) ||
6423 (LocaleCompare(
"-version",option+1) == 0))
6425 ListMagickVersion(stdout);
6428 if (LocaleCompare(
"view",option+1) == 0)
6433 if (i == (ssize_t) argc)
6434 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6437 if (LocaleCompare(
"vignette",option+1) == 0)
6442 if (i == (ssize_t) argc)
6443 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6444 if (IsGeometry(argv[i]) == MagickFalse)
6445 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6448 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
6456 if (i == (ssize_t) argc)
6457 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6458 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6461 ThrowMogrifyException(OptionError,
6462 "UnrecognizedVirtualPixelMethod",argv[i]);
6465 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6469 if (LocaleCompare(
"wave",option+1) == 0)
6472 if (i == (ssize_t) argc)
6473 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6474 if (IsGeometry(argv[i]) == MagickFalse)
6475 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6478 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
6481 if (i == (ssize_t) argc)
6482 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6483 if (IsGeometry(argv[i]) == MagickFalse)
6484 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6487 if (LocaleCompare(
"weight",option+1) == 0)
6492 if (i == (ssize_t) argc)
6493 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6496 if (LocaleCompare(
"white-point",option+1) == 0)
6501 if (i == (ssize_t) argc)
6502 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6503 if (IsGeometry(argv[i]) == MagickFalse)
6504 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6507 if (LocaleCompare(
"white-threshold",option+1) == 0)
6512 if (i == (ssize_t) argc)
6513 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6514 if (IsGeometry(argv[i]) == MagickFalse)
6515 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6518 if (LocaleCompare(
"write",option+1) == 0)
6521 if (i == (ssize_t) argc)
6522 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6525 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6530 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6532 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6533 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6534 if (fire != MagickFalse)
6535 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6538 ThrowMogrifyException(OptionError,
"UnbalancedParenthesis",argv[i]);
6539 if (i != (ssize_t) argc)
6540 ThrowMogrifyException(OptionError,
"MissingAnImageFilename",argv[i]);
6542 return(status != 0 ? MagickTrue : MagickFalse);
6577 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6578 const int argc,
const char **argv,ExceptionInfo *exception)
6595 assert(image_info != (ImageInfo *) NULL);
6596 assert(image_info->signature == MagickCoreSignature);
6597 if (IsEventLogging() != MagickFalse)
6598 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
6599 image_info->filename);
6605 for (i=0; i < (ssize_t) argc; i++)
6608 if (IsCommandOption(option) == MagickFalse)
6610 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6611 count=MagickMax(count,0L);
6612 if ((i+count) >= (ssize_t) argc)
6614 switch (*(option+1))
6618 if (LocaleCompare(
"adjoin",option+1) == 0)
6620 image_info->adjoin=(*option ==
'-') ? MagickTrue : MagickFalse;
6623 if (LocaleCompare(
"antialias",option+1) == 0)
6625 image_info->antialias=(*option ==
'-') ? MagickTrue : MagickFalse;
6628 if (LocaleCompare(
"attenuate",option+1) == 0)
6632 (void) DeleteImageOption(image_info,option+1);
6635 (void) SetImageOption(image_info,option+1,argv[i+1]);
6638 if (LocaleCompare(
"authenticate",option+1) == 0)
6641 (void) CloneString(&image_info->authenticate,(
char *) NULL);
6643 (
void) CloneString(&image_info->authenticate,argv[i+1]);
6650 if (LocaleCompare(
"background",option+1) == 0)
6654 (void) DeleteImageOption(image_info,option+1);
6655 (void) QueryColorDatabase(MogrifyBackgroundColor,
6656 &image_info->background_color,exception);
6659 (void) SetImageOption(image_info,option+1,argv[i+1]);
6660 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6664 if (LocaleCompare(
"bias",option+1) == 0)
6668 (void) SetImageOption(image_info,option+1,
"0.0");
6671 (void) SetImageOption(image_info,option+1,argv[i+1]);
6674 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
6678 (void) SetImageOption(image_info,option+1,
"false");
6681 (void) SetImageOption(image_info,option+1,
"true");
6684 if (LocaleCompare(
"blue-primary",option+1) == 0)
6688 (void) SetImageOption(image_info,option+1,
"0.0");
6691 (void) SetImageOption(image_info,option+1,argv[i+1]);
6694 if (LocaleCompare(
"bordercolor",option+1) == 0)
6698 (void) DeleteImageOption(image_info,option+1);
6699 (void) QueryColorDatabase(MogrifyBorderColor,
6700 &image_info->border_color,exception);
6703 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6705 (void) SetImageOption(image_info,option+1,argv[i+1]);
6708 if (LocaleCompare(
"box",option+1) == 0)
6712 (void) SetImageOption(image_info,
"undercolor",
"none");
6715 (void) SetImageOption(image_info,
"undercolor",argv[i+1]);
6722 if (LocaleCompare(
"cache",option+1) == 0)
6727 limit=MagickResourceInfinity;
6728 if (LocaleCompare(
"unlimited",argv[i+1]) != 0)
6729 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],100.0);
6730 (void) SetMagickResourceLimit(MemoryResource,limit);
6731 (void) SetMagickResourceLimit(MapResource,2*limit);
6734 if (LocaleCompare(
"caption",option+1) == 0)
6738 (void) DeleteImageOption(image_info,option+1);
6741 (void) SetImageOption(image_info,option+1,argv[i+1]);
6744 if (LocaleCompare(
"channel",option+1) == 0)
6748 image_info->channel=DefaultChannels;
6751 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6754 if (LocaleCompare(
"colors",option+1) == 0)
6756 image_info->colors=StringToUnsignedLong(argv[i+1]);
6759 if (LocaleCompare(
"colorspace",option+1) == 0)
6763 image_info->colorspace=UndefinedColorspace;
6764 (void) SetImageOption(image_info,option+1,
"undefined");
6767 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6768 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6769 (void) SetImageOption(image_info,option+1,argv[i+1]);
6772 if (LocaleCompare(
"comment",option+1) == 0)
6776 (void) DeleteImageOption(image_info,option+1);
6779 (void) SetImageOption(image_info,option+1,argv[i+1]);
6782 if (LocaleCompare(
"compose",option+1) == 0)
6786 (void) SetImageOption(image_info,option+1,
"undefined");
6789 (void) SetImageOption(image_info,option+1,argv[i+1]);
6792 if (LocaleCompare(
"compress",option+1) == 0)
6796 image_info->compression=UndefinedCompression;
6797 (void) SetImageOption(image_info,option+1,
"undefined");
6800 image_info->compression=(CompressionType) ParseCommandOption(
6801 MagickCompressOptions,MagickFalse,argv[i+1]);
6802 (void) SetImageOption(image_info,option+1,argv[i+1]);
6809 if (LocaleCompare(
"debug",option+1) == 0)
6812 (void) SetLogEventMask(
"none");
6814 (
void) SetLogEventMask(argv[i+1]);
6815 image_info->debug=IsEventLogging();
6818 if (LocaleCompare(
"define",option+1) == 0)
6822 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6823 (void) DeleteImageRegistry(argv[i+1]+9);
6825 (
void) DeleteImageOption(image_info,argv[i+1]);
6828 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6830 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6834 (void) DefineImageOption(image_info,argv[i+1]);
6837 if (LocaleCompare(
"delay",option+1) == 0)
6841 (void) SetImageOption(image_info,option+1,
"0");
6844 (void) SetImageOption(image_info,option+1,argv[i+1]);
6847 if (LocaleCompare(
"density",option+1) == 0)
6854 if (image_info->density != (
char *) NULL)
6855 image_info->density=DestroyString(image_info->density);
6856 (void) SetImageOption(image_info,option+1,
"72");
6859 (void) CloneString(&image_info->density,argv[i+1]);
6860 (void) SetImageOption(image_info,option+1,argv[i+1]);
6863 if (LocaleCompare(
"depth",option+1) == 0)
6867 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6870 image_info->depth=StringToUnsignedLong(argv[i+1]);
6873 if (LocaleCompare(
"direction",option+1) == 0)
6877 (void) SetImageOption(image_info,option+1,
"undefined");
6880 (void) SetImageOption(image_info,option+1,argv[i+1]);
6883 if (LocaleCompare(
"display",option+1) == 0)
6887 if (image_info->server_name != (
char *) NULL)
6888 image_info->server_name=DestroyString(
6889 image_info->server_name);
6892 (void) CloneString(&image_info->server_name,argv[i+1]);
6895 if (LocaleCompare(
"dispose",option+1) == 0)
6899 (void) SetImageOption(image_info,option+1,
"undefined");
6902 (void) SetImageOption(image_info,option+1,argv[i+1]);
6905 if (LocaleCompare(
"dither",option+1) == 0)
6909 image_info->dither=MagickFalse;
6910 (void) SetImageOption(image_info,option+1,
"none");
6913 (void) SetImageOption(image_info,option+1,argv[i+1]);
6914 image_info->dither=MagickTrue;
6921 if (LocaleCompare(
"encoding",option+1) == 0)
6925 (void) SetImageOption(image_info,option+1,
"undefined");
6928 (void) SetImageOption(image_info,option+1,argv[i+1]);
6931 if (LocaleCompare(
"endian",option+1) == 0)
6935 image_info->endian=UndefinedEndian;
6936 (void) SetImageOption(image_info,option+1,
"undefined");
6939 image_info->endian=(EndianType) ParseCommandOption(
6940 MagickEndianOptions,MagickFalse,argv[i+1]);
6941 (void) SetImageOption(image_info,option+1,argv[i+1]);
6944 if (LocaleCompare(
"extract",option+1) == 0)
6951 if (image_info->extract != (
char *) NULL)
6952 image_info->extract=DestroyString(image_info->extract);
6955 (void) CloneString(&image_info->extract,argv[i+1]);
6962 if (LocaleCompare(
"family",option+1) == 0)
6965 (void) SetImageOption(image_info,option+1,argv[i+1]);
6968 if (LocaleCompare(
"fill",option+1) == 0)
6972 (void) SetImageOption(image_info,option+1,
"none");
6975 (void) SetImageOption(image_info,option+1,argv[i+1]);
6978 if (LocaleCompare(
"filter",option+1) == 0)
6982 (void) SetImageOption(image_info,option+1,
"undefined");
6985 (void) SetImageOption(image_info,option+1,argv[i+1]);
6988 if (LocaleCompare(
"font",option+1) == 0)
6992 if (image_info->font != (
char *) NULL)
6993 image_info->font=DestroyString(image_info->font);
6996 (void) CloneString(&image_info->font,argv[i+1]);
6999 if (LocaleCompare(
"format",option+1) == 0)
7001 (void) SetImageOption(image_info,option+1,argv[i+1]);
7004 if (LocaleCompare(
"fuzz",option+1) == 0)
7008 image_info->fuzz=0.0;
7009 (void) SetImageOption(image_info,option+1,
"0");
7012 image_info->fuzz=StringToDoubleInterval(argv[i+1],(
double)
7014 (void) SetImageOption(image_info,option+1,argv[i+1]);
7021 if (LocaleCompare(
"gravity",option+1) == 0)
7025 (void) SetImageOption(image_info,option+1,
"undefined");
7028 (void) SetImageOption(image_info,option+1,argv[i+1]);
7031 if (LocaleCompare(
"green-primary",option+1) == 0)
7035 (void) SetImageOption(image_info,option+1,
"0.0");
7038 (void) SetImageOption(image_info,option+1,argv[i+1]);
7045 if (LocaleCompare(
"intensity",option+1) == 0)
7049 (void) SetImageOption(image_info,option+1,
"undefined");
7052 (void) SetImageOption(image_info,option+1,argv[i+1]);
7055 if (LocaleCompare(
"intent",option+1) == 0)
7059 (void) SetImageOption(image_info,option+1,
"undefined");
7062 (void) SetImageOption(image_info,option+1,argv[i+1]);
7065 if (LocaleCompare(
"interlace",option+1) == 0)
7069 image_info->interlace=UndefinedInterlace;
7070 (void) SetImageOption(image_info,option+1,
"undefined");
7073 image_info->interlace=(InterlaceType) ParseCommandOption(
7074 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7075 (void) SetImageOption(image_info,option+1,argv[i+1]);
7078 if (LocaleCompare(
"interline-spacing",option+1) == 0)
7082 (void) SetImageOption(image_info,option+1,
"undefined");
7085 (void) SetImageOption(image_info,option+1,argv[i+1]);
7088 if (LocaleCompare(
"interpolate",option+1) == 0)
7092 (void) SetImageOption(image_info,option+1,
"undefined");
7095 (void) SetImageOption(image_info,option+1,argv[i+1]);
7098 if (LocaleCompare(
"interword-spacing",option+1) == 0)
7102 (void) SetImageOption(image_info,option+1,
"undefined");
7105 (void) SetImageOption(image_info,option+1,argv[i+1]);
7112 if (LocaleCompare(
"kerning",option+1) == 0)
7116 (void) SetImageOption(image_info,option+1,
"undefined");
7119 (void) SetImageOption(image_info,option+1,argv[i+1]);
7126 if (LocaleCompare(
"label",option+1) == 0)
7130 (void) DeleteImageOption(image_info,option+1);
7133 (void) SetImageOption(image_info,option+1,argv[i+1]);
7136 if (LocaleCompare(
"limit",option+1) == 0)
7146 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7147 MagickFalse,argv[i+1]);
7148 limit=MagickResourceInfinity;
7149 if (LocaleCompare(
"unlimited",argv[i+2]) != 0)
7150 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7151 (void) SetMagickResourceLimit(type,limit);
7154 if (LocaleCompare(
"list",option+1) == 0)
7162 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7165 case MagickCoderOptions:
7167 (void) ListCoderInfo((FILE *) NULL,exception);
7170 case MagickColorOptions:
7172 (void) ListColorInfo((FILE *) NULL,exception);
7175 case MagickConfigureOptions:
7177 (void) ListConfigureInfo((FILE *) NULL,exception);
7180 case MagickDelegateOptions:
7182 (void) ListDelegateInfo((FILE *) NULL,exception);
7185 case MagickFontOptions:
7187 (void) ListTypeInfo((FILE *) NULL,exception);
7190 case MagickFormatOptions:
7192 (void) ListMagickInfo((FILE *) NULL,exception);
7195 case MagickLocaleOptions:
7197 (void) ListLocaleInfo((FILE *) NULL,exception);
7200 case MagickLogOptions:
7202 (void) ListLogInfo((FILE *) NULL,exception);
7205 case MagickMagicOptions:
7207 (void) ListMagicInfo((FILE *) NULL,exception);
7210 case MagickMimeOptions:
7212 (void) ListMimeInfo((FILE *) NULL,exception);
7215 case MagickModuleOptions:
7217 (void) ListModuleInfo((FILE *) NULL,exception);
7220 case MagickPolicyOptions:
7222 (void) ListPolicyInfo((FILE *) NULL,exception);
7225 case MagickResourceOptions:
7227 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7230 case MagickThresholdOptions:
7232 (void) ListThresholdMaps((FILE *) NULL,exception);
7237 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7244 if (LocaleCompare(
"log",option+1) == 0)
7248 (void) SetLogFormat(argv[i+1]);
7251 if (LocaleCompare(
"loop",option+1) == 0)
7255 (void) SetImageOption(image_info,option+1,
"0");
7258 (void) SetImageOption(image_info,option+1,argv[i+1]);
7265 if (LocaleCompare(
"matte",option+1) == 0)
7269 (void) SetImageOption(image_info,option+1,
"false");
7272 (void) SetImageOption(image_info,option+1,
"true");
7275 if (LocaleCompare(
"mattecolor",option+1) == 0)
7279 (void) SetImageOption(image_info,option+1,argv[i+1]);
7280 (void) QueryColorDatabase(MogrifyMatteColor,
7281 &image_info->matte_color,exception);
7284 (void) SetImageOption(image_info,option+1,argv[i+1]);
7285 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7289 if (LocaleCompare(
"metric",option+1) == 0)
7293 (void) DeleteImageOption(image_info,option+1);
7296 (void) SetImageOption(image_info,option+1,argv[i+1]);
7299 if (LocaleCompare(
"monitor",option+1) == 0)
7301 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7305 if (LocaleCompare(
"monochrome",option+1) == 0)
7307 image_info->monochrome=(*option ==
'-') ? MagickTrue : MagickFalse;
7314 if (LocaleCompare(
"orient",option+1) == 0)
7318 image_info->orientation=UndefinedOrientation;
7319 (void) SetImageOption(image_info,option+1,
"undefined");
7322 image_info->orientation=(OrientationType) ParseCommandOption(
7323 MagickOrientationOptions,MagickFalse,argv[i+1]);
7324 (void) SetImageOption(image_info,option+1,argv[i+1]);
7330 if (LocaleCompare(
"page",option+1) == 0)
7334 page[MaxTextExtent];
7347 (void) DeleteImageOption(image_info,option+1);
7348 (void) CloneString(&image_info->page,(
char *) NULL);
7351 (void) memset(&geometry,0,
sizeof(geometry));
7352 image_option=GetImageOption(image_info,
"page");
7353 if (image_option != (
const char *) NULL)
7354 (void) ParseAbsoluteGeometry(image_option,&geometry);
7355 canonical_page=GetPageGeometry(argv[i+1]);
7356 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7357 canonical_page=DestroyString(canonical_page);
7358 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu",
7359 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
7360 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7361 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu%+ld%+ld",
7362 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
7363 (
long) geometry.x,(long) geometry.y);
7364 (void) SetImageOption(image_info,option+1,page);
7365 (void) CloneString(&image_info->page,page);
7368 if (LocaleCompare(
"pen",option+1) == 0)
7372 (void) SetImageOption(image_info,option+1,
"none");
7375 (void) SetImageOption(image_info,option+1,argv[i+1]);
7378 if (LocaleCompare(
"ping",option+1) == 0)
7380 image_info->ping=(*option ==
'-') ? MagickTrue : MagickFalse;
7383 if (LocaleCompare(
"pointsize",option+1) == 0)
7386 geometry_info.rho=0.0;
7388 (
void) ParseGeometry(argv[i+1],&geometry_info);
7389 image_info->pointsize=geometry_info.rho;
7392 if (LocaleCompare(
"precision",option+1) == 0)
7394 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7397 if (LocaleCompare(
"preview",option+1) == 0)
7404 image_info->preview_type=UndefinedPreview;
7407 image_info->preview_type=(PreviewType) ParseCommandOption(
7408 MagickPreviewOptions,MagickFalse,argv[i+1]);
7415 if (LocaleCompare(
"quality",option+1) == 0)
7422 image_info->quality=UndefinedCompressionQuality;
7423 (void) SetImageOption(image_info,option+1,
"0");
7426 image_info->quality=StringToUnsignedLong(argv[i+1]);
7427 (void) SetImageOption(image_info,option+1,argv[i+1]);
7430 if (LocaleCompare(
"quiet",option+1) == 0)
7432 static WarningHandler
7433 warning_handler = (WarningHandler) NULL;
7440 warning_handler=SetWarningHandler(warning_handler);
7446 warning_handler=SetWarningHandler((WarningHandler) NULL);
7453 if (LocaleCompare(
"red-primary",option+1) == 0)
7457 (void) SetImageOption(image_info,option+1,
"0.0");
7460 (void) SetImageOption(image_info,option+1,argv[i+1]);
7467 if (LocaleCompare(
"sampling-factor",option+1) == 0)
7474 if (image_info->sampling_factor != (
char *) NULL)
7475 image_info->sampling_factor=DestroyString(
7476 image_info->sampling_factor);
7479 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7482 if (LocaleCompare(
"scene",option+1) == 0)
7489 image_info->scene=0;
7490 (void) SetImageOption(image_info,option+1,
"0");
7493 image_info->scene=StringToUnsignedLong(argv[i+1]);
7494 (void) SetImageOption(image_info,option+1,argv[i+1]);
7497 if (LocaleCompare(
"seed",option+1) == 0)
7504 seed=(
unsigned long) time((time_t *) NULL);
7505 SetRandomSecretKey(seed);
7508 seed=StringToUnsignedLong(argv[i+1]);
7509 SetRandomSecretKey(seed);
7512 if (LocaleCompare(
"size",option+1) == 0)
7516 if (image_info->size != (
char *) NULL)
7517 image_info->size=DestroyString(image_info->size);
7520 (void) CloneString(&image_info->size,argv[i+1]);
7523 if (LocaleCompare(
"stroke",option+1) == 0)
7526 (void) SetImageOption(image_info,option+1,
"none");
7528 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7531 if (LocaleCompare(
"strokewidth",option+1) == 0)
7534 (void) SetImageOption(image_info,option+1,
"0");
7536 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7539 if (LocaleCompare(
"style",option+1) == 0)
7542 (void) SetImageOption(image_info,option+1,
"none");
7544 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7547 if (LocaleCompare(
"synchronize",option+1) == 0)
7551 image_info->synchronize=MagickFalse;
7554 image_info->synchronize=MagickTrue;
7561 if (LocaleCompare(
"taint",option+1) == 0)
7565 (void) SetImageOption(image_info,option+1,
"false");
7568 (void) SetImageOption(image_info,option+1,
"true");
7571 if (LocaleCompare(
"texture",option+1) == 0)
7575 if (image_info->texture != (
char *) NULL)
7576 image_info->texture=DestroyString(image_info->texture);
7579 (void) CloneString(&image_info->texture,argv[i+1]);
7582 if (LocaleCompare(
"tile-offset",option+1) == 0)
7586 (void) SetImageOption(image_info,option+1,
"0");
7589 (void) SetImageOption(image_info,option+1,argv[i+1]);
7592 if (LocaleCompare(
"transparent-color",option+1) == 0)
7596 (void) QueryColorDatabase(
"none",&image_info->transparent_color, exception);
7597 (void) SetImageOption(image_info,option+1,
"none");
7600 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7602 (void) SetImageOption(image_info,option+1,argv[i+1]);
7605 if (LocaleCompare(
"type",option+1) == 0)
7609 image_info->type=UndefinedType;
7610 (void) SetImageOption(image_info,option+1,
"undefined");
7613 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7614 MagickFalse,argv[i+1]);
7615 (void) SetImageOption(image_info,option+1,argv[i+1]);
7622 if (LocaleCompare(
"undercolor",option+1) == 0)
7626 (void) DeleteImageOption(image_info,option+1);
7629 (void) SetImageOption(image_info,option+1,argv[i+1]);
7632 if (LocaleCompare(
"units",option+1) == 0)
7636 image_info->units=UndefinedResolution;
7637 (void) SetImageOption(image_info,option+1,
"undefined");
7640 image_info->units=(ResolutionType) ParseCommandOption(
7641 MagickResolutionOptions,MagickFalse,argv[i+1]);
7642 (void) SetImageOption(image_info,option+1,argv[i+1]);
7649 if (LocaleCompare(
"verbose",option+1) == 0)
7653 image_info->verbose=MagickFalse;
7656 image_info->verbose=MagickTrue;
7657 image_info->ping=MagickFalse;
7660 if (LocaleCompare(
"view",option+1) == 0)
7664 if (image_info->view != (
char *) NULL)
7665 image_info->view=DestroyString(image_info->view);
7668 (void) CloneString(&image_info->view,argv[i+1]);
7671 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
7675 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7676 (void) SetImageOption(image_info,option+1,
"undefined");
7679 image_info->virtual_pixel_method=(VirtualPixelMethod)
7680 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7682 (void) SetImageOption(image_info,option+1,argv[i+1]);
7689 if (LocaleCompare(
"weight",option+1) == 0)
7692 (void) SetImageOption(image_info,option+1,
"0");
7694 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7697 if (LocaleCompare(
"white-point",option+1) == 0)
7701 (void) SetImageOption(image_info,option+1,
"0.0");
7704 (void) SetImageOption(image_info,option+1,argv[i+1]);
7751 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7752 const int argc,
const char **argv,Image **images,ExceptionInfo *exception)
7779 assert(image_info != (ImageInfo *) NULL);
7780 assert(image_info->signature == MagickCoreSignature);
7781 assert(images != (Image **) NULL);
7782 assert((*images)->previous == (Image *) NULL);
7783 assert((*images)->signature == MagickCoreSignature);
7784 if (IsEventLogging() != MagickFalse)
7785 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
7786 (*images)->filename);
7787 if ((argc <= 0) || (*argv == (
char *) NULL))
7789 mogrify_info=CloneImageInfo(image_info);
7790 quantize_info=AcquireQuantizeInfo(mogrify_info);
7791 channel=mogrify_info->channel;
7793 for (i=0; i < (ssize_t) argc; i++)
7795 if (*images == (Image *) NULL)
7798 if (IsCommandOption(option) == MagickFalse)
7800 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7801 count=MagickMax(count,0L);
7802 if ((i+count) >= (ssize_t) argc)
7804 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
7805 switch (*(option+1))
7809 if (LocaleCompare(
"affinity",option+1) == 0)
7811 (void) SyncImagesSettings(mogrify_info,*images);
7814 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7815 InheritException(exception,&(*images)->exception);
7821 if (LocaleCompare(
"append",option+1) == 0)
7826 (void) SyncImagesSettings(mogrify_info,*images);
7827 append_image=AppendImages(*images,*option ==
'-' ? MagickTrue :
7828 MagickFalse,exception);
7829 if (append_image == (Image *) NULL)
7834 *images=DestroyImageList(*images);
7835 *images=append_image;
7838 if (LocaleCompare(
"average",option+1) == 0)
7846 (void) SyncImagesSettings(mogrify_info,*images);
7847 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7849 if (average_image == (Image *) NULL)
7854 *images=DestroyImageList(*images);
7855 *images=average_image;
7862 if (LocaleCompare(
"channel",option+1) == 0)
7866 channel=DefaultChannels;
7869 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7872 if (LocaleCompare(
"clut",option+1) == 0)
7878 (void) SyncImagesSettings(mogrify_info,*images);
7879 image=RemoveFirstImageFromList(images);
7880 clut_image=RemoveFirstImageFromList(images);
7881 if (clut_image == (Image *) NULL)
7883 (void) ThrowMagickException(exception,GetMagickModule(),
7884 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7885 image=DestroyImage(image);
7889 (void) ClutImageChannel(image,channel,clut_image);
7890 clut_image=DestroyImage(clut_image);
7891 InheritException(exception,&image->exception);
7892 *images=DestroyImageList(*images);
7896 if (LocaleCompare(
"coalesce",option+1) == 0)
7901 (void) SyncImagesSettings(mogrify_info,*images);
7902 coalesce_image=CoalesceImages(*images,exception);
7903 if (coalesce_image == (Image *) NULL)
7908 *images=DestroyImageList(*images);
7909 *images=coalesce_image;
7912 if (LocaleCompare(
"combine",option+1) == 0)
7917 (void) SyncImagesSettings(mogrify_info,*images);
7918 combine_image=CombineImages(*images,channel,exception);
7919 if (combine_image == (Image *) NULL)
7924 *images=DestroyImageList(*images);
7925 *images=combine_image;
7928 if (LocaleCompare(
"compare",option+1) == 0)
7945 (void) SyncImagesSettings(mogrify_info,*images);
7946 image=RemoveFirstImageFromList(images);
7947 reconstruct_image=RemoveFirstImageFromList(images);
7948 if (reconstruct_image == (Image *) NULL)
7950 (void) ThrowMagickException(exception,GetMagickModule(),
7951 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7952 image=DestroyImage(image);
7956 metric=UndefinedMetric;
7957 option=GetImageOption(image_info,
"metric");
7958 if (option != (
const char *) NULL)
7959 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7960 MagickFalse,option);
7961 difference_image=CompareImageChannels(image,reconstruct_image,
7962 channel,metric,&distortion,exception);
7963 if (difference_image == (Image *) NULL)
7965 reconstruct_image=DestroyImage(reconstruct_image);
7966 image=DestroyImage(image);
7967 if (*images != (Image *) NULL)
7968 *images=DestroyImageList(*images);
7969 *images=difference_image;
7972 if (LocaleCompare(
"complex",option+1) == 0)
7980 (void) SyncImageSettings(mogrify_info,*images);
7981 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7982 MagickFalse,argv[i+1]);
7983 complex_images=ComplexImages(*images,op,exception);
7984 if (complex_images == (Image *) NULL)
7989 *images=DestroyImageList(*images);
7990 *images=complex_images;
7993 if (LocaleCompare(
"composite",option+1) == 0)
8003 (void) SyncImagesSettings(mogrify_info,*images);
8004 image=RemoveFirstImageFromList(images);
8005 composite_image=RemoveFirstImageFromList(images);
8006 if (composite_image == (Image *) NULL)
8008 (void) ThrowMagickException(exception,GetMagickModule(),
8009 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8010 image=DestroyImage(image);
8014 (void) TransformImage(&composite_image,(
char *) NULL,
8015 composite_image->geometry);
8016 SetGeometry(composite_image,&geometry);
8017 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
8018 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8020 mask_image=RemoveFirstImageFromList(images);
8021 if (mask_image != (Image *) NULL)
8023 if ((image->compose == DisplaceCompositeOp) ||
8024 (image->compose == DistortCompositeOp))
8029 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8031 mask_image=DestroyImage(mask_image);
8038 if (image->mask != (Image *) NULL)
8039 image->mask=DestroyImage(image->mask);
8040 image->mask=mask_image;
8041 (void) NegateImage(image->mask,MagickFalse);
8044 (void) CompositeImageChannel(image,channel,image->compose,
8045 composite_image,geometry.x,geometry.y);
8046 if (mask_image != (Image *) NULL)
8048 image->mask=DestroyImage(image->mask);
8049 mask_image=image->mask;
8051 composite_image=DestroyImage(composite_image);
8052 InheritException(exception,&image->exception);
8053 *images=DestroyImageList(*images);
8057 if (LocaleCompare(
"copy",option+1) == 0)
8071 (void) SyncImageSettings(mogrify_info,*images);
8072 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8073 offset.x=geometry.x;
8074 offset.y=geometry.y;
8075 source_image=(*images);
8076 if (source_image->next != (Image *) NULL)
8077 source_image=source_image->next;
8078 (
void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8080 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8088 if (LocaleCompare(
"deconstruct",option+1) == 0)
8093 (void) SyncImagesSettings(mogrify_info,*images);
8094 deconstruct_image=DeconstructImages(*images,exception);
8095 if (deconstruct_image == (Image *) NULL)
8100 *images=DestroyImageList(*images);
8101 *images=deconstruct_image;
8104 if (LocaleCompare(
"delete",option+1) == 0)
8107 DeleteImages(images,
"-1",exception);
8109 DeleteImages(images,argv[i+1],exception);
8112 if (LocaleCompare(
"dither",option+1) == 0)
8116 quantize_info->dither=MagickFalse;
8119 quantize_info->dither=MagickTrue;
8120 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8121 MagickDitherOptions,MagickFalse,argv[i+1]);
8124 if (LocaleCompare(
"duplicate",option+1) == 0)
8130 duplicate_images=DuplicateImages(*images,1,
"-1",exception);
8139 number_duplicates=(size_t) StringToLong(argv[i+1]);
8140 p=strchr(argv[i+1],
',');
8141 if (p == (
const char *) NULL)
8142 duplicate_images=DuplicateImages(*images,number_duplicates,
8145 duplicate_images=DuplicateImages(*images,number_duplicates,
8148 AppendImageToList(images, duplicate_images);
8149 (void) SyncImagesSettings(mogrify_info,*images);
8156 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
8161 MagickEvaluateOperator
8164 (void) SyncImageSettings(mogrify_info,*images);
8165 op=(MagickEvaluateOperator) ParseCommandOption(
8166 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8167 evaluate_image=EvaluateImages(*images,op,exception);
8168 if (evaluate_image == (Image *) NULL)
8173 *images=DestroyImageList(*images);
8174 *images=evaluate_image;
8181 if (LocaleCompare(
"fft",option+1) == 0)
8189 (void) SyncImageSettings(mogrify_info,*images);
8190 fourier_image=ForwardFourierTransformImage(*images,*option ==
'-' ?
8191 MagickTrue : MagickFalse,exception);
8192 if (fourier_image == (Image *) NULL)
8194 *images=DestroyImageList(*images);
8195 *images=fourier_image;
8198 if (LocaleCompare(
"flatten",option+1) == 0)
8203 (void) SyncImagesSettings(mogrify_info,*images);
8204 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8205 if (flatten_image == (Image *) NULL)
8207 *images=DestroyImageList(*images);
8208 *images=flatten_image;
8211 if (LocaleCompare(
"fx",option+1) == 0)
8216 (void) SyncImagesSettings(mogrify_info,*images);
8217 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
8218 if (fx_image == (Image *) NULL)
8223 *images=DestroyImageList(*images);
8231 if (LocaleCompare(
"hald-clut",option+1) == 0)
8237 (void) SyncImagesSettings(mogrify_info,*images);
8238 image=RemoveFirstImageFromList(images);
8239 hald_image=RemoveFirstImageFromList(images);
8240 if (hald_image == (Image *) NULL)
8242 (void) ThrowMagickException(exception,GetMagickModule(),
8243 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8244 image=DestroyImage(image);
8248 (void) HaldClutImageChannel(image,channel,hald_image);
8249 hald_image=DestroyImage(hald_image);
8250 InheritException(exception,&image->exception);
8251 if (*images != (Image *) NULL)
8252 *images=DestroyImageList(*images);
8260 if (LocaleCompare(
"ift",option+1) == 0)
8270 (void) SyncImagesSettings(mogrify_info,*images);
8271 magnitude_image=RemoveFirstImageFromList(images);
8272 phase_image=RemoveFirstImageFromList(images);
8273 if (phase_image == (Image *) NULL)
8275 (void) ThrowMagickException(exception,GetMagickModule(),
8276 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8277 magnitude_image=DestroyImage(magnitude_image);
8281 fourier_image=InverseFourierTransformImage(magnitude_image,
8282 phase_image,*option ==
'-' ? MagickTrue : MagickFalse,exception);
8283 magnitude_image=DestroyImage(magnitude_image);
8284 phase_image=DestroyImage(phase_image);
8285 if (fourier_image == (Image *) NULL)
8287 if (*images != (Image *) NULL)
8288 *images=DestroyImageList(*images);
8289 *images=fourier_image;
8292 if (LocaleCompare(
"insert",option+1) == 0)
8300 index=(ssize_t) StringToLong(argv[i+1]);
8301 p=RemoveLastImageFromList(images);
8302 if (p == (Image *) NULL)
8304 (void) ThrowMagickException(exception,GetMagickModule(),
8305 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8311 PrependImageToList(images,q);
8313 if (index == (ssize_t) GetImageListLength(*images))
8314 AppendImageToList(images,q);
8317 q=GetImageFromList(*images,index-1);
8318 if (q == (Image *) NULL)
8321 (void) ThrowMagickException(exception,GetMagickModule(),
8322 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8326 InsertImageInList(&q,p);
8328 *images=GetFirstImageInList(q);
8335 if (LocaleCompare(
"layers",option+1) == 0)
8343 (void) SyncImagesSettings(mogrify_info,*images);
8344 layers=(Image *) NULL;
8345 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
8346 MagickFalse,argv[i+1]);
8351 layers=CoalesceImages(*images,exception);
8354 case CompareAnyLayer:
8355 case CompareClearLayer:
8356 case CompareOverlayLayer:
8359 layers=CompareImageLayers(*images,method,exception);
8365 case TrimBoundsLayer:
8367 layers=MergeImageLayers(*images,method,exception);
8372 layers=DisposeImages(*images,exception);
8375 case OptimizeImageLayer:
8377 layers=OptimizeImageLayers(*images,exception);
8380 case OptimizePlusLayer:
8382 layers=OptimizePlusImageLayers(*images,exception);
8385 case OptimizeTransLayer:
8387 OptimizeImageTransparency(*images,exception);
8390 case RemoveDupsLayer:
8392 RemoveDuplicateLayers(images,exception);
8395 case RemoveZeroLayer:
8397 RemoveZeroDelayLayers(images,exception);
8405 layers=CoalesceImages(*images,exception);
8406 if (layers == (Image *) NULL)
8411 InheritException(exception,&layers->exception);
8412 *images=DestroyImageList(*images);
8414 layers=OptimizeImageLayers(*images,exception);
8415 if (layers == (Image *) NULL)
8420 InheritException(exception,&layers->exception);
8421 *images=DestroyImageList(*images);
8423 layers=(Image *) NULL;
8424 OptimizeImageTransparency(*images,exception);
8425 InheritException(exception,&(*images)->exception);
8426 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8429 case CompositeLayer:
8444 while (source != (Image *) NULL)
8446 source=GetNextImageInList(source);
8447 if ((source != (Image *) NULL) &&
8448 (LocaleCompare(source->magick,
"NULL") == 0))
8451 if (source != (Image *) NULL)
8453 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8454 (GetNextImageInList(source) == (Image *) NULL))
8455 source=(Image *) NULL;
8461 source=SplitImageList(source->previous);
8462 DeleteImageFromList(&source);
8465 if (source == (Image *) NULL)
8467 (void) ThrowMagickException(exception,GetMagickModule(),
8468 OptionError,
"MissingNullSeparator",
"layers Composite");
8475 SetGeometry(*images,&geometry);
8476 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8477 geometry.width=source->page.width != 0 ?
8478 source->page.width : source->columns;
8479 geometry.height=source->page.height != 0 ?
8480 source->page.height : source->rows;
8481 GravityAdjustGeometry((*images)->page.width != 0 ?
8482 (*images)->page.width : (*images)->columns,
8483 (*images)->page.height != 0 ? (*images)->page.height :
8484 (*images)->rows,(*images)->gravity,&geometry);
8485 compose=OverCompositeOp;
8486 option=GetImageOption(mogrify_info,
"compose");
8487 if (option != (
const char *) NULL)
8488 compose=(CompositeOperator) ParseCommandOption(
8489 MagickComposeOptions,MagickFalse,option);
8490 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8492 source=DestroyImageList(source);
8496 if (layers == (Image *) NULL)
8498 InheritException(exception,&layers->exception);
8499 *images=DestroyImageList(*images);
8507 if (LocaleCompare(
"map",option+1) == 0)
8509 (void) SyncImagesSettings(mogrify_info,*images);
8512 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8513 InheritException(exception,&(*images)->exception);
8519 if (LocaleCompare(
"maximum",option+1) == 0)
8527 (void) SyncImagesSettings(mogrify_info,*images);
8528 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8529 if (maximum_image == (Image *) NULL)
8534 *images=DestroyImageList(*images);
8535 *images=maximum_image;
8538 if (LocaleCompare(
"minimum",option+1) == 0)
8546 (void) SyncImagesSettings(mogrify_info,*images);
8547 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8548 if (minimum_image == (Image *) NULL)
8553 *images=DestroyImageList(*images);
8554 *images=minimum_image;
8557 if (LocaleCompare(
"morph",option+1) == 0)
8562 (void) SyncImagesSettings(mogrify_info,*images);
8563 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8565 if (morph_image == (Image *) NULL)
8570 *images=DestroyImageList(*images);
8571 *images=morph_image;
8574 if (LocaleCompare(
"mosaic",option+1) == 0)
8579 (void) SyncImagesSettings(mogrify_info,*images);
8580 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8581 if (mosaic_image == (Image *) NULL)
8586 *images=DestroyImageList(*images);
8587 *images=mosaic_image;
8594 if (LocaleCompare(
"poly",option+1) == 0)
8598 token[MaxTextExtent];
8618 (void) SyncImageSettings(mogrify_info,*images);
8619 args=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8620 InheritException(exception,&(*images)->exception);
8621 if (args == (
char *) NULL)
8624 for (x=0; *p !=
'\0'; x++)
8626 (void) GetNextToken(p,&p,MaxTextExtent,token);
8628 (void) GetNextToken(p,&p,MaxTextExtent,token);
8630 number_arguments=(size_t) x;
8631 arguments=(
double *) AcquireQuantumMemory(number_arguments,
8632 sizeof(*arguments));
8633 if (arguments == (
double *) NULL)
8634 ThrowWandFatalException(ResourceLimitFatalError,
8635 "MemoryAllocationFailed",(*images)->filename);
8636 (void) memset(arguments,0,number_arguments*
8637 sizeof(*arguments));
8639 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
8641 (void) GetNextToken(p,&p,MaxTextExtent,token);
8643 (void) GetNextToken(p,&p,MaxTextExtent,token);
8644 arguments[x]=StringToDouble(token,(
char **) NULL);
8646 args=DestroyString(args);
8647 polynomial_image=PolynomialImageChannel(*images,channel,
8648 number_arguments >> 1,arguments,exception);
8649 arguments=(
double *) RelinquishMagickMemory(arguments);
8650 if (polynomial_image == (Image *) NULL)
8655 *images=DestroyImageList(*images);
8656 *images=polynomial_image;
8659 if (LocaleCompare(
"print",option+1) == 0)
8664 (void) SyncImagesSettings(mogrify_info,*images);
8665 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8666 if (
string == (
char *) NULL)
8668 InheritException(exception,&(*images)->exception);
8669 (void) FormatLocaleFile(stdout,
"%s",
string);
8670 string=DestroyString(
string);
8672 if (LocaleCompare(
"process",option+1) == 0)
8681 (void) SyncImagesSettings(mogrify_info,*images);
8682 arguments=StringToArgv(argv[i+1],&number_arguments);
8683 if (arguments == (
char **) NULL)
8685 if ((argc > 1) && (strchr(arguments[1],
'=') != (
char *) NULL))
8708 length=strlen(argv[i+1]);
8709 token=(
char *) NULL;
8710 if (~length >= (MaxTextExtent-1))
8711 token=(
char *) AcquireQuantumMemory(length+MaxTextExtent,
8713 if (token == (
char *) NULL)
8716 arguments=argv[i+1];
8717 token_info=AcquireTokenInfo();
8718 status=Tokenizer(token_info,0,token,length,arguments,
"",
"=",
8719 "\"",
'\0',&breaker,&next,"e);
8720 token_info=DestroyTokenInfo(token_info);
8726 argv=(&(arguments[next]));
8727 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8730 token=DestroyString(token);
8733 (void) SubstituteString(&arguments[1],
"-",
"");
8734 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8735 number_arguments-2,(
const char **) arguments+2,exception);
8736 for (j=0; j < number_arguments; j++)
8737 arguments[j]=DestroyString(arguments[j]);
8738 arguments=(
char **) RelinquishMagickMemory(arguments);
8745 if (LocaleCompare(
"reverse",option+1) == 0)
8747 ReverseImageList(images);
8748 InheritException(exception,&(*images)->exception);
8755 if (LocaleCompare(
"smush",option+1) == 0)
8763 (void) SyncImagesSettings(mogrify_info,*images);
8764 offset=(ssize_t) StringToLong(argv[i+1]);
8765 smush_image=SmushImages(*images,*option ==
'-' ? MagickTrue :
8766 MagickFalse,offset,exception);
8767 if (smush_image == (Image *) NULL)
8772 *images=DestroyImageList(*images);
8773 *images=smush_image;
8776 if (LocaleCompare(
"swap",option+1) == 0)
8798 flags=ParseGeometry(argv[i+1],&geometry_info);
8799 index=(ssize_t) geometry_info.rho;
8800 if ((flags & SigmaValue) != 0)
8801 swap_index=(ssize_t) geometry_info.sigma;
8803 p=GetImageFromList(*images,index);
8804 q=GetImageFromList(*images,swap_index);
8805 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8807 (void) ThrowMagickException(exception,GetMagickModule(),
8808 OptionError,
"NoSuchImage",
"`%s'",(*images)->filename);
8814 u=CloneImage(p,0,0,MagickTrue,exception);
8815 if (u == (Image *) NULL)
8817 v=CloneImage(q,0,0,MagickTrue,exception);
8818 if (v == (Image *) NULL)
8823 ReplaceImageInList(&p,v);
8824 ReplaceImageInList(&q,u);
8825 *images=GetFirstImageInList(q);
8832 if (LocaleCompare(
"write",option+1) == 0)
8843 (void) SyncImagesSettings(mogrify_info,*images);
8844 (void) FormatLocaleString(key,MaxTextExtent,
"cache:%s",argv[i+1]);
8845 (void) DeleteImageRegistry(key);
8846 write_images=CloneImageList(*images,exception);
8847 write_info=CloneImageInfo(mogrify_info);
8848 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8849 write_info=DestroyImageInfo(write_info);
8850 write_images=DestroyImageList(write_images);
8860 quantize_info=DestroyQuantizeInfo(quantize_info);
8861 mogrify_info=DestroyImageInfo(mogrify_info);
8862 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8863 return(status != 0 ? MagickTrue : MagickFalse);
8903 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8904 const MagickBooleanType post,
const int argc,
const char **argv,
8905 Image **images,ExceptionInfo *exception)
8907 #define MogrifyImageTag "Mogrify/Image"
8921 assert(image_info != (ImageInfo *) NULL);
8922 assert(image_info->signature == MagickCoreSignature);
8923 if (images == (Image **) NULL)
8924 return(MogrifyImage(image_info,argc,argv,images,exception));
8925 assert((*images)->previous == (Image *) NULL);
8926 assert((*images)->signature == MagickCoreSignature);
8927 if (IsEventLogging() != MagickFalse)
8928 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
8929 (*images)->filename);
8930 if ((argc <= 0) || (*argv == (
char *) NULL))
8932 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8936 (void) FormatLocaleFile(stderr,
"mogrify start %s %d (%s)\n",argv[0],argc,
8942 if (post == MagickFalse)
8943 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8948 n=GetImageListLength(*images);
8952 (void) FormatLocaleFile(stderr,
"mogrify %ld of %ld\n",(
long)
8953 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8955 status&=MogrifyImage(image_info,argc,argv,images,exception);
8956 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8957 if (proceed == MagickFalse)
8959 if ((*images)->next == (Image *) NULL)
8961 *images=(*images)->next;
8964 assert(*images != (Image *) NULL);
8966 (void) FormatLocaleFile(stderr,
"mogrify end %ld of %ld\n",(
long)
8967 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8972 *images=GetFirstImageInList(*images);
8973 if (post != MagickFalse)
8974 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8975 return(status != 0 ? MagickTrue : MagickFalse);