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 (void) CopyMagickString(tag,text == (
const char *) NULL ?
"null" : text,
404 if (p != (
char *) NULL)
406 (void) FormatLocaleString(message,MaxTextExtent,
"Monitor/%s",tag);
407 locale_message=GetLocaleMessage(message);
408 if (locale_message == message)
410 if (p == (
char *) NULL)
411 (void) FormatLocaleFile(stderr,
"%s: %ld of %lu, %02ld%% complete\r",
412 locale_message,(
long) offset,(
unsigned long) extent,(
long)
413 (100.0*offset*PerceptibleReciprocal(extent-1.0)));
415 (
void) FormatLocaleFile(stderr,
"%s[%s]: %ld of %lu, %02ld%% complete\r",
416 locale_message,p+1,(
long) offset,(
unsigned long) extent,(
long)
417 (100.0*offset*PerceptibleReciprocal(extent-1.0)));
418 if (offset == (MagickOffsetType) (extent-1))
419 (void) FormatLocaleFile(stderr,
"\n");
420 (void) fflush(stderr);
424 static Image *SparseColorOption(
const Image *image,
const ChannelType channel,
425 const SparseColorMethod method,
const char *arguments,
426 const MagickBooleanType color_from_image,ExceptionInfo *exception)
432 token[MaxTextExtent];
463 assert(image != (Image *) NULL);
464 assert(image->signature == MagickCoreSignature);
465 assert(exception != (ExceptionInfo *) NULL);
466 assert(exception->signature == MagickCoreSignature);
467 if (IsEventLogging() != MagickFalse)
468 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
473 if (image->colorspace != CMYKColorspace)
474 channels=(ChannelType) (channels & ~IndexChannel);
475 if (image->matte == MagickFalse)
476 channels=(ChannelType) (channels & ~OpacityChannel);
478 if ((channels & RedChannel) != 0)
480 if ((channels & GreenChannel) != 0)
482 if ((channels & BlueChannel) != 0)
484 if ((channels & IndexChannel) != 0)
486 if ((channels & OpacityChannel) != 0)
496 (void) GetNextToken(p,&p,MaxTextExtent,token);
497 if ( *token ==
',' )
continue;
498 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
499 if ( color_from_image ) {
500 (void) ThrowMagickException(exception,GetMagickModule(),
501 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
502 "Color arg given, when colors are coming from image");
503 return( (Image *) NULL);
512 if ( color_from_image ) {
514 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
515 number_arguments=(x/2)*(2+number_colors);
519 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
523 (void) ThrowMagickException(exception,GetMagickModule(),
524 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
525 "Invalid number of Arguments");
526 return( (Image *) NULL);
530 sparse_arguments=(
double *) AcquireQuantumMemory(number_arguments,
531 sizeof(*sparse_arguments));
532 if (sparse_arguments == (
double *) NULL) {
533 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
534 " MemoryAllocationFailed\n""%s",
"SparseColorOption");
535 return( (Image *) NULL);
537 (void) memset(sparse_arguments,0,number_arguments*
538 sizeof(*sparse_arguments));
541 while( *p !=
'\0' && x < number_arguments ) {
544 while ( *token ==
',' )
545 (void) GetNextToken(p,&p,MaxTextExtent,token);
546 if ( *token ==
'\0' )
break;
547 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
548 (void) ThrowMagickException(exception,GetMagickModule(),
549 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
550 "Color found, instead of X-coord");
554 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
556 *token=
',';
while ( *token ==
',' ) GetNextToken(p,&p,MaxTextExtent,token);
557 if ( *token ==
'\0' )
break;
558 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
559 (void) ThrowMagickException(exception,GetMagickModule(),
560 OptionError,
"InvalidArgument",
"`%s': %s",
"sparse-color",
561 "Color found, instead of Y-coord");
565 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
568 if ( (color_from_image ) {
577 while ( *token ==
',' )
578 (
void) GetNextToken(p,&p,MaxTextExtent,token);
579 if ( *token ==
'\0' )
break;
580 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
582 (void) QueryMagickColor(token,&color,exception);
583 if ( channels & RedChannel )
584 sparse_arguments[x++] = QuantumScale*color.red;
585 if ( channels & GreenChannel )
586 sparse_arguments[x++] = QuantumScale*color.green;
587 if ( channels & BlueChannel )
588 sparse_arguments[x++] = QuantumScale*color.blue;
589 if ( channels & IndexChannel )
590 sparse_arguments[x++] = QuantumScale*color.index;
591 if ( channels & OpacityChannel )
592 sparse_arguments[x++] = QuantumScale*color.opacity;
597 if ( channels & RedChannel ) {
598 while ( *token ==
',' )
599 (void) GetNextToken(p,&p,MaxTextExtent,token);
600 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
602 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
605 if ( channels & GreenChannel ) {
606 while ( *token ==
',' )
607 (void) GetNextToken(p,&p,MaxTextExtent,token);
608 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
610 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
613 if ( channels & BlueChannel ) {
614 while ( *token ==
',' )
615 (void) GetNextToken(p,&p,MaxTextExtent,token);
616 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
618 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
621 if ( channels & IndexChannel ) {
622 while ( *token ==
',' )
623 (void) GetNextToken(p,&p,MaxTextExtent,token);
624 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
626 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
629 if ( channels & OpacityChannel ) {
630 while ( *token ==
',' )
631 (void) GetNextToken(p,&p,MaxTextExtent,token);
632 if ( *token ==
'\0' || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
634 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
640 if ( number_arguments != x && !error ) {
641 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
642 " InvalidArgument",
"`%s': %s",
"sparse-color",
"Argument Parsing Error");
643 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
644 return( (Image *) NULL);
647 return( (Image *) NULL);
650 sparse_image=SparseColorImage(image,channels,method,number_arguments,
651 sparse_arguments,exception);
652 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
653 return( sparse_image );
656 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,
const int argc,
657 const char **argv,Image **image,ExceptionInfo *exception)
700 assert(image_info != (
const ImageInfo *) NULL);
701 assert(image_info->signature == MagickCoreSignature);
702 assert(image != (Image **) NULL);
703 assert((*image)->signature == MagickCoreSignature);
704 if (IsEventLogging() != MagickFalse)
705 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
708 mogrify_info=CloneImageInfo(image_info);
709 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
710 quantize_info=AcquireQuantizeInfo(mogrify_info);
711 SetGeometryInfo(&geometry_info);
712 GetMagickPixelPacket(*image,&fill);
713 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
715 channel=mogrify_info->channel;
716 format=GetImageOption(mogrify_info,
"format");
717 SetGeometry(*image,®ion_geometry);
718 region_image=NewImageList();
722 for (i=0; i < (ssize_t) argc; i++)
731 if (IsCommandOption(option) == MagickFalse)
733 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
735 if ((i+count) >= (ssize_t) argc)
737 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
738 mogrify_image=(Image *) NULL;
743 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
748 (void) SyncImageSettings(mogrify_info,*image);
749 flags=ParseGeometry(argv[i+1],&geometry_info);
750 if ((flags & SigmaValue) == 0)
751 geometry_info.sigma=1.0;
752 mogrify_image=AdaptiveBlurImageChannel(*image,channel,
753 geometry_info.rho,geometry_info.sigma,exception);
756 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
761 (void) SyncImageSettings(mogrify_info,*image);
762 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
763 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
764 geometry.height,exception);
767 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
772 (void) SyncImageSettings(mogrify_info,*image);
773 flags=ParseGeometry(argv[i+1],&geometry_info);
774 if ((flags & SigmaValue) == 0)
775 geometry_info.sigma=1.0;
776 mogrify_image=AdaptiveSharpenImageChannel(*image,channel,
777 geometry_info.rho,geometry_info.sigma,exception);
780 if (LocaleCompare(
"affine",option+1) == 0)
787 GetAffineMatrix(&draw_info->affine);
790 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
793 if (LocaleCompare(
"alpha",option+1) == 0)
798 (void) SyncImageSettings(mogrify_info,*image);
799 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
800 MagickFalse,argv[i+1]);
801 (void) SetImageAlphaChannel(*image,alpha_type);
802 InheritException(exception,&(*image)->exception);
805 if (LocaleCompare(
"annotate",option+1) == 0)
809 geometry[MaxTextExtent];
814 (void) SyncImageSettings(mogrify_info,*image);
815 SetGeometryInfo(&geometry_info);
816 flags=ParseGeometry(argv[i+1],&geometry_info);
817 if ((flags & SigmaValue) == 0)
818 geometry_info.sigma=geometry_info.rho;
819 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
820 InheritException(exception,&(*image)->exception);
821 if (text == (
char *) NULL)
823 (void) CloneString(&draw_info->text,text);
824 text=DestroyString(text);
825 (void) FormatLocaleString(geometry,MaxTextExtent,
"%+f%+f",
826 geometry_info.xi,geometry_info.psi);
827 (void) CloneString(&draw_info->geometry,geometry);
828 draw_info->affine.sx=cos(DegreesToRadians(
829 fmod(geometry_info.rho,360.0)));
830 draw_info->affine.rx=sin(DegreesToRadians(
831 fmod(geometry_info.rho,360.0)));
832 draw_info->affine.ry=(-sin(DegreesToRadians(
833 fmod(geometry_info.sigma,360.0))));
834 draw_info->affine.sy=cos(DegreesToRadians(
835 fmod(geometry_info.sigma,360.0)));
836 (void) AnnotateImage(*image,draw_info);
837 InheritException(exception,&(*image)->exception);
840 if (LocaleCompare(
"antialias",option+1) == 0)
842 draw_info->stroke_antialias=(*option ==
'-') ? MagickTrue :
844 draw_info->text_antialias=(*option ==
'-') ? MagickTrue :
848 if (LocaleCompare(
"auto-gamma",option+1) == 0)
853 (void) SyncImageSettings(mogrify_info,*image);
854 (void) AutoGammaImageChannel(*image,channel);
857 if (LocaleCompare(
"auto-level",option+1) == 0)
862 (void) SyncImageSettings(mogrify_info,*image);
863 (void) AutoLevelImageChannel(*image,channel);
866 if (LocaleCompare(
"auto-orient",option+1) == 0)
868 (void) SyncImageSettings(mogrify_info,*image);
869 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
877 if (LocaleCompare(
"black-threshold",option+1) == 0)
882 (void) SyncImageSettings(mogrify_info,*image);
883 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
885 InheritException(exception,&(*image)->exception);
888 if (LocaleCompare(
"blue-shift",option+1) == 0)
893 (void) SyncImageSettings(mogrify_info,*image);
894 geometry_info.rho=1.5;
896 flags=ParseGeometry(argv[i+1],&geometry_info);
897 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
900 if (LocaleCompare(
"blur",option+1) == 0)
905 (void) SyncImageSettings(mogrify_info,*image);
906 flags=ParseGeometry(argv[i+1],&geometry_info);
907 if ((flags & SigmaValue) == 0)
908 geometry_info.sigma=1.0;
909 mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho,
910 geometry_info.sigma,exception);
913 if (LocaleCompare(
"border",option+1) == 0)
918 (void) SyncImageSettings(mogrify_info,*image);
919 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
920 mogrify_image=BorderImage(*image,&geometry,exception);
923 if (LocaleCompare(
"bordercolor",option+1) == 0)
927 (void) QueryColorDatabase(MogrifyBorderColor,
928 &draw_info->border_color,exception);
931 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
935 if (LocaleCompare(
"box",option+1) == 0)
937 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
941 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
956 (void) SyncImageSettings(mogrify_info,*image);
957 flags=ParseGeometry(argv[i+1],&geometry_info);
958 brightness=geometry_info.rho;
960 if ((flags & SigmaValue) != 0)
961 contrast=geometry_info.sigma;
962 (void) BrightnessContrastImageChannel(*image,channel,brightness,
964 InheritException(exception,&(*image)->exception);
971 if (LocaleCompare(
"canny",option+1) == 0)
976 (void) SyncImageSettings(mogrify_info,*image);
977 flags=ParseGeometry(argv[i+1],&geometry_info);
978 if ((flags & SigmaValue) == 0)
979 geometry_info.sigma=1.0;
980 if ((flags & XiValue) == 0)
981 geometry_info.xi=0.10;
982 if ((flags & PsiValue) == 0)
983 geometry_info.psi=0.30;
984 if ((flags & PercentValue) != 0)
986 geometry_info.xi/=100.0;
987 geometry_info.psi/=100.0;
989 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
990 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
993 if (LocaleCompare(
"cdl",option+1) == 0)
996 *color_correction_collection;
1001 (void) SyncImageSettings(mogrify_info,*image);
1002 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
1003 if (color_correction_collection == (
char *) NULL)
1005 (void) ColorDecisionListImage(*image,color_correction_collection);
1006 InheritException(exception,&(*image)->exception);
1009 if (LocaleCompare(
"channel",option+1) == 0)
1012 channel=DefaultChannels;
1014 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1017 if (LocaleCompare(
"charcoal",option+1) == 0)
1022 (void) SyncImageSettings(mogrify_info,*image);
1023 flags=ParseGeometry(argv[i+1],&geometry_info);
1024 if ((flags & SigmaValue) == 0)
1025 geometry_info.sigma=1.0;
1026 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1027 geometry_info.sigma,exception);
1030 if (LocaleCompare(
"chop",option+1) == 0)
1035 (void) SyncImageSettings(mogrify_info,*image);
1036 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1037 mogrify_image=ChopImage(*image,&geometry,exception);
1040 if (LocaleCompare(
"clamp",option+1) == 0)
1045 (void) SyncImageSettings(mogrify_info,*image);
1046 (void) ClampImageChannel(*image,channel);
1047 InheritException(exception,&(*image)->exception);
1050 if (LocaleCompare(
"clip",option+1) == 0)
1052 (void) SyncImageSettings(mogrify_info,*image);
1055 (void) SetImageClipMask(*image,(Image *) NULL);
1056 InheritException(exception,&(*image)->exception);
1059 (void) ClipImage(*image);
1060 InheritException(exception,&(*image)->exception);
1063 if (LocaleCompare(
"clip-mask",option+1) == 0)
1080 (void) SyncImageSettings(mogrify_info,*image);
1086 (void) SetImageMask(*image,(Image *) NULL);
1087 InheritException(exception,&(*image)->exception);
1094 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1095 if (mask_image == (Image *) NULL)
1097 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1098 return(MagickFalse);
1099 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1100 for (y=0; y < (ssize_t) mask_image->rows; y++)
1102 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1104 if (q == (PixelPacket *) NULL)
1106 for (x=0; x < (ssize_t) mask_image->columns; x++)
1108 if (mask_image->matte == MagickFalse)
1109 SetPixelOpacity(q,ClampToQuantum(GetPixelIntensity(mask_image,
1111 SetPixelRed(q,GetPixelOpacity(q));
1112 SetPixelGreen(q,GetPixelOpacity(q));
1113 SetPixelBlue(q,GetPixelOpacity(q));
1116 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1119 mask_view=DestroyCacheView(mask_view);
1120 mask_image->matte=MagickTrue;
1121 (void) SetImageClipMask(*image,mask_image);
1122 mask_image=DestroyImage(mask_image);
1123 InheritException(exception,&(*image)->exception);
1126 if (LocaleCompare(
"clip-path",option+1) == 0)
1128 (void) SyncImageSettings(mogrify_info,*image);
1129 (void) ClipImagePath(*image,argv[i+1],*option ==
'-' ? MagickTrue :
1131 InheritException(exception,&(*image)->exception);
1134 if (LocaleCompare(
"colorize",option+1) == 0)
1139 (void) SyncImageSettings(mogrify_info,*image);
1140 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1144 if (LocaleCompare(
"color-matrix",option+1) == 0)
1149 (void) SyncImageSettings(mogrify_info,*image);
1150 kernel=AcquireKernelInfo(argv[i+1]);
1151 if (kernel == (KernelInfo *) NULL)
1153 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1154 kernel=DestroyKernelInfo(kernel);
1157 if (LocaleCompare(
"colors",option+1) == 0)
1162 (void) SyncImageSettings(mogrify_info,*image);
1163 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1164 if (quantize_info->number_colors == 0)
1166 if (((*image)->storage_class == DirectClass) ||
1167 (*image)->colors > quantize_info->number_colors)
1168 (void) QuantizeImage(quantize_info,*image);
1170 (
void) CompressImageColormap(*image);
1171 InheritException(exception,&(*image)->exception);
1174 if (LocaleCompare(
"colorspace",option+1) == 0)
1179 (void) SyncImageSettings(mogrify_info,*image);
1182 (void) TransformImageColorspace(*image,sRGBColorspace);
1183 InheritException(exception,&(*image)->exception);
1186 colorspace=(ColorspaceType) ParseCommandOption(
1187 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1188 (void) TransformImageColorspace(*image,colorspace);
1189 InheritException(exception,&(*image)->exception);
1192 if (LocaleCompare(
"connected-components",option+1) == 0)
1194 (void) SyncImageSettings(mogrify_info,*image);
1195 mogrify_image=ConnectedComponentsImage(*image,
1196 (
size_t) StringToInteger(argv[i+1]),exception);
1199 if (LocaleCompare(
"contrast",option+1) == 0)
1201 (void) SyncImageSettings(mogrify_info,*image);
1202 (void) ContrastImage(*image,(*option ==
'-') ? MagickTrue :
1204 InheritException(exception,&(*image)->exception);
1207 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
1219 (void) SyncImageSettings(mogrify_info,*image);
1220 flags=ParseGeometry(argv[i+1],&geometry_info);
1221 black_point=geometry_info.rho;
1222 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1224 if ((flags & PercentValue) != 0)
1226 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1227 white_point*=(
double) (*image)->columns*(*image)->rows/100.0;
1229 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1231 (
void) ContrastStretchImageChannel(*image,channel,black_point,
1233 InheritException(exception,&(*image)->exception);
1236 if (LocaleCompare(
"convolve",option+1) == 0)
1250 (void) SyncImageSettings(mogrify_info,*image);
1251 kernel_info=AcquireKernelInfo(argv[i+1]);
1252 if (kernel_info == (KernelInfo *) NULL)
1254 extent=kernel_info->width*kernel_info->height;
1256 for (j=0; j < (ssize_t) extent; j++)
1257 gamma+=kernel_info->values[j];
1258 gamma=1.0/(fabs((
double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1259 for (j=0; j < (ssize_t) extent; j++)
1260 kernel_info->values[j]*=gamma;
1261 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1262 kernel_info,exception);
1263 kernel_info=DestroyKernelInfo(kernel_info);
1266 if (LocaleCompare(
"crop",option+1) == 0)
1271 (void) SyncImageSettings(mogrify_info,*image);
1273 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1274 if (((geometry.width != 0) || (geometry.height != 0)) &&
1275 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1279 mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
1280 mogrify_image->next = mogrify_image->previous = (Image *) NULL;
1281 (void) TransformImage(&mogrify_image,argv[i+1],(
char *) NULL);
1282 InheritException(exception,&mogrify_image->exception);
1284 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1288 if (LocaleCompare(
"cycle",option+1) == 0)
1293 (void) SyncImageSettings(mogrify_info,*image);
1294 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]));
1295 InheritException(exception,&(*image)->exception);
1302 if (LocaleCompare(
"decipher",option+1) == 0)
1310 (void) SyncImageSettings(mogrify_info,*image);
1311 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1312 if (passkey != (StringInfo *) NULL)
1314 (void) PasskeyDecipherImage(*image,passkey,exception);
1315 passkey=DestroyStringInfo(passkey);
1319 if (LocaleCompare(
"density",option+1) == 0)
1324 (void) CloneString(&draw_info->density,argv[i+1]);
1327 if (LocaleCompare(
"depth",option+1) == 0)
1329 (void) SyncImageSettings(mogrify_info,*image);
1332 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1335 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1338 if (LocaleCompare(
"deskew",option+1) == 0)
1346 (void) SyncImageSettings(mogrify_info,*image);
1348 threshold=40.0*QuantumRange/100.0;
1350 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
1352 mogrify_image=DeskewImage(*image,threshold,exception);
1355 if (LocaleCompare(
"despeckle",option+1) == 0)
1360 (void) SyncImageSettings(mogrify_info,*image);
1361 mogrify_image=DespeckleImage(*image,exception);
1364 if (LocaleCompare(
"display",option+1) == 0)
1366 (void) CloneString(&draw_info->server_name,argv[i+1]);
1369 if (LocaleCompare(
"distort",option+1) == 0)
1373 token[MaxTextExtent];
1393 (void) SyncImageSettings(mogrify_info,*image);
1394 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1395 MagickFalse,argv[i+1]);
1396 if (method == ResizeDistortion)
1404 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1406 resize_args[0]=(double) geometry.width;
1407 resize_args[1]=(
double) geometry.height;
1408 mogrify_image=DistortImage(*image,method,(
size_t) 2,
1409 resize_args,MagickTrue,exception);
1412 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1413 InheritException(exception,&(*image)->exception);
1414 if (args == (
char *) NULL)
1417 for (x=0; *p !=
'\0'; x++)
1419 (void) GetNextToken(p,&p,MaxTextExtent,token);
1421 (void) GetNextToken(p,&p,MaxTextExtent,token);
1423 number_arguments=(size_t) x;
1424 arguments=(
double *) AcquireQuantumMemory(number_arguments,
1425 sizeof(*arguments));
1426 if (arguments == (
double *) NULL)
1427 ThrowWandFatalException(ResourceLimitFatalError,
1428 "MemoryAllocationFailed",(*image)->filename);
1429 (void) memset(arguments,0,number_arguments*
sizeof(*arguments));
1431 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
1433 (void) GetNextToken(p,&p,MaxTextExtent,token);
1435 (void) GetNextToken(p,&p,MaxTextExtent,token);
1436 arguments[x]=StringToDouble(token,(
char **) NULL);
1438 args=DestroyString(args);
1439 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1440 (*option ==
'+') ? MagickTrue : MagickFalse,exception);
1441 arguments=(
double *) RelinquishMagickMemory(arguments);
1444 if (LocaleCompare(
"dither",option+1) == 0)
1448 quantize_info->dither=MagickFalse;
1451 quantize_info->dither=MagickTrue;
1452 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1453 MagickDitherOptions,MagickFalse,argv[i+1]);
1454 if (quantize_info->dither_method == NoDitherMethod)
1455 quantize_info->dither=MagickFalse;
1458 if (LocaleCompare(
"draw",option+1) == 0)
1463 (void) SyncImageSettings(mogrify_info,*image);
1464 (void) CloneString(&draw_info->primitive,argv[i+1]);
1465 (void) DrawImage(*image,draw_info);
1466 InheritException(exception,&(*image)->exception);
1473 if (LocaleCompare(
"edge",option+1) == 0)
1478 (void) SyncImageSettings(mogrify_info,*image);
1479 flags=ParseGeometry(argv[i+1],&geometry_info);
1480 if ((flags & SigmaValue) == 0)
1481 geometry_info.sigma=1.0;
1482 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1485 if (LocaleCompare(
"emboss",option+1) == 0)
1490 (void) SyncImageSettings(mogrify_info,*image);
1491 flags=ParseGeometry(argv[i+1],&geometry_info);
1492 if ((flags & SigmaValue) == 0)
1493 geometry_info.sigma=1.0;
1494 mogrify_image=EmbossImage(*image,geometry_info.rho,
1495 geometry_info.sigma,exception);
1498 if (LocaleCompare(
"encipher",option+1) == 0)
1506 (void) SyncImageSettings(mogrify_info,*image);
1507 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1508 if (passkey != (StringInfo *) NULL)
1510 (void) PasskeyEncipherImage(*image,passkey,exception);
1511 passkey=DestroyStringInfo(passkey);
1515 if (LocaleCompare(
"encoding",option+1) == 0)
1517 (void) CloneString(&draw_info->encoding,argv[i+1]);
1520 if (LocaleCompare(
"enhance",option+1) == 0)
1525 (void) SyncImageSettings(mogrify_info,*image);
1526 mogrify_image=EnhanceImage(*image,exception);
1529 if (LocaleCompare(
"equalize",option+1) == 0)
1534 (void) SyncImageSettings(mogrify_info,*image);
1535 (void) EqualizeImageChannel(*image,channel);
1536 InheritException(exception,&(*image)->exception);
1539 if (LocaleCompare(
"evaluate",option+1) == 0)
1544 MagickEvaluateOperator
1547 (void) SyncImageSettings(mogrify_info,*image);
1548 op=(MagickEvaluateOperator) ParseCommandOption(
1549 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1550 constant=StringToDoubleInterval(argv[i+2],(
double) QuantumRange+
1552 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1555 if (LocaleCompare(
"extent",option+1) == 0)
1560 (void) SyncImageSettings(mogrify_info,*image);
1561 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1562 if (geometry.width == 0)
1563 geometry.width=(*image)->columns;
1564 if (geometry.height == 0)
1565 geometry.height=(*image)->rows;
1566 mogrify_image=ExtentImage(*image,&geometry,exception);
1573 if (LocaleCompare(
"family",option+1) == 0)
1577 if (draw_info->family != (
char *) NULL)
1578 draw_info->family=DestroyString(draw_info->family);
1581 (void) SetImageOption(image_info,option+1,argv[i+1]);
1582 (void) CloneString(&draw_info->family,argv[i+1]);
1585 if (LocaleCompare(
"features",option+1) == 0)
1589 (void) DeleteImageArtifact(*image,
"identify:features");
1592 (void) SetImageArtifact(*image,
"identify:features",argv[i+1]);
1593 (void) SetImageArtifact(*image,
"verbose",
"true");
1596 if (LocaleCompare(
"fill",option+1) == 0)
1601 GetMagickPixelPacket(*image,&fill);
1604 (void) QueryMagickColor(
"none",&fill,exception);
1605 (void) QueryColorDatabase(
"none",&draw_info->fill,exception);
1606 if (draw_info->fill_pattern != (Image *) NULL)
1607 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1610 sans=AcquireExceptionInfo();
1611 (void) QueryMagickColor(argv[i+1],&fill,sans);
1612 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1613 sans=DestroyExceptionInfo(sans);
1614 if (status == MagickFalse)
1615 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1619 if (LocaleCompare(
"flip",option+1) == 0)
1624 (void) SyncImageSettings(mogrify_info,*image);
1625 mogrify_image=FlipImage(*image,exception);
1628 if (LocaleCompare(
"floodfill",option+1) == 0)
1636 (void) SyncImageSettings(mogrify_info,*image);
1637 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1638 (void) QueryMagickColor(argv[i+2],&target,exception);
1639 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1640 geometry.x,geometry.y,*option ==
'-' ? MagickFalse : MagickTrue);
1641 InheritException(exception,&(*image)->exception);
1644 if (LocaleCompare(
"flop",option+1) == 0)
1649 (void) SyncImageSettings(mogrify_info,*image);
1650 mogrify_image=FlopImage(*image,exception);
1653 if (LocaleCompare(
"font",option+1) == 0)
1657 if (draw_info->font != (
char *) NULL)
1658 draw_info->font=DestroyString(draw_info->font);
1661 (void) CloneString(&draw_info->font,argv[i+1]);
1664 if (LocaleCompare(
"format",option+1) == 0)
1669 if (LocaleCompare(
"frame",option+1) == 0)
1677 (void) SyncImageSettings(mogrify_info,*image);
1678 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1679 frame_info.width=geometry.width;
1680 frame_info.height=geometry.height;
1681 frame_info.outer_bevel=geometry.x;
1682 frame_info.inner_bevel=geometry.y;
1683 frame_info.x=(ssize_t) frame_info.width;
1684 frame_info.y=(ssize_t) frame_info.height;
1685 frame_info.width=(*image)->columns+2*frame_info.width;
1686 frame_info.height=(*image)->rows+2*frame_info.height;
1687 mogrify_image=FrameImage(*image,&frame_info,exception);
1690 if (LocaleCompare(
"function",option+1) == 0)
1694 token[MaxTextExtent];
1714 (void) SyncImageSettings(mogrify_info,*image);
1715 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1716 MagickFalse,argv[i+1]);
1717 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1718 InheritException(exception,&(*image)->exception);
1719 if (arguments == (
char *) NULL)
1721 p=(
char *) arguments;
1722 for (x=0; *p !=
'\0'; x++)
1724 (void) GetNextToken(p,&p,MaxTextExtent,token);
1726 (void) GetNextToken(p,&p,MaxTextExtent,token);
1728 number_parameters=(size_t) x;
1729 parameters=(
double *) AcquireQuantumMemory(number_parameters,
1730 sizeof(*parameters));
1731 if (parameters == (
double *) NULL)
1732 ThrowWandFatalException(ResourceLimitFatalError,
1733 "MemoryAllocationFailed",(*image)->filename);
1734 (void) memset(parameters,0,number_parameters*
1735 sizeof(*parameters));
1736 p=(
char *) arguments;
1737 for (x=0; (x < (ssize_t) number_parameters) && (*p !=
'\0'); x++)
1739 (void) GetNextToken(p,&p,MaxTextExtent,token);
1741 (void) GetNextToken(p,&p,MaxTextExtent,token);
1742 parameters[x]=StringToDouble(token,(
char **) NULL);
1744 arguments=DestroyString(arguments);
1745 (void) FunctionImageChannel(*image,channel,
function,
1746 number_parameters,parameters,exception);
1747 parameters=(
double *) RelinquishMagickMemory(parameters);
1754 if (LocaleCompare(
"gamma",option+1) == 0)
1759 (void) SyncImageSettings(mogrify_info,*image);
1761 (*image)->gamma=StringToDouble(argv[i+1],(
char **) NULL);
1764 if (strchr(argv[i+1],
',') != (
char *) NULL)
1765 (void) GammaImage(*image,argv[i+1]);
1767 (
void) GammaImageChannel(*image,channel,
1768 StringToDouble(argv[i+1],(
char **) NULL));
1769 InheritException(exception,&(*image)->exception);
1773 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
1774 (LocaleCompare(
"gaussian",option+1) == 0))
1779 (void) SyncImageSettings(mogrify_info,*image);
1780 flags=ParseGeometry(argv[i+1],&geometry_info);
1781 if ((flags & SigmaValue) == 0)
1782 geometry_info.sigma=1.0;
1783 mogrify_image=GaussianBlurImageChannel(*image,channel,
1784 geometry_info.rho,geometry_info.sigma,exception);
1787 if (LocaleCompare(
"geometry",option+1) == 0)
1792 (void) SyncImageSettings(mogrify_info,*image);
1795 if ((*image)->geometry != (
char *) NULL)
1796 (*image)->geometry=DestroyString((*image)->geometry);
1799 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1800 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1801 (void) CloneString(&(*image)->geometry,argv[i+1]);
1803 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1804 (*image)->filter,(*image)->blur,exception);
1807 if (LocaleCompare(
"gravity",option+1) == 0)
1811 draw_info->gravity=UndefinedGravity;
1814 draw_info->gravity=(GravityType) ParseCommandOption(
1815 MagickGravityOptions,MagickFalse,argv[i+1]);
1818 if (LocaleCompare(
"grayscale",option+1) == 0)
1820 PixelIntensityMethod
1823 (void) SyncImagesSettings(mogrify_info,*image);
1824 method=(PixelIntensityMethod) ParseCommandOption(
1825 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1826 (void) GrayscaleImage(*image,method);
1827 InheritException(exception,&(*image)->exception);
1834 if (LocaleCompare(
"highlight-color",option+1) == 0)
1836 (void) SetImageArtifact(*image,
"compare:highlight-color",argv[i+1]);
1839 if (LocaleCompare(
"hough-lines",option+1) == 0)
1844 (void) SyncImageSettings(mogrify_info,*image);
1845 flags=ParseGeometry(argv[i+1],&geometry_info);
1846 if ((flags & SigmaValue) == 0)
1847 geometry_info.sigma=geometry_info.rho;
1848 if ((flags & XiValue) == 0)
1849 geometry_info.xi=40;
1850 mogrify_image=HoughLineImage(*image,(
size_t) geometry_info.rho,
1851 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,exception);
1858 if (LocaleCompare(
"identify",option+1) == 0)
1863 (void) SyncImageSettings(mogrify_info,*image);
1864 if (format == (
char *) NULL)
1866 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1867 InheritException(exception,&(*image)->exception);
1870 text=InterpretImageProperties(mogrify_info,*image,format);
1871 InheritException(exception,&(*image)->exception);
1872 if (text == (
char *) NULL)
1874 (void) fputs(text,stdout);
1875 text=DestroyString(text);
1878 if (LocaleCompare(
"implode",option+1) == 0)
1883 (void) SyncImageSettings(mogrify_info,*image);
1884 (void) ParseGeometry(argv[i+1],&geometry_info);
1885 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1888 if (LocaleCompare(
"interline-spacing",option+1) == 0)
1891 (void) ParseGeometry(
"0",&geometry_info);
1893 (
void) ParseGeometry(argv[i+1],&geometry_info);
1894 draw_info->interline_spacing=geometry_info.rho;
1897 if (LocaleCompare(
"interword-spacing",option+1) == 0)
1900 (void) ParseGeometry(
"0",&geometry_info);
1902 (
void) ParseGeometry(argv[i+1],&geometry_info);
1903 draw_info->interword_spacing=geometry_info.rho;
1906 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
1911 (void) SyncImageSettings(mogrify_info,*image);
1912 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1913 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1914 geometry.height,(*image)->interpolate,exception);
1921 if (LocaleCompare(
"kerning",option+1) == 0)
1924 (void) ParseGeometry(
"0",&geometry_info);
1926 (
void) ParseGeometry(argv[i+1],&geometry_info);
1927 draw_info->kerning=geometry_info.rho;
1930 if (LocaleCompare(
"kuwahara",option+1) == 0)
1935 (void) SyncImageSettings(mogrify_info,*image);
1936 flags=ParseGeometry(argv[i+1],&geometry_info);
1937 if ((flags & SigmaValue) == 0)
1938 geometry_info.sigma=geometry_info.rho-0.5;
1939 mogrify_image=KuwaharaImageChannel(*image,channel,geometry_info.rho,
1940 geometry_info.sigma,exception);
1947 if (LocaleCompare(
"lat",option+1) == 0)
1952 (void) SyncImageSettings(mogrify_info,*image);
1953 flags=ParseGeometry(argv[i+1],&geometry_info);
1954 if ((flags & SigmaValue) == 0)
1955 geometry_info.sigma=1.0;
1956 if ((flags & PercentValue) != 0)
1957 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1958 mogrify_image=AdaptiveThresholdImage(*image,(
size_t)
1959 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1960 geometry_info.xi,exception);
1963 if (LocaleCompare(
"level",option+1) == 0)
1976 (void) SyncImageSettings(mogrify_info,*image);
1977 flags=ParseGeometry(argv[i+1],&geometry_info);
1978 black_point=geometry_info.rho;
1979 white_point=(MagickRealType) QuantumRange;
1980 if ((flags & SigmaValue) != 0)
1981 white_point=geometry_info.sigma;
1983 if ((flags & XiValue) != 0)
1984 gamma=geometry_info.xi;
1985 if ((flags & PercentValue) != 0)
1987 black_point*=(MagickRealType) (QuantumRange/100.0);
1988 white_point*=(MagickRealType) (QuantumRange/100.0);
1990 if ((flags & SigmaValue) == 0)
1991 white_point=(MagickRealType) QuantumRange-black_point;
1992 if ((*option ==
'+') || ((flags & AspectValue) != 0))
1993 (
void) LevelizeImageChannel(*image,channel,black_point,
1996 (
void) LevelImageChannel(*image,channel,black_point,white_point,
1998 InheritException(exception,&(*image)->exception);
2001 if (LocaleCompare(
"level-colors",option+1) == 0)
2004 token[MaxTextExtent];
2013 p=(
const char *) argv[i+1];
2014 (void) GetNextToken(p,&p,MaxTextExtent,token);
2015 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2016 (void) QueryMagickColor(token,&black_point,exception);
2018 (
void) QueryMagickColor(
"#000000",&black_point,exception);
2019 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
2020 (void) GetNextToken(p,&p,MaxTextExtent,token);
2022 white_point=black_point;
2025 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
2026 (
void) GetNextToken(p,&p,MaxTextExtent,token);
2027 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2028 (void) QueryMagickColor(token,&white_point,exception);
2030 (
void) QueryMagickColor(
"#ffffff",&white_point,exception);
2032 (void) LevelColorsImageChannel(*image,channel,&black_point,
2033 &white_point,*option ==
'+' ? MagickTrue : MagickFalse);
2036 if (LocaleCompare(
"linear-stretch",option+1) == 0)
2045 (void) SyncImageSettings(mogrify_info,*image);
2046 flags=ParseGeometry(argv[i+1],&geometry_info);
2047 black_point=geometry_info.rho;
2048 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2049 if ((flags & SigmaValue) != 0)
2050 white_point=geometry_info.sigma;
2051 if ((flags & PercentValue) != 0)
2053 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2054 white_point*=(
double) (*image)->columns*(*image)->rows/100.0;
2056 if ((flags & SigmaValue) == 0)
2057 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2059 (void) LinearStretchImage(*image,black_point,white_point);
2060 InheritException(exception,&(*image)->exception);
2063 if (LocaleCompare(
"linewidth",option+1) == 0)
2065 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
2068 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
2073 (void) SyncImageSettings(mogrify_info,*image);
2074 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2075 if ((flags & XValue) == 0)
2077 if ((flags & YValue) == 0)
2079 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2080 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2083 if (LocaleCompare(
"local-contrast",option+1) == 0)
2088 (void) SyncImageSettings(mogrify_info,*image);
2089 flags=ParseGeometry(argv[i+1],&geometry_info);
2090 if ((flags & RhoValue) == 0)
2091 geometry_info.rho=10;
2092 if ((flags & SigmaValue) == 0)
2093 geometry_info.sigma=12.5;
2094 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
2095 geometry_info.sigma,exception);
2098 if (LocaleCompare(
"lowlight-color",option+1) == 0)
2100 (void) SetImageArtifact(*image,
"compare:lowlight-color",argv[i+1]);
2107 if (LocaleCompare(
"magnify",option+1) == 0)
2112 (void) SyncImageSettings(mogrify_info,*image);
2113 mogrify_image=MagnifyImage(*image,exception);
2116 if (LocaleCompare(
"map",option+1) == 0)
2124 (void) SyncImageSettings(mogrify_info,*image);
2127 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2128 if (remap_image == (Image *) NULL)
2130 (void) RemapImage(quantize_info,*image,remap_image);
2131 InheritException(exception,&(*image)->exception);
2132 remap_image=DestroyImage(remap_image);
2135 if (LocaleCompare(
"mask",option+1) == 0)
2140 (void) SyncImageSettings(mogrify_info,*image);
2146 (void) SetImageMask(*image,(Image *) NULL);
2147 InheritException(exception,&(*image)->exception);
2153 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2154 if (mask == (Image *) NULL)
2156 (void) SetImageMask(*image,mask);
2157 mask=DestroyImage(mask);
2158 InheritException(exception,&(*image)->exception);
2161 if (LocaleCompare(
"matte",option+1) == 0)
2163 (void) SetImageAlphaChannel(*image,(*option ==
'-') ?
2164 SetAlphaChannel : DeactivateAlphaChannel );
2165 InheritException(exception,&(*image)->exception);
2168 if (LocaleCompare(
"mean-shift",option+1) == 0)
2173 (void) SyncImageSettings(mogrify_info,*image);
2174 flags=ParseGeometry(argv[i+1],&geometry_info);
2175 if ((flags & SigmaValue) == 0)
2176 geometry_info.sigma=geometry_info.rho;
2177 if ((flags & XiValue) == 0)
2178 geometry_info.xi=0.10*QuantumRange;
2179 if ((flags & PercentValue) != 0)
2180 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2181 mogrify_image=MeanShiftImage(*image,(
size_t) geometry_info.rho,
2182 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2185 if (LocaleCompare(
"median",option+1) == 0)
2190 (void) SyncImageSettings(mogrify_info,*image);
2191 (void) ParseGeometry(argv[i+1],&geometry_info);
2192 mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic,
2193 (
size_t) geometry_info.rho,(
size_t) geometry_info.rho,exception);
2196 if (LocaleCompare(
"mode",option+1) == 0)
2201 (void) SyncImageSettings(mogrify_info,*image);
2202 (void) ParseGeometry(argv[i+1],&geometry_info);
2203 mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic,
2204 (
size_t) geometry_info.rho,(
size_t) geometry_info.rho,exception);
2207 if (LocaleCompare(
"modulate",option+1) == 0)
2209 (void) SyncImageSettings(mogrify_info,*image);
2210 (void) ModulateImage(*image,argv[i+1]);
2211 InheritException(exception,&(*image)->exception);
2214 if (LocaleCompare(
"moments",option+1) == 0)
2218 (void) DeleteImageArtifact(*image,
"identify:moments");
2221 (void) SetImageArtifact(*image,
"identify:moments",argv[i+1]);
2222 (void) SetImageArtifact(*image,
"verbose",
"true");
2225 if (LocaleCompare(
"monitor",option+1) == 0)
2229 (void) SetImageProgressMonitor(*image,
2230 (MagickProgressMonitor) NULL,(
void *) NULL);
2233 (void) SetImageProgressMonitor(*image,MonitorProgress,
2237 if (LocaleCompare(
"monochrome",option+1) == 0)
2239 (void) SyncImageSettings(mogrify_info,*image);
2240 (void) SetImageType(*image,BilevelType);
2241 InheritException(exception,&(*image)->exception);
2244 if (LocaleCompare(
"morphology",option+1) == 0)
2247 token[MaxTextExtent];
2264 (void) SyncImageSettings(mogrify_info,*image);
2266 (void) GetNextToken(p,&p,MaxTextExtent,token);
2267 method=(MorphologyMethod) ParseCommandOption(
2268 MagickMorphologyOptions,MagickFalse,token);
2270 (void) GetNextToken(p,&p,MaxTextExtent,token);
2271 if ((*p ==
':') || (*p ==
','))
2272 (void) GetNextToken(p,&p,MaxTextExtent,token);
2274 iterations=(ssize_t) StringToLong(p);
2275 kernel=AcquireKernelInfo(argv[i+2]);
2276 if (kernel == (KernelInfo *) NULL)
2278 (void) ThrowMagickException(exception,GetMagickModule(),
2279 OptionError,
"UnabletoParseKernel",
"morphology");
2283 mogrify_image=MorphologyImageChannel(*image,channel,method,
2284 iterations,kernel,exception);
2285 kernel=DestroyKernelInfo(kernel);
2288 if (LocaleCompare(
"motion-blur",option+1) == 0)
2293 (void) SyncImageSettings(mogrify_info,*image);
2294 flags=ParseGeometry(argv[i+1],&geometry_info);
2295 if ((flags & SigmaValue) == 0)
2296 geometry_info.sigma=1.0;
2297 mogrify_image=MotionBlurImageChannel(*image,channel,
2298 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2305 if (LocaleCompare(
"negate",option+1) == 0)
2307 (void) SyncImageSettings(mogrify_info,*image);
2308 (void) NegateImageChannel(*image,channel,*option ==
'+' ?
2309 MagickTrue : MagickFalse);
2310 InheritException(exception,&(*image)->exception);
2313 if (LocaleCompare(
"noise",option+1) == 0)
2315 (void) SyncImageSettings(mogrify_info,*image);
2318 flags=ParseGeometry(argv[i+1],&geometry_info);
2319 if ((flags & SigmaValue) == 0)
2320 geometry_info.sigma=geometry_info.rho;
2321 mogrify_image=StatisticImageChannel(*image,channel,
2322 NonpeakStatistic,(
size_t) geometry_info.rho,(
size_t)
2323 geometry_info.sigma,exception);
2330 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2331 MagickFalse,argv[i+1]);
2332 mogrify_image=AddNoiseImageChannel(*image,channel,noise,
2337 if (LocaleCompare(
"normalize",option+1) == 0)
2339 (void) SyncImageSettings(mogrify_info,*image);
2340 (void) NormalizeImageChannel(*image,channel);
2341 InheritException(exception,&(*image)->exception);
2348 if (LocaleCompare(
"opaque",option+1) == 0)
2353 (void) SyncImageSettings(mogrify_info,*image);
2354 (void) QueryMagickColor(argv[i+1],&target,exception);
2355 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2356 *option ==
'-' ? MagickFalse : MagickTrue);
2359 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2361 (void) SyncImageSettings(mogrify_info,*image);
2362 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2370 if (LocaleCompare(
"paint",option+1) == 0)
2372 (void) SyncImageSettings(mogrify_info,*image);
2373 (void) ParseGeometry(argv[i+1],&geometry_info);
2374 mogrify_image=OilPaintImage(*image,geometry_info.rho,exception);
2377 if (LocaleCompare(
"pen",option+1) == 0)
2381 (void) QueryColorDatabase(
"none",&draw_info->fill,exception);
2384 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2387 if (LocaleCompare(
"perceptible",option+1) == 0)
2392 (void) SyncImageSettings(mogrify_info,*image);
2393 (void) PerceptibleImageChannel(*image,channel,StringToDouble(
2394 argv[i+1],(
char **) NULL));
2395 InheritException(exception,&(*image)->exception);
2398 if (LocaleCompare(
"pointsize",option+1) == 0)
2401 (void) ParseGeometry(
"12",&geometry_info);
2403 (
void) ParseGeometry(argv[i+1],&geometry_info);
2404 draw_info->pointsize=geometry_info.rho;
2407 if (LocaleCompare(
"polaroid",option+1) == 0)
2418 (void) SyncImageSettings(mogrify_info,*image);
2419 random_info=AcquireRandomInfo();
2420 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2421 random_info=DestroyRandomInfo(random_info);
2424 SetGeometryInfo(&geometry_info);
2425 flags=ParseGeometry(argv[i+1],&geometry_info);
2426 angle=geometry_info.rho;
2428 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2431 if (LocaleCompare(
"posterize",option+1) == 0)
2436 (void) SyncImageSettings(mogrify_info,*image);
2437 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2438 quantize_info->dither);
2439 InheritException(exception,&(*image)->exception);
2442 if (LocaleCompare(
"preview",option+1) == 0)
2450 (void) SyncImageSettings(mogrify_info,*image);
2452 preview_type=UndefinedPreview;
2454 preview_type=(PreviewType) ParseCommandOption(
2455 MagickPreviewOptions,MagickFalse,argv[i+1]);
2456 mogrify_image=PreviewImage(*image,preview_type,exception);
2459 if (LocaleCompare(
"profile",option+1) == 0)
2476 (void) SyncImageSettings(mogrify_info,*image);
2482 (void) ProfileImage(*image,argv[i+1],(
const unsigned char *)
2484 InheritException(exception,&(*image)->exception);
2490 profile_info=CloneImageInfo(mogrify_info);
2491 profile=GetImageProfile(*image,
"iptc");
2492 if (profile != (StringInfo *) NULL)
2493 profile_info->profile=(
void *) CloneStringInfo(profile);
2494 sans_exception=AcquireExceptionInfo();
2495 profile_image=GetImageCache(profile_info,argv[i+1],sans_exception);
2496 sans_exception=DestroyExceptionInfo(sans_exception);
2497 profile_info=DestroyImageInfo(profile_info);
2498 if (profile_image == (Image *) NULL)
2503 profile_info=CloneImageInfo(mogrify_info);
2504 (void) CopyMagickString(profile_info->filename,argv[i+1],
2506 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2507 if (profile != (StringInfo *) NULL)
2509 (void) SetImageInfo(profile_info,0,exception);
2510 (void) ProfileImage(*image,profile_info->magick,
2511 GetStringInfoDatum(profile),(size_t)
2512 GetStringInfoLength(profile),MagickFalse);
2513 profile=DestroyStringInfo(profile);
2515 profile_info=DestroyImageInfo(profile_info);
2518 ResetImageProfileIterator(profile_image);
2519 name=GetNextImageProfile(profile_image);
2520 while (name != (
const char *) NULL)
2522 profile=GetImageProfile(profile_image,name);
2523 if (profile != (StringInfo *) NULL)
2524 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2525 (size_t) GetStringInfoLength(profile),MagickFalse);
2526 name=GetNextImageProfile(profile_image);
2528 profile_image=DestroyImage(profile_image);
2535 if (LocaleCompare(
"quantize",option+1) == 0)
2539 quantize_info->colorspace=UndefinedColorspace;
2542 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2543 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2550 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
2551 LocaleCompare(
"rotational-blur",option+1) == 0)
2556 (void) SyncImageSettings(mogrify_info,*image);
2557 mogrify_image=RotationalBlurImageChannel(*image,channel,
2558 StringToDouble(argv[i+1],(
char **) NULL),exception);
2561 if (LocaleCompare(
"raise",option+1) == 0)
2566 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2567 (void) RaiseImage(*image,&geometry,*option ==
'-' ? MagickTrue :
2569 InheritException(exception,&(*image)->exception);
2572 if (LocaleCompare(
"random-threshold",option+1) == 0)
2577 (void) SyncImageSettings(mogrify_info,*image);
2578 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2582 if (LocaleCompare(
"recolor",option+1) == 0)
2587 (void) SyncImageSettings(mogrify_info,*image);
2588 kernel=AcquireKernelInfo(argv[i+1]);
2589 if (kernel == (KernelInfo *) NULL)
2591 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2592 kernel=DestroyKernelInfo(kernel);
2595 if (LocaleCompare(
"region",option+1) == 0)
2597 (void) SyncImageSettings(mogrify_info,*image);
2598 if (region_image != (Image *) NULL)
2603 (void) CompositeImage(region_image,region_image->matte !=
2604 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2605 region_geometry.x,region_geometry.y);
2606 InheritException(exception,®ion_image->exception);
2607 *image=DestroyImage(*image);
2608 *image=region_image;
2609 region_image=(Image *) NULL;
2616 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2618 mogrify_image=CropImage(*image,®ion_geometry,exception);
2619 if (mogrify_image == (Image *) NULL)
2621 region_image=(*image);
2622 *image=mogrify_image;
2623 mogrify_image=(Image *) NULL;
2626 if (LocaleCompare(
"render",option+1) == 0)
2628 (void) SyncImageSettings(mogrify_info,*image);
2629 draw_info->render=(*option ==
'+') ? MagickTrue : MagickFalse;
2632 if (LocaleCompare(
"remap",option+1) == 0)
2640 (void) SyncImageSettings(mogrify_info,*image);
2643 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2644 if (remap_image == (Image *) NULL)
2646 (void) RemapImage(quantize_info,*image,remap_image);
2647 InheritException(exception,&(*image)->exception);
2648 remap_image=DestroyImage(remap_image);
2651 if (LocaleCompare(
"repage",option+1) == 0)
2655 (void) ParseAbsoluteGeometry(
"0x0+0+0",&(*image)->page);
2658 (void) ResetImagePage(*image,argv[i+1]);
2659 InheritException(exception,&(*image)->exception);
2662 if (LocaleCompare(
"resample",option+1) == 0)
2667 (void) SyncImageSettings(mogrify_info,*image);
2668 flags=ParseGeometry(argv[i+1],&geometry_info);
2669 if ((flags & SigmaValue) == 0)
2670 geometry_info.sigma=geometry_info.rho;
2671 mogrify_image=ResampleImage(*image,geometry_info.rho,
2672 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2675 if (LocaleCompare(
"resize",option+1) == 0)
2680 (void) SyncImageSettings(mogrify_info,*image);
2681 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2682 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2683 (*image)->filter,(*image)->blur,exception);
2686 if (LocaleCompare(
"roll",option+1) == 0)
2691 (void) SyncImageSettings(mogrify_info,*image);
2692 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2693 if ((flags & PercentValue) != 0)
2695 geometry.x*=(double) (*image)->columns/100.0;
2696 geometry.y*=(
double) (*image)->rows/100.0;
2698 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2701 if (LocaleCompare(
"rotate",option+1) == 0)
2709 (void) SyncImageSettings(mogrify_info,*image);
2710 if (strchr(argv[i+1],
'>') != (
char *) NULL)
2711 if ((*image)->columns <= (*image)->rows)
2713 if (strchr(argv[i+1],
'<') != (
char *) NULL)
2714 if ((*image)->columns >= (*image)->rows)
2719 geometry=ConstantString(argv[i+1]);
2720 (void) SubstituteString(&geometry,
">",
"");
2721 (void) SubstituteString(&geometry,
"<",
"");
2722 (void) ParseGeometry(geometry,&geometry_info);
2723 geometry=DestroyString(geometry);
2724 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2731 if (LocaleCompare(
"sample",option+1) == 0)
2736 (void) SyncImageSettings(mogrify_info,*image);
2737 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2738 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2742 if (LocaleCompare(
"scale",option+1) == 0)
2747 (void) SyncImageSettings(mogrify_info,*image);
2748 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2749 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2753 if (LocaleCompare(
"selective-blur",option+1) == 0)
2758 (void) SyncImageSettings(mogrify_info,*image);
2759 flags=ParseGeometry(argv[i+1],&geometry_info);
2760 if ((flags & PercentValue) != 0)
2761 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2762 mogrify_image=SelectiveBlurImageChannel(*image,channel,
2763 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2766 if (LocaleCompare(
"separate",option+1) == 0)
2772 (void) SyncImageSettings(mogrify_info,*image);
2773 mogrify_image=SeparateImages(*image,channel,exception);
2776 if (LocaleCompare(
"sepia-tone",option+1) == 0)
2784 (void) SyncImageSettings(mogrify_info,*image);
2785 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2787 mogrify_image=SepiaToneImage(*image,threshold,exception);
2790 if (LocaleCompare(
"segment",option+1) == 0)
2795 (void) SyncImageSettings(mogrify_info,*image);
2796 flags=ParseGeometry(argv[i+1],&geometry_info);
2797 if ((flags & SigmaValue) == 0)
2798 geometry_info.sigma=1.0;
2799 (void) SegmentImage(*image,(*image)->colorspace,
2800 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2801 InheritException(exception,&(*image)->exception);
2804 if (LocaleCompare(
"set",option+1) == 0)
2814 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2815 (void) DeleteImageRegistry(argv[i+1]+9);
2817 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2819 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2820 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2823 (
void) DeleteImageProperty(*image,argv[i+1]);
2826 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2827 InheritException(exception,&(*image)->exception);
2828 if (value == (
char *) NULL)
2830 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2831 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2834 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2836 (void) SetImageOption(image_info,argv[i+1]+7,value);
2837 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2838 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2841 (
void) SetImageProperty(*image,argv[i+1],value);
2842 value=DestroyString(value);
2845 if (LocaleCompare(
"shade",option+1) == 0)
2850 (void) SyncImageSettings(mogrify_info,*image);
2851 flags=ParseGeometry(argv[i+1],&geometry_info);
2852 if ((flags & SigmaValue) == 0)
2853 geometry_info.sigma=1.0;
2854 mogrify_image=ShadeImage(*image,(*option ==
'-') ? MagickTrue :
2855 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2858 if (LocaleCompare(
"shadow",option+1) == 0)
2863 (void) SyncImageSettings(mogrify_info,*image);
2864 flags=ParseGeometry(argv[i+1],&geometry_info);
2865 if ((flags & SigmaValue) == 0)
2866 geometry_info.sigma=1.0;
2867 if ((flags & XiValue) == 0)
2868 geometry_info.xi=4.0;
2869 if ((flags & PsiValue) == 0)
2870 geometry_info.psi=4.0;
2871 mogrify_image=ShadowImage(*image,geometry_info.rho,
2872 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2873 ceil(geometry_info.psi-0.5),exception);
2876 if (LocaleCompare(
"sharpen",option+1) == 0)
2881 (void) SyncImageSettings(mogrify_info,*image);
2882 flags=ParseGeometry(argv[i+1],&geometry_info);
2883 if ((flags & SigmaValue) == 0)
2884 geometry_info.sigma=1.0;
2885 mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2886 geometry_info.sigma,exception);
2889 if (LocaleCompare(
"shave",option+1) == 0)
2894 (void) SyncImageSettings(mogrify_info,*image);
2895 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2896 mogrify_image=ShaveImage(*image,&geometry,exception);
2899 if (LocaleCompare(
"shear",option+1) == 0)
2904 (void) SyncImageSettings(mogrify_info,*image);
2905 flags=ParseGeometry(argv[i+1],&geometry_info);
2906 if ((flags & SigmaValue) == 0)
2907 geometry_info.sigma=geometry_info.rho;
2908 mogrify_image=ShearImage(*image,geometry_info.rho,
2909 geometry_info.sigma,exception);
2912 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
2917 (void) SyncImageSettings(mogrify_info,*image);
2918 flags=ParseGeometry(argv[i+1],&geometry_info);
2919 if ((flags & SigmaValue) == 0)
2920 geometry_info.sigma=(double) QuantumRange/2.0;
2921 if ((flags & PercentValue) != 0)
2922 geometry_info.sigma=(
double) QuantumRange*geometry_info.sigma/
2924 (void) SigmoidalContrastImageChannel(*image,channel,
2925 (*option ==
'-') ? MagickTrue : MagickFalse,geometry_info.rho,
2926 geometry_info.sigma);
2927 InheritException(exception,&(*image)->exception);
2930 if (LocaleCompare(
"sketch",option+1) == 0)
2935 (void) SyncImageSettings(mogrify_info,*image);
2936 flags=ParseGeometry(argv[i+1],&geometry_info);
2937 if ((flags & SigmaValue) == 0)
2938 geometry_info.sigma=1.0;
2939 mogrify_image=SketchImage(*image,geometry_info.rho,
2940 geometry_info.sigma,geometry_info.xi,exception);
2943 if (LocaleCompare(
"solarize",option+1) == 0)
2948 (void) SyncImageSettings(mogrify_info,*image);
2949 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2951 (void) SolarizeImageChannel(*image,channel,threshold,exception);
2954 if (LocaleCompare(
"sparse-color",option+1) == 0)
2965 (void) SyncImageSettings(mogrify_info,*image);
2966 method=(SparseColorMethod) ParseCommandOption(
2967 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2968 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2969 InheritException(exception,&(*image)->exception);
2970 if (arguments == (
char *) NULL)
2972 mogrify_image=SparseColorOption(*image,channel,method,arguments,
2973 option[0] ==
'+' ? MagickTrue : MagickFalse,exception);
2974 arguments=DestroyString(arguments);
2977 if (LocaleCompare(
"splice",option+1) == 0)
2982 (void) SyncImageSettings(mogrify_info,*image);
2983 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2984 mogrify_image=SpliceImage(*image,&geometry,exception);
2987 if (LocaleCompare(
"spread",option+1) == 0)
2992 (void) SyncImageSettings(mogrify_info,*image);
2993 (void) ParseGeometry(argv[i+1],&geometry_info);
2994 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
2997 if (LocaleCompare(
"statistic",option+1) == 0)
3002 (void) SyncImageSettings(mogrify_info,*image);
3003 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
3004 MagickFalse,argv[i+1]);
3005 (void) ParseGeometry(argv[i+2],&geometry_info);
3006 mogrify_image=StatisticImageChannel(*image,channel,type,(
size_t)
3007 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
3010 if (LocaleCompare(
"stretch",option+1) == 0)
3014 draw_info->stretch=UndefinedStretch;
3017 draw_info->stretch=(StretchType) ParseCommandOption(
3018 MagickStretchOptions,MagickFalse,argv[i+1]);
3021 if (LocaleCompare(
"strip",option+1) == 0)
3026 (void) SyncImageSettings(mogrify_info,*image);
3027 (void) StripImage(*image);
3028 InheritException(exception,&(*image)->exception);
3031 if (LocaleCompare(
"stroke",option+1) == 0)
3038 (void) QueryColorDatabase(
"none",&draw_info->stroke,exception);
3039 if (draw_info->stroke_pattern != (Image *) NULL)
3040 draw_info->stroke_pattern=DestroyImage(
3041 draw_info->stroke_pattern);
3044 sans=AcquireExceptionInfo();
3045 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3046 sans=DestroyExceptionInfo(sans);
3047 if (status == MagickFalse)
3048 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3052 if (LocaleCompare(
"strokewidth",option+1) == 0)
3054 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
3057 if (LocaleCompare(
"style",option+1) == 0)
3061 draw_info->style=UndefinedStyle;
3064 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3065 MagickFalse,argv[i+1]);
3068 if (LocaleCompare(
"swirl",option+1) == 0)
3073 (void) SyncImageSettings(mogrify_info,*image);
3074 (void) ParseGeometry(argv[i+1],&geometry_info);
3075 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
3082 if (LocaleCompare(
"threshold",option+1) == 0)
3090 (void) SyncImageSettings(mogrify_info,*image);
3092 threshold=(double) QuantumRange/2;
3094 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
3096 (void) BilevelImageChannel(*image,channel,threshold);
3097 InheritException(exception,&(*image)->exception);
3100 if (LocaleCompare(
"thumbnail",option+1) == 0)
3105 (void) SyncImageSettings(mogrify_info,*image);
3106 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3107 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3111 if (LocaleCompare(
"tile",option+1) == 0)
3115 if (draw_info->fill_pattern != (Image *) NULL)
3116 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3119 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3123 if (LocaleCompare(
"tint",option+1) == 0)
3128 (void) SyncImageSettings(mogrify_info,*image);
3129 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3132 if (LocaleCompare(
"transform",option+1) == 0)
3137 (void) SyncImageSettings(mogrify_info,*image);
3138 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3142 if (LocaleCompare(
"transparent",option+1) == 0)
3147 (void) SyncImageSettings(mogrify_info,*image);
3148 (void) QueryMagickColor(argv[i+1],&target,exception);
3149 (void) TransparentPaintImage(*image,&target,(Quantum)
3150 TransparentOpacity,*option ==
'-' ? MagickFalse : MagickTrue);
3151 InheritException(exception,&(*image)->exception);
3154 if (LocaleCompare(
"transpose",option+1) == 0)
3159 (void) SyncImageSettings(mogrify_info,*image);
3160 mogrify_image=TransposeImage(*image,exception);
3163 if (LocaleCompare(
"transverse",option+1) == 0)
3168 (void) SyncImageSettings(mogrify_info,*image);
3169 mogrify_image=TransverseImage(*image,exception);
3172 if (LocaleCompare(
"treedepth",option+1) == 0)
3174 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3177 if (LocaleCompare(
"trim",option+1) == 0)
3182 (void) SyncImageSettings(mogrify_info,*image);
3183 mogrify_image=TrimImage(*image,exception);
3186 if (LocaleCompare(
"type",option+1) == 0)
3191 (void) SyncImageSettings(mogrify_info,*image);
3195 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3197 (*image)->type=UndefinedType;
3198 (void) SetImageType(*image,type);
3199 InheritException(exception,&(*image)->exception);
3206 if (LocaleCompare(
"undercolor",option+1) == 0)
3208 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3212 if (LocaleCompare(
"unique",option+1) == 0)
3216 (void) DeleteImageArtifact(*image,
"identify:unique-colors");
3219 (void) SetImageArtifact(*image,
"identify:unique-colors",
"true");
3220 (void) SetImageArtifact(*image,
"verbose",
"true");
3223 if (LocaleCompare(
"unique-colors",option+1) == 0)
3228 (void) SyncImageSettings(mogrify_info,*image);
3229 mogrify_image=UniqueImageColors(*image,exception);
3232 if (LocaleCompare(
"unsharp",option+1) == 0)
3237 (void) SyncImageSettings(mogrify_info,*image);
3238 flags=ParseGeometry(argv[i+1],&geometry_info);
3239 if ((flags & SigmaValue) == 0)
3240 geometry_info.sigma=1.0;
3241 if ((flags & XiValue) == 0)
3242 geometry_info.xi=1.0;
3243 if ((flags & PsiValue) == 0)
3244 geometry_info.psi=0.05;
3245 mogrify_image=UnsharpMaskImageChannel(*image,channel,
3246 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3247 geometry_info.psi,exception);
3254 if (LocaleCompare(
"verbose",option+1) == 0)
3256 (void) SetImageArtifact(*image,option+1,
3257 *option ==
'+' ?
"false" :
"true");
3260 if (LocaleCompare(
"vignette",option+1) == 0)
3265 (void) SyncImageSettings(mogrify_info,*image);
3266 flags=ParseGeometry(argv[i+1],&geometry_info);
3267 if ((flags & SigmaValue) == 0)
3268 geometry_info.sigma=1.0;
3269 if ((flags & XiValue) == 0)
3270 geometry_info.xi=0.1*(*image)->columns;
3271 if ((flags & PsiValue) == 0)
3272 geometry_info.psi=0.1*(*image)->rows;
3273 if ((flags & PercentValue) != 0)
3275 geometry_info.xi*=(double) (*image)->columns/100.0;
3276 geometry_info.psi*=(
double) (*image)->rows/100.0;
3278 mogrify_image=VignetteImage(*image,geometry_info.rho,
3279 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3280 ceil(geometry_info.psi-0.5),exception);
3283 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
3287 (void) SetImageVirtualPixelMethod(*image,
3288 UndefinedVirtualPixelMethod);
3291 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3292 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3300 if (LocaleCompare(
"wave",option+1) == 0)
3305 (void) SyncImageSettings(mogrify_info,*image);
3306 flags=ParseGeometry(argv[i+1],&geometry_info);
3307 if ((flags & SigmaValue) == 0)
3308 geometry_info.sigma=1.0;
3309 mogrify_image=WaveImage(*image,geometry_info.rho,
3310 geometry_info.sigma,exception);
3313 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3318 (void) SyncImageSettings(mogrify_info,*image);
3319 flags=ParseGeometry(argv[i+1],&geometry_info);
3320 if ((flags & PercentValue) != 0)
3322 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
3323 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
3325 if ((flags & SigmaValue) == 0)
3326 geometry_info.sigma=0.0;
3327 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3328 geometry_info.sigma,exception);
3331 if (LocaleCompare(
"weight",option+1) == 0)
3336 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3339 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3340 draw_info->weight=(size_t) weight;
3343 if (LocaleCompare(
"white-threshold",option+1) == 0)
3348 (void) SyncImageSettings(mogrify_info,*image);
3349 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3351 InheritException(exception,&(*image)->exception);
3362 if (mogrify_image != (Image *) NULL)
3363 ReplaceImageInListReturnLast(image,mogrify_image);
3366 if (region_image != (Image *) NULL)
3371 (void) SyncImageSettings(mogrify_info,*image);
3372 (void) CompositeImage(region_image,region_image->matte != MagickFalse ?
3373 CopyCompositeOp : OverCompositeOp,*image,region_geometry.x,
3375 InheritException(exception,®ion_image->exception);
3376 *image=DestroyImage(*image);
3377 *image=region_image;
3378 region_image = (Image *) NULL;
3383 quantize_info=DestroyQuantizeInfo(quantize_info);
3384 draw_info=DestroyDrawInfo(draw_info);
3385 mogrify_info=DestroyImageInfo(mogrify_info);
3386 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3387 return(status == 0 ? MagickFalse : MagickTrue);
3424 static MagickBooleanType MogrifyUsage(
void)
3428 " -debug events display copious debugging information\n"
3429 " -distribute-cache port\n"
3430 " distributed pixel cache spanning one or more servers\n"
3431 " -help print program options\n"
3432 " -list type print a list of supported option arguments\n"
3433 " -log format format of debugging information\n"
3434 " -version print version information",
3436 " -adaptive-blur geometry\n"
3437 " adaptively blur pixels; decrease effect near edges\n"
3438 " -adaptive-resize geometry\n"
3439 " adaptively resize image using 'mesh' interpolation\n"
3440 " -adaptive-sharpen geometry\n"
3441 " adaptively sharpen pixels; increase effect near edges\n"
3442 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3443 " transparent, extract, background, or shape\n"
3444 " -annotate geometry text\n"
3445 " annotate the image with text\n"
3446 " -auto-gamma automagically adjust gamma level of image\n"
3447 " -auto-level automagically adjust color levels of image\n"
3448 " -auto-orient automagically orient (rotate) image\n"
3449 " -bench iterations measure performance\n"
3450 " -black-threshold value\n"
3451 " force all pixels below the threshold into black\n"
3452 " -blue-shift simulate a scene at nighttime in the moonlight\n"
3453 " -blur geometry reduce image noise and reduce detail levels\n"
3454 " -border geometry surround image with a border of color\n"
3455 " -bordercolor color border color\n"
3456 " -brightness-contrast geometry\n"
3457 " improve brightness / contrast of the image\n"
3458 " -canny geometry detect edges in the image\n"
3459 " -cdl filename color correct with a color decision list\n"
3460 " -charcoal radius simulate a charcoal drawing\n"
3461 " -chop geometry remove pixels from the image interior\n"
3462 " -clamp keep pixel values in range (0-QuantumRange)\n"
3463 " -clip clip along the first path from the 8BIM profile\n"
3464 " -clip-mask filename associate a clip mask with the image\n"
3465 " -clip-path id clip along a named path from the 8BIM profile\n"
3466 " -colorize value colorize the image with the fill color\n"
3467 " -color-matrix matrix apply color correction to the image\n"
3468 " -connected-components connectivity\n"
3469 " connected-components uniquely labeled\n"
3470 " -contrast enhance or reduce the image contrast\n"
3471 " -contrast-stretch geometry\n"
3472 " improve contrast by `stretching' the intensity range\n"
3473 " -convolve coefficients\n"
3474 " apply a convolution kernel to the image\n"
3475 " -cycle amount cycle the image colormap\n"
3476 " -decipher filename convert cipher pixels to plain pixels\n"
3477 " -deskew threshold straighten an image\n"
3478 " -despeckle reduce the speckles within an image\n"
3479 " -distort method args\n"
3480 " distort images according to given method ad args\n"
3481 " -draw string annotate the image with a graphic primitive\n"
3482 " -edge radius apply a filter to detect edges in the image\n"
3483 " -encipher filename convert plain pixels to cipher pixels\n"
3484 " -emboss radius emboss an image\n"
3485 " -enhance apply a digital filter to enhance a noisy image\n"
3486 " -equalize perform histogram equalization to an image\n"
3487 " -evaluate operator value\n"
3488 " evaluate an arithmetic, relational, or logical expression\n"
3489 " -extent geometry set the image size\n"
3490 " -extract geometry extract area from image\n"
3491 " -hough-lines geometry\n"
3492 " identify lines in the image\n"
3493 " -features distance analyze image features (e.g. contrast, correlation)\n"
3494 " -fft implements the discrete Fourier transform (DFT)\n"
3495 " -flip flip image vertically\n"
3496 " -floodfill geometry color\n"
3497 " floodfill the image with color\n"
3498 " -flop flop image horizontally\n"
3499 " -frame geometry surround image with an ornamental border\n"
3500 " -function name parameters\n"
3501 " apply function over image values\n"
3502 " -gamma value level of gamma correction\n"
3503 " -gaussian-blur geometry\n"
3504 " reduce image noise and reduce detail levels\n"
3505 " -geometry geometry preferred size or location of the image\n"
3506 " -grayscale method convert image to grayscale\n"
3507 " -help print program options\n"
3508 " -identify identify the format and characteristics of the image\n"
3509 " -ift implements the inverse discrete Fourier transform (DFT)\n"
3510 " -implode amount implode image pixels about the center\n"
3511 " -kuwahara geometry edge preserving noise reduction filter\n"
3512 " -lat geometry local adaptive thresholding\n"
3513 " -layers method optimize, merge, or compare image layers\n"
3514 " -level value adjust the level of image contrast\n"
3515 " -level-colors color,color\n"
3516 " level image with the given colors\n"
3517 " -linear-stretch geometry\n"
3518 " improve contrast by `stretching with saturation'\n"
3519 " -liquid-rescale geometry\n"
3520 " rescale image with seam-carving\n"
3521 " -local-contrast geometry\n"
3522 " enhance local contrast\n"
3523 " -magnify double the size of the image with pixel art scaling\n"
3524 " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3525 " -median geometry apply a median filter to the image\n"
3526 " -mode geometry make each pixel the 'predominant color' of the\n"
3528 " -modulate value vary the brightness, saturation, and hue\n"
3529 " -monochrome transform image to black and white\n"
3530 " -morphology method kernel\n"
3531 " apply a morphology method to the image\n"
3532 " -motion-blur geometry\n"
3533 " simulate motion blur\n"
3534 " -negate replace every pixel with its complementary color \n"
3535 " -noise geometry add or reduce noise in an image\n"
3536 " -normalize transform image to span the full range of colors\n"
3537 " -opaque color change this color to the fill color\n"
3538 " -ordered-dither NxN\n"
3539 " add a noise pattern to the image with specific\n"
3541 " -paint radius simulate an oil painting\n"
3542 " -perceptible epsilon\n"
3543 " pixel value less than |epsilon| become epsilon or\n"
3545 " -polaroid angle simulate a Polaroid picture\n"
3546 " -posterize levels reduce the image to a limited number of color levels\n"
3547 " -profile filename add, delete, or apply an image profile\n"
3548 " -quantize colorspace reduce colors in this colorspace\n"
3549 " -radial-blur angle radial blur the image\n"
3550 " -raise value lighten/darken image edges to create a 3-D effect\n"
3551 " -random-threshold low,high\n"
3552 " random threshold the image\n"
3553 " -region geometry apply options to a portion of the image\n"
3554 " -render render vector graphics\n"
3555 " -resample geometry change the resolution of an image\n"
3556 " -resize geometry resize the image\n"
3557 " -roll geometry roll an image vertically or horizontally\n"
3558 " -rotate degrees apply Paeth rotation to the image\n"
3559 " -sample geometry scale image with pixel sampling\n"
3560 " -scale geometry scale the image\n"
3561 " -segment values segment an image\n"
3562 " -selective-blur geometry\n"
3563 " selectively blur pixels within a contrast threshold\n"
3564 " -sepia-tone threshold\n"
3565 " simulate a sepia-toned photo\n"
3566 " -set property value set an image property\n"
3567 " -shade degrees shade the image using a distant light source\n"
3568 " -shadow geometry simulate an image shadow\n"
3569 " -sharpen geometry sharpen the image\n"
3570 " -shave geometry shave pixels from the image edges\n"
3571 " -shear geometry slide one edge of the image along the X or Y axis\n"
3572 " -sigmoidal-contrast geometry\n"
3573 " increase the contrast without saturating highlights or\n"
3575 " -sketch geometry simulate a pencil sketch\n"
3576 " -solarize threshold negate all pixels above the threshold level\n"
3577 " -sparse-color method args\n"
3578 " fill in a image based on a few color points\n"
3579 " -splice geometry splice the background color into the image\n"
3580 " -spread radius displace image pixels by a random amount\n"
3581 " -statistic type radius\n"
3582 " replace each pixel with corresponding statistic from the neighborhood\n"
3583 " -strip strip image of all profiles and comments\n"
3584 " -swirl degrees swirl image pixels about the center\n"
3585 " -threshold value threshold the image\n"
3586 " -thumbnail geometry create a thumbnail of the image\n"
3587 " -tile filename tile image when filling a graphic primitive\n"
3588 " -tint value tint the image with the fill color\n"
3589 " -transform affine transform image\n"
3590 " -transparent color make this color transparent within the image\n"
3591 " -transpose flip image vertically and rotate 90 degrees\n"
3592 " -transverse flop image horizontally and rotate 270 degrees\n"
3593 " -trim trim image edges\n"
3594 " -type type image type\n"
3595 " -unique-colors discard all but one of any pixel color\n"
3596 " -unsharp geometry sharpen the image\n"
3597 " -vignette geometry soften the edges of the image in vignette style\n"
3598 " -wave geometry alter an image along a sine wave\n"
3599 " -wavelet-denoise threshold\n"
3600 " removes noise from the image using a wavelet transform\n"
3601 " -white-threshold value\n"
3602 " force all pixels above the threshold into white",
3603 sequence_operators[] =
3604 " -affinity filename transform image colors to match this set of colors\n"
3605 " -append append an image sequence\n"
3606 " -clut apply a color lookup table to the image\n"
3607 " -coalesce merge a sequence of images\n"
3608 " -combine combine a sequence of images\n"
3609 " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3610 " -complex operator perform complex mathematics on an image sequence\n"
3611 " -composite composite image\n"
3612 " -copy geometry offset\n"
3613 " copy pixels from one area of an image to another\n"
3614 " -crop geometry cut out a rectangular region of the image\n"
3615 " -deconstruct break down an image sequence into constituent parts\n"
3616 " -evaluate-sequence operator\n"
3617 " evaluate an arithmetic, relational, or logical expression\n"
3618 " -flatten flatten a sequence of images\n"
3619 " -fx expression apply mathematical expression to an image channel(s)\n"
3620 " -hald-clut apply a Hald color lookup table to the image\n"
3621 " -layers method optimize, merge, or compare image layers\n"
3622 " -morph value morph an image sequence\n"
3623 " -mosaic create a mosaic from an image sequence\n"
3624 " -poly terms build a polynomial from the image sequence and the corresponding\n"
3625 " terms (coefficients and degree pairs).\n"
3626 " -print string interpret string and print to console\n"
3627 " -process arguments process the image with a custom image filter\n"
3628 " -separate separate an image channel into a grayscale image\n"
3629 " -smush geometry smush an image sequence together\n"
3630 " -write filename write images to this file",
3632 " -adjoin join images into a single multi-image file\n"
3633 " -affine matrix affine transform matrix\n"
3634 " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3635 " -antialias remove pixel-aliasing\n"
3636 " -authenticate password\n"
3637 " decipher image with this password\n"
3638 " -attenuate value lessen (or intensify) when adding noise to an image\n"
3639 " -background color background color\n"
3640 " -bias value add bias when convolving an image\n"
3641 " -black-point-compensation\n"
3642 " use black point compensation\n"
3643 " -blue-primary point chromaticity blue primary point\n"
3644 " -bordercolor color border color\n"
3645 " -caption string assign a caption to an image\n"
3646 " -cdl filename color correct with a color decision list\n"
3647 " -channel type apply option to select image channels\n"
3648 " -colors value preferred number of colors in the image\n"
3649 " -colorspace type alternate image colorspace\n"
3650 " -comment string annotate image with comment\n"
3651 " -compose operator set image composite operator\n"
3652 " -compress type type of pixel compression when writing the image\n"
3653 " -decipher filename convert cipher pixels to plain pixels\n"
3654 " -define format:option\n"
3655 " define one or more image format options\n"
3656 " -delay value display the next image after pausing\n"
3657 " -density geometry horizontal and vertical density of the image\n"
3658 " -depth value image depth\n"
3659 " -direction type render text right-to-left or left-to-right\n"
3660 " -display server get image or font from this X server\n"
3661 " -dispose method layer disposal method\n"
3662 " -dither method apply error diffusion to image\n"
3663 " -encipher filename convert plain pixels to cipher pixels\n"
3664 " -encoding type text encoding type\n"
3665 " -endian type endianness (MSB or LSB) of the image\n"
3666 " -family name render text with this font family\n"
3667 " -features distance analyze image features (e.g. contrast, correlation)\n"
3668 " -fill color color to use when filling a graphic primitive\n"
3669 " -filter type use this filter when resizing an image\n"
3670 " -flatten flatten a sequence of images\n"
3671 " -font name render text with this font\n"
3672 " -format \"string\" output formatted image characteristics\n"
3673 " -function name apply a function to the image\n"
3674 " -fuzz distance colors within this distance are considered equal\n"
3675 " -gravity type horizontal and vertical text placement\n"
3676 " -green-primary point chromaticity green primary point\n"
3677 " -intensity method method to generate intensity value from pixel\n"
3678 " -intent type type of rendering intent when managing the image color\n"
3679 " -interlace type type of image interlacing scheme\n"
3680 " -interline-spacing value\n"
3681 " set the space between two text lines\n"
3682 " -interpolate method pixel color interpolation method\n"
3683 " -interword-spacing value\n"
3684 " set the space between two words\n"
3685 " -kerning value set the space between two letters\n"
3686 " -label string assign a label to an image\n"
3687 " -limit type value pixel cache resource limit\n"
3688 " -loop iterations add Netscape loop extension to your GIF animation\n"
3689 " -mask filename associate a mask with the image\n"
3690 " -matte store matte channel if the image has one\n"
3691 " -mattecolor color frame color\n"
3692 " -monitor monitor progress\n"
3693 " -morphology method kernel\n"
3694 " apply a morphology method to the image\n"
3695 " -orient type image orientation\n"
3696 " -page geometry size and location of an image canvas (setting)\n"
3697 " -path path write images to this path on disk\n"
3698 " -ping efficiently determine image attributes\n"
3699 " -pointsize value font point size\n"
3700 " -precision value maximum number of significant digits to print\n"
3701 " -preview type image preview type\n"
3702 " -quality value JPEG/MIFF/PNG compression level\n"
3703 " -quiet suppress all warning messages\n"
3704 " -red-primary point chromaticity red primary point\n"
3705 " -regard-warnings pay attention to warning messages\n"
3706 " -remap filename transform image colors to match this set of colors\n"
3707 " -repage geometry size and location of an image canvas\n"
3708 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3709 " -sampling-factor geometry\n"
3710 " horizontal and vertical sampling factor\n"
3711 " -scene value image scene number\n"
3712 " -seed value seed a new sequence of pseudo-random numbers\n"
3713 " -size geometry width and height of image\n"
3714 " -stretch type render text with this font stretch\n"
3715 " -stroke color graphic primitive stroke color\n"
3716 " -strokewidth value graphic primitive stroke width\n"
3717 " -style type render text with this font style\n"
3718 " -synchronize synchronize image to storage device\n"
3719 " -taint declare the image as modified\n"
3720 " -texture filename name of texture to tile onto the image background\n"
3721 " -tile-offset geometry\n"
3723 " -treedepth value color tree depth\n"
3724 " -transparent-color color\n"
3725 " transparent color\n"
3726 " -undercolor color annotation bounding box color\n"
3727 " -units type the units of image resolution\n"
3728 " -verbose print detailed information about the image\n"
3729 " -view FlashPix viewing transforms\n"
3730 " -virtual-pixel method\n"
3731 " virtual pixel access method\n"
3732 " -weight type render text with this font weight\n"
3733 " -white-point point chromaticity white point",
3735 " -delete indexes delete the image from the image sequence\n"
3736 " -duplicate count,indexes\n"
3737 " duplicate an image one or more times\n"
3738 " -insert index insert last image into the image sequence\n"
3739 " -reverse reverse image sequence\n"
3740 " -swap indexes swap two images in the image sequence";
3742 ListMagickVersion(stdout);
3743 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
3745 (void) printf(
"\nImage Settings:\n");
3746 (void) puts(settings);
3747 (void) printf(
"\nImage Operators:\n");
3748 (void) puts(operators);
3749 (void) printf(
"\nImage Sequence Operators:\n");
3750 (void) puts(sequence_operators);
3751 (void) printf(
"\nImage Stack Operators:\n");
3752 (void) puts(stack_operators);
3753 (void) printf(
"\nMiscellaneous Options:\n");
3754 (void) puts(miscellaneous);
3756 "\nBy default, the image format of `file' is determined by its magic\n");
3758 "number. To specify a particular image format, precede the filename\n");
3760 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3762 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3763 (void) printf(
"'-' for standard input or output.\n");
3767 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3768 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
3770 #define DestroyMogrify() \
3772 if (format != (char *) NULL) \
3773 format=DestroyString(format); \
3774 if (path != (char *) NULL) \
3775 path=DestroyString(path); \
3776 DestroyImageStack(); \
3777 for (i=0; i < (ssize_t) argc; i++) \
3778 argv[i]=DestroyString(argv[i]); \
3779 argv=(char **) RelinquishMagickMemory(argv); \
3781 #define ThrowMogrifyException(asperity,tag,option) \
3783 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3786 return(MagickFalse); \
3788 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3790 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3791 "InvalidArgument","`%s': %s",argument,option); \
3793 return(MagickFalse); \
3805 image_stack[MaxImageStackDepth+1];
3813 respect_parenthesis;
3825 wand_unreferenced(metadata);
3830 assert(image_info != (ImageInfo *) NULL);
3831 assert(image_info->signature == MagickCoreSignature);
3832 assert(exception != (ExceptionInfo *) NULL);
3833 if (IsEventLogging() != MagickFalse)
3834 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3838 if ((LocaleCompare(
"version",option+1) == 0) ||
3839 (LocaleCompare(
"-version",option+1) == 0))
3841 ListMagickVersion(stdout);
3846 return(MogrifyUsage());
3847 format=(
char *) NULL;
3849 global_colormap=MagickFalse;
3853 option=(
char *) NULL;
3855 respect_parenthesis=MagickFalse;
3860 ReadCommandlLine(argc,&argv);
3861 status=ExpandFilenames(&argc,&argv);
3862 if (status == MagickFalse)
3863 ThrowMogrifyException(ResourceLimitError,
"MemoryAllocationFailed",
3864 GetExceptionMessage(errno));
3865 for (i=1; i < (ssize_t) argc; i++)
3868 if (LocaleCompare(option,
"(") == 0)
3870 FireImageStack(MagickFalse,MagickTrue,pend);
3871 if (k == MaxImageStackDepth)
3872 ThrowMogrifyException(OptionError,
"ParenthesisNestedTooDeeply",
3877 if (LocaleCompare(option,
")") == 0)
3879 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3881 ThrowMogrifyException(OptionError,
"UnableToParseExpression",option);
3885 if (IsCommandOption(option) == MagickFalse)
3888 backup_filename[MaxTextExtent],
3890 magic[MagickPathExtent];
3901 FireImageStack(MagickFalse,MagickFalse,pend);
3903 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
3905 (void) SetImageOption(image_info,
"filename",filename);
3906 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3907 images=ReadImages(image_info,exception);
3908 status&=(images != (Image *) NULL) &&
3909 (exception->severity < ErrorException);
3910 if (images == (Image *) NULL)
3912 properties=(*GetBlobProperties(images));
3913 if (format != (
char *) NULL)
3914 GetPathComponent(images->magick_filename,BasePathSansCompressExtension,
3916 if (path != (
char *) NULL)
3918 GetPathComponent(option,TailPath,filename);
3919 (void) FormatLocaleString(images->filename,MaxTextExtent,
"%s%c%s",
3920 path,*DirectorySeparator,filename);
3922 if (format != (
char *) NULL)
3923 AppendImageFormat(format,images->filename);
3924 AppendImageStack(images);
3925 FinalizeImageSettings(image_info,image,MagickFalse);
3926 if (image == (Image *) NULL)
3928 if (global_colormap != MagickFalse)
3933 quantize_info=AcquireQuantizeInfo(image_info);
3934 (void) RemapImages(quantize_info,images,(Image *) NULL);
3935 quantize_info=DestroyQuantizeInfo(quantize_info);
3937 *backup_filename=
'\0';
3939 GetPathComponent(filename,MagickPath,magic);
3943 filename[MagickPathExtent];
3945 if (format != (
char *) NULL)
3946 (void) CopyMagickString(magic,format,MagickPathExtent);
3947 (void) FormatLocaleString(filename,MagickPathExtent,
"%s:%s",magic,
3949 (void) CopyMagickString(image->filename,filename,MagickPathExtent);
3951 if ((LocaleCompare(image->filename,
"-") != 0) &&
3952 (IsPathWritable(image->filename) != MagickFalse))
3960 (void) CopyMagickString(backup_filename,image->filename,
3962 for (i=0; i < 6; i++)
3964 (void) ConcatenateMagickString(backup_filename,
"~",MaxTextExtent);
3965 if (IsPathAccessible(backup_filename) == MagickFalse)
3968 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3969 (rename_utf8(image->filename,backup_filename) != 0))
3970 *backup_filename=
'\0';
3975 image_info->synchronize=MagickTrue;
3976 status&=WriteImages(image_info,image,image->filename,exception);
3977 if (status != MagickFalse)
3979 #if defined(MAGICKCORE_HAVE_UTIME)
3984 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3985 "preserve-timestamp"));
3986 if (preserve_timestamp != MagickFalse)
3991 timestamp.actime=properties.st_atime;
3992 timestamp.modtime=properties.st_mtime;
3993 (void) utime(image->filename,×tamp);
3997 if (*backup_filename !=
'\0')
3998 (void) remove_utf8(backup_filename);
4001 if (*backup_filename !=
'\0')
4002 (void) rename_utf8(backup_filename,image->filename);
4003 RemoveAllImageStack();
4006 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4007 switch (*(option+1))
4011 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
4014 if (i == (ssize_t) argc)
4015 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4016 if (IsGeometry(argv[i]) == MagickFalse)
4017 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4020 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
4023 if (i == (ssize_t) argc)
4024 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4025 if (IsGeometry(argv[i]) == MagickFalse)
4026 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4029 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
4032 if (i == (ssize_t) argc)
4033 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4034 if (IsGeometry(argv[i]) == MagickFalse)
4035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4038 if (LocaleCompare(
"affine",option+1) == 0)
4043 if (i == (ssize_t) argc)
4044 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4045 if (IsGeometry(argv[i]) == MagickFalse)
4046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4049 if (LocaleCompare(
"alpha",option+1) == 0)
4057 if (i == (ssize_t) argc)
4058 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4059 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
4061 ThrowMogrifyException(OptionError,
"UnrecognizedAlphaChannelType",
4065 if (LocaleCompare(
"annotate",option+1) == 0)
4070 if (i == (ssize_t) argc)
4071 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4072 if (IsGeometry(argv[i]) == MagickFalse)
4073 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4074 if (i == (ssize_t) argc)
4075 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4079 if (LocaleCompare(
"antialias",option+1) == 0)
4081 if (LocaleCompare(
"append",option+1) == 0)
4083 if (LocaleCompare(
"attenuate",option+1) == 0)
4088 if (i == (ssize_t) argc)
4089 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4090 if (IsGeometry(argv[i]) == MagickFalse)
4091 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4094 if (LocaleCompare(
"authenticate",option+1) == 0)
4099 if (i == (ssize_t) argc)
4100 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4103 if (LocaleCompare(
"auto-gamma",option+1) == 0)
4105 if (LocaleCompare(
"auto-level",option+1) == 0)
4107 if (LocaleCompare(
"auto-orient",option+1) == 0)
4109 if (LocaleCompare(
"average",option+1) == 0)
4111 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4115 if (LocaleCompare(
"background",option+1) == 0)
4120 if (i == (ssize_t) argc)
4121 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4124 if (LocaleCompare(
"bias",option+1) == 0)
4129 if (i == (ssize_t) argc)
4130 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4131 if (IsGeometry(argv[i]) == MagickFalse)
4132 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4135 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
4137 if (LocaleCompare(
"black-threshold",option+1) == 0)
4142 if (i == (ssize_t) argc)
4143 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4144 if (IsGeometry(argv[i]) == MagickFalse)
4145 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4148 if (LocaleCompare(
"blue-primary",option+1) == 0)
4153 if (i == (ssize_t) argc)
4154 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4155 if (IsGeometry(argv[i]) == MagickFalse)
4156 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4159 if (LocaleCompare(
"blue-shift",option+1) == 0)
4162 if (i == (ssize_t) argc)
4163 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4164 if (IsGeometry(argv[i]) == MagickFalse)
4165 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4168 if (LocaleCompare(
"blur",option+1) == 0)
4171 if (i == (ssize_t) argc)
4172 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4173 if (IsGeometry(argv[i]) == MagickFalse)
4174 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4177 if (LocaleCompare(
"border",option+1) == 0)
4182 if (i == (ssize_t) argc)
4183 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4184 if (IsGeometry(argv[i]) == MagickFalse)
4185 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4188 if (LocaleCompare(
"bordercolor",option+1) == 0)
4193 if (i == (ssize_t) argc)
4194 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4197 if (LocaleCompare(
"box",option+1) == 0)
4202 if (i == (ssize_t) argc)
4203 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4206 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
4209 if (i == (ssize_t) argc)
4210 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4211 if (IsGeometry(argv[i]) == MagickFalse)
4212 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4215 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4219 if (LocaleCompare(
"cache",option+1) == 0)
4224 if (i == (ssize_t) argc)
4225 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4226 if (IsGeometry(argv[i]) == MagickFalse)
4227 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4230 if (LocaleCompare(
"canny",option+1) == 0)
4235 if (i == (ssize_t) argc)
4236 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4237 if (IsGeometry(argv[i]) == MagickFalse)
4238 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4241 if (LocaleCompare(
"caption",option+1) == 0)
4246 if (i == (ssize_t) argc)
4247 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4250 if (LocaleCompare(
"channel",option+1) == 0)
4258 if (i == (ssize_t) argc)
4259 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4260 channel=ParseChannelOption(argv[i]);
4262 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4266 if (LocaleCompare(
"cdl",option+1) == 0)
4271 if (i == (ssize_t) argc)
4272 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4275 if (LocaleCompare(
"charcoal",option+1) == 0)
4280 if (i == (ssize_t) argc)
4281 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4282 if (IsGeometry(argv[i]) == MagickFalse)
4283 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4286 if (LocaleCompare(
"chop",option+1) == 0)
4291 if (i == (ssize_t) argc)
4292 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4293 if (IsGeometry(argv[i]) == MagickFalse)
4294 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4297 if (LocaleCompare(
"clamp",option+1) == 0)
4299 if (LocaleCompare(
"clip",option+1) == 0)
4301 if (LocaleCompare(
"clip-mask",option+1) == 0)
4306 if (i == (ssize_t) argc)
4307 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4310 if (LocaleCompare(
"clut",option+1) == 0)
4312 if (LocaleCompare(
"coalesce",option+1) == 0)
4314 if (LocaleCompare(
"colorize",option+1) == 0)
4319 if (i == (ssize_t) argc)
4320 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4321 if (IsGeometry(argv[i]) == MagickFalse)
4322 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4325 if (LocaleCompare(
"color-matrix",option+1) == 0)
4333 if (i == (ssize_t) argc)
4334 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4335 kernel_info=AcquireKernelInfo(argv[i]);
4336 if (kernel_info == (KernelInfo *) NULL)
4337 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4338 kernel_info=DestroyKernelInfo(kernel_info);
4341 if (LocaleCompare(
"colors",option+1) == 0)
4346 if (i == (ssize_t) argc)
4347 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4348 if (IsGeometry(argv[i]) == MagickFalse)
4349 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4352 if (LocaleCompare(
"colorspace",option+1) == 0)
4360 if (i == (ssize_t) argc)
4361 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4362 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4365 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4369 if (LocaleCompare(
"combine",option+1) == 0)
4374 if (i == (ssize_t) argc)
4375 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4378 if (LocaleCompare(
"comment",option+1) == 0)
4383 if (i == (ssize_t) argc)
4384 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4387 if (LocaleCompare(
"compare",option+1) == 0)
4389 if (LocaleCompare(
"complex",option+1) == 0)
4397 if (i == (ssize_t) argc)
4398 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4399 op=ParseCommandOption(MagickComplexOptions,MagickFalse,argv[i]);
4401 ThrowMogrifyException(OptionError,
"UnrecognizedComplexOperator",
4405 if (LocaleCompare(
"compose",option+1) == 0)
4413 if (i == (ssize_t) argc)
4414 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4415 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4418 ThrowMogrifyException(OptionError,
"UnrecognizedComposeOperator",
4422 if (LocaleCompare(
"composite",option+1) == 0)
4424 if (LocaleCompare(
"compress",option+1) == 0)
4432 if (i == (ssize_t) argc)
4433 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4434 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4437 ThrowMogrifyException(OptionError,
"UnrecognizedImageCompression",
4441 if (LocaleCompare(
"concurrent",option+1) == 0)
4443 if (LocaleCompare(
"connected-components",option+1) == 0)
4446 if (i == (ssize_t) argc)
4447 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4448 if (IsGeometry(argv[i]) == MagickFalse)
4449 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4452 if (LocaleCompare(
"contrast",option+1) == 0)
4454 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
4457 if (i == (ssize_t) argc)
4458 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4459 if (IsGeometry(argv[i]) == MagickFalse)
4460 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4463 if (LocaleCompare(
"convolve",option+1) == 0)
4471 if (i == (ssize_t) argc)
4472 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4473 kernel_info=AcquireKernelInfo(argv[i]);
4474 if (kernel_info == (KernelInfo *) NULL)
4475 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4476 kernel_info=DestroyKernelInfo(kernel_info);
4479 if (LocaleCompare(
"copy",option+1) == 0)
4484 if (i == (ssize_t) argc)
4485 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4486 if (IsGeometry(argv[i]) == MagickFalse)
4487 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4489 if (i == (ssize_t) argc)
4490 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4491 if (IsGeometry(argv[i]) == MagickFalse)
4492 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4495 if (LocaleCompare(
"crop",option+1) == 0)
4500 if (i == (ssize_t) argc)
4501 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4502 if (IsGeometry(argv[i]) == MagickFalse)
4503 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4506 if (LocaleCompare(
"cycle",option+1) == 0)
4511 if (i == (ssize_t) argc)
4512 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4513 if (IsGeometry(argv[i]) == MagickFalse)
4514 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4517 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4521 if (LocaleCompare(
"decipher",option+1) == 0)
4526 if (i == (ssize_t) argc)
4527 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4530 if (LocaleCompare(
"deconstruct",option+1) == 0)
4532 if (LocaleCompare(
"debug",option+1) == 0)
4540 if (i == (ssize_t) argc)
4541 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4542 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4544 ThrowMogrifyException(OptionError,
"UnrecognizedEventType",
4546 (void) SetLogEventMask(argv[i]);
4549 if (LocaleCompare(
"define",option+1) == 0)
4552 if (i == (ssize_t) argc)
4553 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4559 define=GetImageOption(image_info,argv[i]);
4560 if (define == (
const char *) NULL)
4561 ThrowMogrifyException(OptionError,
"NoSuchOption",argv[i]);
4566 if (LocaleCompare(
"delay",option+1) == 0)
4571 if (i == (ssize_t) argc)
4572 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4573 if (IsGeometry(argv[i]) == MagickFalse)
4574 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4577 if (LocaleCompare(
"delete",option+1) == 0)
4582 if (i == (ssize_t) argc)
4583 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4584 if (LocaleNCompare(argv[i],
"registry:",9) == 0)
4586 (void) DeleteImageRegistry(argv[i]+9);
4589 if (IsGeometry(argv[i]) == MagickFalse)
4590 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4593 if (LocaleCompare(
"density",option+1) == 0)
4598 if (i == (ssize_t) argc)
4599 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4600 if (IsGeometry(argv[i]) == MagickFalse)
4601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4604 if (LocaleCompare(
"depth",option+1) == 0)
4609 if (i == (ssize_t) argc)
4610 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4611 if (IsGeometry(argv[i]) == MagickFalse)
4612 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4615 if (LocaleCompare(
"deskew",option+1) == 0)
4620 if (i == (ssize_t) argc)
4621 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4622 if (IsGeometry(argv[i]) == MagickFalse)
4623 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4626 if (LocaleCompare(
"despeckle",option+1) == 0)
4628 if (LocaleCompare(
"dft",option+1) == 0)
4630 if (LocaleCompare(
"direction",option+1) == 0)
4638 if (i == (ssize_t) argc)
4639 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4640 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4643 ThrowMogrifyException(OptionError,
"UnrecognizedDirectionType",
4647 if (LocaleCompare(
"display",option+1) == 0)
4652 if (i == (ssize_t) argc)
4653 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4656 if (LocaleCompare(
"dispose",option+1) == 0)
4664 if (i == (ssize_t) argc)
4665 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4666 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4669 ThrowMogrifyException(OptionError,
"UnrecognizedDisposeMethod",
4673 if (LocaleCompare(
"distort",option+1) == 0)
4679 if (i == (ssize_t) argc)
4680 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4681 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4683 ThrowMogrifyException(OptionError,
"UnrecognizedDistortMethod",
4686 if (i == (ssize_t) argc)
4687 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4690 if (LocaleCompare(
"dither",option+1) == 0)
4698 if (i == (ssize_t) argc)
4699 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4700 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4702 ThrowMogrifyException(OptionError,
"UnrecognizedDitherMethod",
4706 if (LocaleCompare(
"draw",option+1) == 0)
4711 if (i == (ssize_t) argc)
4712 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4715 if (LocaleCompare(
"duplicate",option+1) == 0)
4720 if (i == (ssize_t) argc)
4721 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4722 if (IsGeometry(argv[i]) == MagickFalse)
4723 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4726 if (LocaleCompare(
"duration",option+1) == 0)
4731 if (i == (ssize_t) argc)
4732 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4733 if (IsGeometry(argv[i]) == MagickFalse)
4734 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4737 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4741 if (LocaleCompare(
"edge",option+1) == 0)
4746 if (i == (ssize_t) argc)
4747 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4748 if (IsGeometry(argv[i]) == MagickFalse)
4749 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4752 if (LocaleCompare(
"emboss",option+1) == 0)
4757 if (i == (ssize_t) argc)
4758 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4759 if (IsGeometry(argv[i]) == MagickFalse)
4760 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4763 if (LocaleCompare(
"encipher",option+1) == 0)
4768 if (i == (ssize_t) argc)
4769 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4772 if (LocaleCompare(
"encoding",option+1) == 0)
4777 if (i == (ssize_t) argc)
4778 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4781 if (LocaleCompare(
"endian",option+1) == 0)
4789 if (i == (ssize_t) argc)
4790 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4791 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4793 ThrowMogrifyException(OptionError,
"UnrecognizedEndianType",
4797 if (LocaleCompare(
"enhance",option+1) == 0)
4799 if (LocaleCompare(
"equalize",option+1) == 0)
4801 if (LocaleCompare(
"evaluate",option+1) == 0)
4809 if (i == (ssize_t) argc)
4810 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4811 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4813 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4816 if (i == (ssize_t) argc)
4817 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4818 if (IsGeometry(argv[i]) == MagickFalse)
4819 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4822 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4830 if (i == (ssize_t) argc)
4831 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4832 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4834 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4838 if (LocaleCompare(
"extent",option+1) == 0)
4843 if (i == (ssize_t) argc)
4844 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4845 if (IsGeometry(argv[i]) == MagickFalse)
4846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4849 if (LocaleCompare(
"extract",option+1) == 0)
4854 if (i == (ssize_t) argc)
4855 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4856 if (IsGeometry(argv[i]) == MagickFalse)
4857 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4860 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4864 if (LocaleCompare(
"family",option+1) == 0)
4869 if (i == (ssize_t) argc)
4870 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4873 if (LocaleCompare(
"features",option+1) == 0)
4878 if (i == (ssize_t) argc)
4879 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4880 if (IsGeometry(argv[i]) == MagickFalse)
4881 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4884 if (LocaleCompare(
"fill",option+1) == 0)
4889 if (i == (ssize_t) argc)
4890 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4893 if (LocaleCompare(
"filter",option+1) == 0)
4901 if (i == (ssize_t) argc)
4902 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4903 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4905 ThrowMogrifyException(OptionError,
"UnrecognizedImageFilter",
4909 if (LocaleCompare(
"flatten",option+1) == 0)
4911 if (LocaleCompare(
"flip",option+1) == 0)
4913 if (LocaleCompare(
"flop",option+1) == 0)
4915 if (LocaleCompare(
"floodfill",option+1) == 0)
4920 if (i == (ssize_t) argc)
4921 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4922 if (IsGeometry(argv[i]) == MagickFalse)
4923 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4925 if (i == (ssize_t) argc)
4926 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4929 if (LocaleCompare(
"font",option+1) == 0)
4934 if (i == (ssize_t) argc)
4935 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4938 if (LocaleCompare(
"format",option+1) == 0)
4940 (void) CopyMagickString(argv[i]+1,
"sans",MaxTextExtent);
4941 (void) CloneString(&format,(
char *) NULL);
4945 if (i == (ssize_t) argc)
4946 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4947 (void) CloneString(&format,argv[i]);
4948 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4949 (void) ConcatenateMagickString(image_info->filename,
":",
4951 (void) SetImageInfo(image_info,0,exception);
4952 if (*image_info->magick ==
'\0')
4953 ThrowMogrifyException(OptionError,
"UnrecognizedImageFormat",
4957 if (LocaleCompare(
"frame",option+1) == 0)
4962 if (i == (ssize_t) argc)
4963 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4964 if (IsGeometry(argv[i]) == MagickFalse)
4965 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4968 if (LocaleCompare(
"function",option+1) == 0)
4976 if (i == (ssize_t) argc)
4977 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4978 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4980 ThrowMogrifyException(OptionError,
"UnrecognizedFunction",argv[i]);
4982 if (i == (ssize_t) argc)
4983 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4986 if (LocaleCompare(
"fuzz",option+1) == 0)
4991 if (i == (ssize_t) argc)
4992 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4993 if (IsGeometry(argv[i]) == MagickFalse)
4994 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4997 if (LocaleCompare(
"fx",option+1) == 0)
5002 if (i == (ssize_t) argc)
5003 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5006 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5010 if (LocaleCompare(
"gamma",option+1) == 0)
5013 if (i == (ssize_t) argc)
5014 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5015 if (IsGeometry(argv[i]) == MagickFalse)
5016 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5019 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
5020 (LocaleCompare(
"gaussian",option+1) == 0))
5023 if (i == (ssize_t) argc)
5024 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5025 if (IsGeometry(argv[i]) == MagickFalse)
5026 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5029 if (LocaleCompare(
"geometry",option+1) == 0)
5034 if (i == (ssize_t) argc)
5035 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5036 if (IsGeometry(argv[i]) == MagickFalse)
5037 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5040 if (LocaleCompare(
"gravity",option+1) == 0)
5048 if (i == (ssize_t) argc)
5049 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5050 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5053 ThrowMogrifyException(OptionError,
"UnrecognizedGravityType",
5057 if (LocaleCompare(
"grayscale",option+1) == 0)
5065 if (i == (ssize_t) argc)
5066 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5067 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5070 ThrowMogrifyException(OptionError,
"UnrecognizedIntensityMethod",
5074 if (LocaleCompare(
"green-primary",option+1) == 0)
5079 if (i == (ssize_t) argc)
5080 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5081 if (IsGeometry(argv[i]) == MagickFalse)
5082 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5085 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5089 if (LocaleCompare(
"hald-clut",option+1) == 0)
5091 if (LocaleCompare(
"hough-lines",option+1) == 0)
5096 if (i == (ssize_t) argc)
5097 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5098 if (IsGeometry(argv[i]) == MagickFalse)
5099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5102 if ((LocaleCompare(
"help",option+1) == 0) ||
5103 (LocaleCompare(
"-help",option+1) == 0))
5106 return(MogrifyUsage());
5108 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5112 if (LocaleCompare(
"identify",option+1) == 0)
5114 if (LocaleCompare(
"idft",option+1) == 0)
5116 if (LocaleCompare(
"implode",option+1) == 0)
5121 if (i == (ssize_t) argc)
5122 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5123 if (IsGeometry(argv[i]) == MagickFalse)
5124 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5127 if (LocaleCompare(
"intensity",option+1) == 0)
5135 if (i == (ssize_t) argc)
5136 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5137 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5138 MagickFalse,argv[i]);
5140 ThrowMogrifyException(OptionError,
5141 "UnrecognizedPixelIntensityMethod",argv[i]);
5144 if (LocaleCompare(
"intent",option+1) == 0)
5152 if (i == (ssize_t) argc)
5153 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5154 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5156 ThrowMogrifyException(OptionError,
"UnrecognizedIntentType",
5160 if (LocaleCompare(
"interlace",option+1) == 0)
5168 if (i == (ssize_t) argc)
5169 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5170 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5173 ThrowMogrifyException(OptionError,
"UnrecognizedInterlaceType",
5177 if (LocaleCompare(
"interline-spacing",option+1) == 0)
5182 if (i == (ssize_t) argc)
5183 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5184 if (IsGeometry(argv[i]) == MagickFalse)
5185 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5188 if (LocaleCompare(
"interpolate",option+1) == 0)
5196 if (i == (ssize_t) argc)
5197 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5198 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5200 if (interpolate < 0)
5201 ThrowMogrifyException(OptionError,
"UnrecognizedInterpolateMethod",
5205 if (LocaleCompare(
"interword-spacing",option+1) == 0)
5210 if (i == (ssize_t) argc)
5211 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5212 if (IsGeometry(argv[i]) == MagickFalse)
5213 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5216 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5220 if (LocaleCompare(
"kerning",option+1) == 0)
5225 if (i == (ssize_t) argc)
5226 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5227 if (IsGeometry(argv[i]) == MagickFalse)
5228 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5231 if (LocaleCompare(
"kuwahara",option+1) == 0)
5234 if (i == (ssize_t) argc)
5235 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5236 if (IsGeometry(argv[i]) == MagickFalse)
5237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5240 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5244 if (LocaleCompare(
"label",option+1) == 0)
5249 if (i == (ssize_t) argc)
5250 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5253 if (LocaleCompare(
"lat",option+1) == 0)
5258 if (i == (ssize_t) argc)
5259 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5260 if (IsGeometry(argv[i]) == MagickFalse)
5261 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5264 if (LocaleCompare(
"layers",option+1) == 0)
5272 if (i == (ssize_t) argc)
5273 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5274 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5276 ThrowMogrifyException(OptionError,
"UnrecognizedLayerMethod",
5280 if (LocaleCompare(
"level",option+1) == 0)
5283 if (i == (ssize_t) argc)
5284 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5285 if (IsGeometry(argv[i]) == MagickFalse)
5286 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5289 if (LocaleCompare(
"level-colors",option+1) == 0)
5292 if (i == (ssize_t) argc)
5293 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5296 if (LocaleCompare(
"linewidth",option+1) == 0)
5301 if (i == (ssize_t) argc)
5302 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5303 if (IsGeometry(argv[i]) == MagickFalse)
5304 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5307 if (LocaleCompare(
"limit",option+1) == 0)
5321 if (i == (ssize_t) argc)
5322 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5323 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5326 ThrowMogrifyException(OptionError,
"UnrecognizedResourceType",
5329 if (i == (ssize_t) argc)
5330 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5331 value=StringToDouble(argv[i],&p);
5333 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
5334 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5337 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
5340 if (i == (ssize_t) argc)
5341 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5342 if (IsGeometry(argv[i]) == MagickFalse)
5343 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5346 if (LocaleCompare(
"list",option+1) == 0)
5354 if (i == (ssize_t) argc)
5355 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5356 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5358 ThrowMogrifyException(OptionError,
"UnrecognizedListType",argv[i]);
5359 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
5361 return(status == 0 ? MagickFalse : MagickTrue);
5363 if (LocaleCompare(
"local-contrast",option+1) == 0)
5366 if (i == (ssize_t) argc)
5367 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5368 if (IsGeometry(argv[i]) == MagickFalse)
5369 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5372 if (LocaleCompare(
"log",option+1) == 0)
5377 if ((i == (ssize_t) argc) ||
5378 (strchr(argv[i],
'%') == (
char *) NULL))
5379 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5382 if (LocaleCompare(
"loop",option+1) == 0)
5387 if (i == (ssize_t) argc)
5388 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5389 if (IsGeometry(argv[i]) == MagickFalse)
5390 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5393 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5397 if (LocaleCompare(
"magnify",option+1) == 0)
5399 if (LocaleCompare(
"map",option+1) == 0)
5401 global_colormap=(*option ==
'+') ? MagickTrue : MagickFalse;
5405 if (i == (ssize_t) argc)
5406 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5409 if (LocaleCompare(
"mask",option+1) == 0)
5414 if (i == (ssize_t) argc)
5415 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5418 if (LocaleCompare(
"matte",option+1) == 0)
5420 if (LocaleCompare(
"mattecolor",option+1) == 0)
5425 if (i == (ssize_t) argc)
5426 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5429 if (LocaleCompare(
"metric",option+1) == 0)
5437 if (i == (ssize_t) argc)
5438 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5439 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5441 ThrowMogrifyException(OptionError,
"UnrecognizedMetricType",
5445 if (LocaleCompare(
"maximum",option+1) == 0)
5447 if (LocaleCompare(
"mean-shift",option+1) == 0)
5452 if (i == (ssize_t) argc)
5453 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5454 if (IsGeometry(argv[i]) == MagickFalse)
5455 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5458 if (LocaleCompare(
"median",option+1) == 0)
5463 if (i == (ssize_t) argc)
5464 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5465 if (IsGeometry(argv[i]) == MagickFalse)
5466 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5469 if (LocaleCompare(
"minimum",option+1) == 0)
5471 if (LocaleCompare(
"modulate",option+1) == 0)
5476 if (i == (ssize_t) argc)
5477 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5478 if (IsGeometry(argv[i]) == MagickFalse)
5479 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5482 if (LocaleCompare(
"mode",option+1) == 0)
5487 if (i == (ssize_t) argc)
5488 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5489 if (IsGeometry(argv[i]) == MagickFalse)
5490 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5493 if (LocaleCompare(
"monitor",option+1) == 0)
5495 if (LocaleCompare(
"monochrome",option+1) == 0)
5497 if (LocaleCompare(
"morph",option+1) == 0)
5502 if (i == (ssize_t) argc)
5503 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5504 if (IsGeometry(argv[i]) == MagickFalse)
5505 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5508 if (LocaleCompare(
"morphology",option+1) == 0)
5511 token[MaxTextExtent];
5520 if (i == (ssize_t) argc)
5521 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5522 (void) GetNextToken(argv[i],(
const char **) NULL,MaxTextExtent,token);
5523 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5525 ThrowMogrifyException(OptionError,
"UnrecognizedMorphologyMethod",
5528 if (i == (ssize_t) argc)
5529 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5530 kernel_info=AcquireKernelInfo(argv[i]);
5531 if (kernel_info == (KernelInfo *) NULL)
5532 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5533 kernel_info=DestroyKernelInfo(kernel_info);
5536 if (LocaleCompare(
"mosaic",option+1) == 0)
5538 if (LocaleCompare(
"motion-blur",option+1) == 0)
5543 if (i == (ssize_t) argc)
5544 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5545 if (IsGeometry(argv[i]) == MagickFalse)
5546 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5549 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5553 if (LocaleCompare(
"negate",option+1) == 0)
5555 if (LocaleCompare(
"noise",option+1) == 0)
5558 if (i == (ssize_t) argc)
5559 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5565 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5567 ThrowMogrifyException(OptionError,
"UnrecognizedNoiseType",
5571 if (IsGeometry(argv[i]) == MagickFalse)
5572 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5575 if (LocaleCompare(
"noop",option+1) == 0)
5577 if (LocaleCompare(
"normalize",option+1) == 0)
5579 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5583 if (LocaleCompare(
"opaque",option+1) == 0)
5586 if (i == (ssize_t) argc)
5587 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5590 if (LocaleCompare(
"ordered-dither",option+1) == 0)
5595 if (i == (ssize_t) argc)
5596 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5599 if (LocaleCompare(
"orient",option+1) == 0)
5604 orientation=UndefinedOrientation;
5608 if (i == (ssize_t) argc)
5609 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5610 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5612 if (orientation < 0)
5613 ThrowMogrifyException(OptionError,
"UnrecognizedImageOrientation",
5617 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5621 if (LocaleCompare(
"page",option+1) == 0)
5626 if (i == (ssize_t) argc)
5627 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5630 if (LocaleCompare(
"paint",option+1) == 0)
5635 if (i == (ssize_t) argc)
5636 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5637 if (IsGeometry(argv[i]) == MagickFalse)
5638 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5641 if (LocaleCompare(
"path",option+1) == 0)
5643 (void) CloneString(&path,(
char *) NULL);
5647 if (i == (ssize_t) argc)
5648 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5649 (void) CloneString(&path,argv[i]);
5652 if (LocaleCompare(
"perceptible",option+1) == 0)
5657 if (i == (ssize_t) argc)
5658 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5659 if (IsGeometry(argv[i]) == MagickFalse)
5660 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5663 if (LocaleCompare(
"pointsize",option+1) == 0)
5668 if (i == (ssize_t) argc)
5669 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5670 if (IsGeometry(argv[i]) == MagickFalse)
5671 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5674 if (LocaleCompare(
"polaroid",option+1) == 0)
5679 if (i == (ssize_t) argc)
5680 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5681 if (IsGeometry(argv[i]) == MagickFalse)
5682 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5685 if (LocaleCompare(
"poly",option+1) == 0)
5690 if (i == (ssize_t) argc)
5691 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5692 if (IsGeometry(argv[i]) == MagickFalse)
5693 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5696 if (LocaleCompare(
"posterize",option+1) == 0)
5701 if (i == (ssize_t) argc)
5702 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5703 if (IsGeometry(argv[i]) == MagickFalse)
5704 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5707 if (LocaleCompare(
"precision",option+1) == 0)
5712 if (i == (ssize_t) argc)
5713 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5714 if (IsGeometry(argv[i]) == MagickFalse)
5715 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5718 if (LocaleCompare(
"print",option+1) == 0)
5723 if (i == (ssize_t) argc)
5724 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5727 if (LocaleCompare(
"process",option+1) == 0)
5732 if (i == (ssize_t) argc)
5733 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5736 if (LocaleCompare(
"profile",option+1) == 0)
5739 if (i == (ssize_t) argc)
5740 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5743 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5747 if (LocaleCompare(
"quality",option+1) == 0)
5752 if (i == (ssize_t) argc)
5753 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5754 if (IsGeometry(argv[i]) == MagickFalse)
5755 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5758 if (LocaleCompare(
"quantize",option+1) == 0)
5766 if (i == (ssize_t) argc)
5767 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5768 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5771 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
5775 if (LocaleCompare(
"quiet",option+1) == 0)
5777 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5781 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
5782 LocaleCompare(
"rotational-blur",option+1) == 0)
5785 if (i == (ssize_t) argc)
5786 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5787 if (IsGeometry(argv[i]) == MagickFalse)
5788 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5791 if (LocaleCompare(
"raise",option+1) == 0)
5794 if (i == (ssize_t) argc)
5795 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5796 if (IsGeometry(argv[i]) == MagickFalse)
5797 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5800 if (LocaleCompare(
"random-threshold",option+1) == 0)
5805 if (i == (ssize_t) argc)
5806 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5807 if (IsGeometry(argv[i]) == MagickFalse)
5808 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5811 if (LocaleCompare(
"recolor",option+1) == 0)
5816 if (i == (ssize_t) argc)
5817 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5818 if (IsGeometry(argv[i]) == MagickFalse)
5819 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5822 if (LocaleCompare(
"red-primary",option+1) == 0)
5827 if (i == (ssize_t) argc)
5828 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5829 if (IsGeometry(argv[i]) == MagickFalse)
5830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5832 if (LocaleCompare(
"regard-warnings",option+1) == 0)
5834 if (LocaleCompare(
"region",option+1) == 0)
5839 if (i == (ssize_t) argc)
5840 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5841 if (IsGeometry(argv[i]) == MagickFalse)
5842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5845 if (LocaleCompare(
"remap",option+1) == 0)
5850 if (i == (ssize_t) argc)
5851 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5854 if (LocaleCompare(
"render",option+1) == 0)
5856 if (LocaleCompare(
"repage",option+1) == 0)
5861 if (i == (ssize_t) argc)
5862 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5863 if (IsGeometry(argv[i]) == MagickFalse)
5864 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5867 if (LocaleCompare(
"resample",option+1) == 0)
5872 if (i == (ssize_t) argc)
5873 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5874 if (IsGeometry(argv[i]) == MagickFalse)
5875 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5878 if (LocaleCompare(
"resize",option+1) == 0)
5883 if (i == (ssize_t) argc)
5884 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5885 if (IsGeometry(argv[i]) == MagickFalse)
5886 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5889 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
5891 respect_parenthesis=(*option ==
'-') ? MagickTrue : MagickFalse;
5894 if (LocaleCompare(
"reverse",option+1) == 0)
5896 if (LocaleCompare(
"roll",option+1) == 0)
5901 if (i == (ssize_t) argc)
5902 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5903 if (IsGeometry(argv[i]) == MagickFalse)
5904 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5907 if (LocaleCompare(
"rotate",option+1) == 0)
5910 if (i == (ssize_t) argc)
5911 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5912 if (IsGeometry(argv[i]) == MagickFalse)
5913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5916 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5920 if (LocaleCompare(
"sample",option+1) == 0)
5925 if (i == (ssize_t) argc)
5926 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5927 if (IsGeometry(argv[i]) == MagickFalse)
5928 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5931 if (LocaleCompare(
"sampling-factor",option+1) == 0)
5936 if (i == (ssize_t) argc)
5937 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5938 if (IsGeometry(argv[i]) == MagickFalse)
5939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5942 if (LocaleCompare(
"scale",option+1) == 0)
5947 if (i == (ssize_t) argc)
5948 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5949 if (IsGeometry(argv[i]) == MagickFalse)
5950 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5953 if (LocaleCompare(
"scene",option+1) == 0)
5958 if (i == (ssize_t) argc)
5959 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5960 if (IsGeometry(argv[i]) == MagickFalse)
5961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5964 if (LocaleCompare(
"seed",option+1) == 0)
5969 if (i == (ssize_t) argc)
5970 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5971 if (IsGeometry(argv[i]) == MagickFalse)
5972 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5975 if (LocaleCompare(
"segment",option+1) == 0)
5980 if (i == (ssize_t) argc)
5981 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5982 if (IsGeometry(argv[i]) == MagickFalse)
5983 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5986 if (LocaleCompare(
"selective-blur",option+1) == 0)
5989 if (i == (ssize_t) argc)
5990 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5991 if (IsGeometry(argv[i]) == MagickFalse)
5992 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5995 if (LocaleCompare(
"separate",option+1) == 0)
5997 if (LocaleCompare(
"sepia-tone",option+1) == 0)
6002 if (i == (ssize_t) argc)
6003 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6004 if (IsGeometry(argv[i]) == MagickFalse)
6005 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6008 if (LocaleCompare(
"set",option+1) == 0)
6011 if (i == (ssize_t) argc)
6012 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6016 if (i == (ssize_t) argc)
6017 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6020 if (LocaleCompare(
"shade",option+1) == 0)
6023 if (i == (ssize_t) argc)
6024 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6025 if (IsGeometry(argv[i]) == MagickFalse)
6026 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6029 if (LocaleCompare(
"shadow",option+1) == 0)
6034 if (i == (ssize_t) argc)
6035 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6036 if (IsGeometry(argv[i]) == MagickFalse)
6037 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6040 if (LocaleCompare(
"sharpen",option+1) == 0)
6043 if (i == (ssize_t) argc)
6044 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6045 if (IsGeometry(argv[i]) == MagickFalse)
6046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6049 if (LocaleCompare(
"shave",option+1) == 0)
6054 if (i == (ssize_t) argc)
6055 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6056 if (IsGeometry(argv[i]) == MagickFalse)
6057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6060 if (LocaleCompare(
"shear",option+1) == 0)
6063 if (i == (ssize_t) argc)
6064 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6065 if (IsGeometry(argv[i]) == MagickFalse)
6066 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6069 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
6072 if (i == (ssize_t) argc)
6073 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6074 if (IsGeometry(argv[i]) == MagickFalse)
6075 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6078 if (LocaleCompare(
"size",option+1) == 0)
6083 if (i == (ssize_t) argc)
6084 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6085 if (IsGeometry(argv[i]) == MagickFalse)
6086 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6089 if (LocaleCompare(
"sketch",option+1) == 0)
6094 if (i == (ssize_t) argc)
6095 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6096 if (IsGeometry(argv[i]) == MagickFalse)
6097 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6100 if (LocaleCompare(
"smush",option+1) == 0)
6103 if (i == (ssize_t) argc)
6104 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6105 if (IsGeometry(argv[i]) == MagickFalse)
6106 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6110 if (LocaleCompare(
"solarize",option+1) == 0)
6115 if (i == (ssize_t) argc)
6116 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6117 if (IsGeometry(argv[i]) == MagickFalse)
6118 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6121 if (LocaleCompare(
"sparse-color",option+1) == 0)
6127 if (i == (ssize_t) argc)
6128 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6129 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6131 ThrowMogrifyException(OptionError,
"UnrecognizedSparseColorMethod",
6134 if (i == (ssize_t) argc)
6135 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6138 if (LocaleCompare(
"splice",option+1) == 0)
6143 if (i == (ssize_t) argc)
6144 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6145 if (IsGeometry(argv[i]) == MagickFalse)
6146 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6149 if (LocaleCompare(
"spread",option+1) == 0)
6154 if (i == (ssize_t) argc)
6155 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6156 if (IsGeometry(argv[i]) == MagickFalse)
6157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6160 if (LocaleCompare(
"statistic",option+1) == 0)
6168 if (i == (ssize_t) argc)
6169 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6170 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6172 ThrowMogrifyException(OptionError,
"UnrecognizedStatisticType",
6175 if (i == (ssize_t) argc)
6176 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6177 if (IsGeometry(argv[i]) == MagickFalse)
6178 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6181 if (LocaleCompare(
"stretch",option+1) == 0)
6189 if (i == (ssize_t) argc)
6190 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6191 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
6193 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6197 if (LocaleCompare(
"strip",option+1) == 0)
6199 if (LocaleCompare(
"stroke",option+1) == 0)
6204 if (i == (ssize_t) argc)
6205 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6208 if (LocaleCompare(
"strokewidth",option+1) == 0)
6213 if (i == (ssize_t) argc)
6214 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6215 if (IsGeometry(argv[i]) == MagickFalse)
6216 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6219 if (LocaleCompare(
"style",option+1) == 0)
6227 if (i == (ssize_t) argc)
6228 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6229 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6231 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6235 if (LocaleCompare(
"swap",option+1) == 0)
6240 if (i == (ssize_t) argc)
6241 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6242 if (IsGeometry(argv[i]) == MagickFalse)
6243 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6246 if (LocaleCompare(
"swirl",option+1) == 0)
6251 if (i == (ssize_t) argc)
6252 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6253 if (IsGeometry(argv[i]) == MagickFalse)
6254 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6257 if (LocaleCompare(
"synchronize",option+1) == 0)
6259 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6263 if (LocaleCompare(
"taint",option+1) == 0)
6265 if (LocaleCompare(
"texture",option+1) == 0)
6270 if (i == (ssize_t) argc)
6271 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6274 if (LocaleCompare(
"tile",option+1) == 0)
6279 if (i == (ssize_t) argc)
6280 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6283 if (LocaleCompare(
"tile-offset",option+1) == 0)
6288 if (i == (ssize_t) argc)
6289 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6290 if (IsGeometry(argv[i]) == MagickFalse)
6291 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6294 if (LocaleCompare(
"tint",option+1) == 0)
6299 if (i == (ssize_t) argc)
6300 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6301 if (IsGeometry(argv[i]) == MagickFalse)
6302 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6305 if (LocaleCompare(
"transform",option+1) == 0)
6307 if (LocaleCompare(
"transpose",option+1) == 0)
6309 if (LocaleCompare(
"transverse",option+1) == 0)
6311 if (LocaleCompare(
"threshold",option+1) == 0)
6316 if (i == (ssize_t) argc)
6317 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6318 if (IsGeometry(argv[i]) == MagickFalse)
6319 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6322 if (LocaleCompare(
"thumbnail",option+1) == 0)
6327 if (i == (ssize_t) argc)
6328 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6329 if (IsGeometry(argv[i]) == MagickFalse)
6330 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6333 if (LocaleCompare(
"transparent",option+1) == 0)
6336 if (i == (ssize_t) argc)
6337 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6340 if (LocaleCompare(
"transparent-color",option+1) == 0)
6345 if (i == (ssize_t) argc)
6346 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6349 if (LocaleCompare(
"treedepth",option+1) == 0)
6354 if (i == (ssize_t) argc)
6355 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6356 if (IsGeometry(argv[i]) == MagickFalse)
6357 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6360 if (LocaleCompare(
"trim",option+1) == 0)
6362 if (LocaleCompare(
"type",option+1) == 0)
6370 if (i == (ssize_t) argc)
6371 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6372 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6374 ThrowMogrifyException(OptionError,
"UnrecognizedImageType",
6378 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6382 if (LocaleCompare(
"undercolor",option+1) == 0)
6387 if (i == (ssize_t) argc)
6388 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6391 if (LocaleCompare(
"unique-colors",option+1) == 0)
6393 if (LocaleCompare(
"units",option+1) == 0)
6401 if (i == (ssize_t) argc)
6402 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6403 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6406 ThrowMogrifyException(OptionError,
"UnrecognizedUnitsType",
6410 if (LocaleCompare(
"unsharp",option+1) == 0)
6413 if (i == (ssize_t) argc)
6414 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6415 if (IsGeometry(argv[i]) == MagickFalse)
6416 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6419 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6423 if (LocaleCompare(
"verbose",option+1) == 0)
6425 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
6428 if ((LocaleCompare(
"version",option+1) == 0) ||
6429 (LocaleCompare(
"-version",option+1) == 0))
6431 ListMagickVersion(stdout);
6434 if (LocaleCompare(
"view",option+1) == 0)
6439 if (i == (ssize_t) argc)
6440 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6443 if (LocaleCompare(
"vignette",option+1) == 0)
6448 if (i == (ssize_t) argc)
6449 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6450 if (IsGeometry(argv[i]) == MagickFalse)
6451 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6454 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
6462 if (i == (ssize_t) argc)
6463 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6464 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6467 ThrowMogrifyException(OptionError,
6468 "UnrecognizedVirtualPixelMethod",argv[i]);
6471 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6475 if (LocaleCompare(
"wave",option+1) == 0)
6478 if (i == (ssize_t) argc)
6479 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6480 if (IsGeometry(argv[i]) == MagickFalse)
6481 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6484 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
6487 if (i == (ssize_t) argc)
6488 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6489 if (IsGeometry(argv[i]) == MagickFalse)
6490 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6493 if (LocaleCompare(
"weight",option+1) == 0)
6498 if (i == (ssize_t) argc)
6499 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6502 if (LocaleCompare(
"white-point",option+1) == 0)
6507 if (i == (ssize_t) argc)
6508 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6509 if (IsGeometry(argv[i]) == MagickFalse)
6510 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6513 if (LocaleCompare(
"white-threshold",option+1) == 0)
6518 if (i == (ssize_t) argc)
6519 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6520 if (IsGeometry(argv[i]) == MagickFalse)
6521 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6524 if (LocaleCompare(
"write",option+1) == 0)
6527 if (i == (ssize_t) argc)
6528 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6531 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6536 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6538 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6539 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6540 if (fire != MagickFalse)
6541 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6544 ThrowMogrifyException(OptionError,
"UnbalancedParenthesis",argv[i]);
6545 if (i != (ssize_t) argc)
6546 ThrowMogrifyException(OptionError,
"MissingAnImageFilename",argv[i]);
6548 return(status != 0 ? MagickTrue : MagickFalse);
6583 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6584 const int argc,
const char **argv,ExceptionInfo *exception)
6601 assert(image_info != (ImageInfo *) NULL);
6602 assert(image_info->signature == MagickCoreSignature);
6603 if (IsEventLogging() != MagickFalse)
6604 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
6605 image_info->filename);
6611 for (i=0; i < (ssize_t) argc; i++)
6614 if (IsCommandOption(option) == MagickFalse)
6616 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6617 count=MagickMax(count,0L);
6618 if ((i+count) >= (ssize_t) argc)
6620 switch (*(option+1))
6624 if (LocaleCompare(
"adjoin",option+1) == 0)
6626 image_info->adjoin=(*option ==
'-') ? MagickTrue : MagickFalse;
6629 if (LocaleCompare(
"antialias",option+1) == 0)
6631 image_info->antialias=(*option ==
'-') ? MagickTrue : MagickFalse;
6634 if (LocaleCompare(
"attenuate",option+1) == 0)
6638 (void) DeleteImageOption(image_info,option+1);
6641 (void) SetImageOption(image_info,option+1,argv[i+1]);
6644 if (LocaleCompare(
"authenticate",option+1) == 0)
6647 (void) CloneString(&image_info->authenticate,(
char *) NULL);
6649 (
void) CloneString(&image_info->authenticate,argv[i+1]);
6656 if (LocaleCompare(
"background",option+1) == 0)
6660 (void) DeleteImageOption(image_info,option+1);
6661 (void) QueryColorDatabase(MogrifyBackgroundColor,
6662 &image_info->background_color,exception);
6665 (void) SetImageOption(image_info,option+1,argv[i+1]);
6666 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6670 if (LocaleCompare(
"bias",option+1) == 0)
6674 (void) SetImageOption(image_info,option+1,
"0.0");
6677 (void) SetImageOption(image_info,option+1,argv[i+1]);
6680 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
6684 (void) SetImageOption(image_info,option+1,
"false");
6687 (void) SetImageOption(image_info,option+1,
"true");
6690 if (LocaleCompare(
"blue-primary",option+1) == 0)
6694 (void) SetImageOption(image_info,option+1,
"0.0");
6697 (void) SetImageOption(image_info,option+1,argv[i+1]);
6700 if (LocaleCompare(
"bordercolor",option+1) == 0)
6704 (void) DeleteImageOption(image_info,option+1);
6705 (void) QueryColorDatabase(MogrifyBorderColor,
6706 &image_info->border_color,exception);
6709 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6711 (void) SetImageOption(image_info,option+1,argv[i+1]);
6714 if (LocaleCompare(
"box",option+1) == 0)
6718 (void) SetImageOption(image_info,
"undercolor",
"none");
6721 (void) SetImageOption(image_info,
"undercolor",argv[i+1]);
6728 if (LocaleCompare(
"cache",option+1) == 0)
6733 limit=MagickResourceInfinity;
6734 if (LocaleCompare(
"unlimited",argv[i+1]) != 0)
6735 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],100.0);
6736 (void) SetMagickResourceLimit(MemoryResource,limit);
6737 (void) SetMagickResourceLimit(MapResource,2*limit);
6740 if (LocaleCompare(
"caption",option+1) == 0)
6744 (void) DeleteImageOption(image_info,option+1);
6747 (void) SetImageOption(image_info,option+1,argv[i+1]);
6750 if (LocaleCompare(
"channel",option+1) == 0)
6754 image_info->channel=DefaultChannels;
6757 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6760 if (LocaleCompare(
"colors",option+1) == 0)
6762 image_info->colors=StringToUnsignedLong(argv[i+1]);
6765 if (LocaleCompare(
"colorspace",option+1) == 0)
6769 image_info->colorspace=UndefinedColorspace;
6770 (void) SetImageOption(image_info,option+1,
"undefined");
6773 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6774 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6775 (void) SetImageOption(image_info,option+1,argv[i+1]);
6778 if (LocaleCompare(
"comment",option+1) == 0)
6782 (void) DeleteImageOption(image_info,option+1);
6785 (void) SetImageOption(image_info,option+1,argv[i+1]);
6788 if (LocaleCompare(
"compose",option+1) == 0)
6792 (void) SetImageOption(image_info,option+1,
"undefined");
6795 (void) SetImageOption(image_info,option+1,argv[i+1]);
6798 if (LocaleCompare(
"compress",option+1) == 0)
6802 image_info->compression=UndefinedCompression;
6803 (void) SetImageOption(image_info,option+1,
"undefined");
6806 image_info->compression=(CompressionType) ParseCommandOption(
6807 MagickCompressOptions,MagickFalse,argv[i+1]);
6808 (void) SetImageOption(image_info,option+1,argv[i+1]);
6815 if (LocaleCompare(
"debug",option+1) == 0)
6818 (void) SetLogEventMask(
"none");
6820 (
void) SetLogEventMask(argv[i+1]);
6821 image_info->debug=IsEventLogging();
6824 if (LocaleCompare(
"define",option+1) == 0)
6828 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6829 (void) DeleteImageRegistry(argv[i+1]+9);
6831 (
void) DeleteImageOption(image_info,argv[i+1]);
6834 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6836 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6840 (void) DefineImageOption(image_info,argv[i+1]);
6843 if (LocaleCompare(
"delay",option+1) == 0)
6847 (void) SetImageOption(image_info,option+1,
"0");
6850 (void) SetImageOption(image_info,option+1,argv[i+1]);
6853 if (LocaleCompare(
"density",option+1) == 0)
6860 if (image_info->density != (
char *) NULL)
6861 image_info->density=DestroyString(image_info->density);
6862 (void) SetImageOption(image_info,option+1,
"72");
6865 (void) CloneString(&image_info->density,argv[i+1]);
6866 (void) SetImageOption(image_info,option+1,argv[i+1]);
6869 if (LocaleCompare(
"depth",option+1) == 0)
6873 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6876 image_info->depth=StringToUnsignedLong(argv[i+1]);
6879 if (LocaleCompare(
"direction",option+1) == 0)
6883 (void) SetImageOption(image_info,option+1,
"undefined");
6886 (void) SetImageOption(image_info,option+1,argv[i+1]);
6889 if (LocaleCompare(
"display",option+1) == 0)
6893 if (image_info->server_name != (
char *) NULL)
6894 image_info->server_name=DestroyString(
6895 image_info->server_name);
6898 (void) CloneString(&image_info->server_name,argv[i+1]);
6901 if (LocaleCompare(
"dispose",option+1) == 0)
6905 (void) SetImageOption(image_info,option+1,
"undefined");
6908 (void) SetImageOption(image_info,option+1,argv[i+1]);
6911 if (LocaleCompare(
"dither",option+1) == 0)
6915 image_info->dither=MagickFalse;
6916 (void) SetImageOption(image_info,option+1,
"none");
6919 (void) SetImageOption(image_info,option+1,argv[i+1]);
6920 image_info->dither=MagickTrue;
6927 if (LocaleCompare(
"encoding",option+1) == 0)
6931 (void) SetImageOption(image_info,option+1,
"undefined");
6934 (void) SetImageOption(image_info,option+1,argv[i+1]);
6937 if (LocaleCompare(
"endian",option+1) == 0)
6941 image_info->endian=UndefinedEndian;
6942 (void) SetImageOption(image_info,option+1,
"undefined");
6945 image_info->endian=(EndianType) ParseCommandOption(
6946 MagickEndianOptions,MagickFalse,argv[i+1]);
6947 (void) SetImageOption(image_info,option+1,argv[i+1]);
6950 if (LocaleCompare(
"extract",option+1) == 0)
6957 if (image_info->extract != (
char *) NULL)
6958 image_info->extract=DestroyString(image_info->extract);
6961 (void) CloneString(&image_info->extract,argv[i+1]);
6968 if (LocaleCompare(
"family",option+1) == 0)
6971 (void) SetImageOption(image_info,option+1,argv[i+1]);
6974 if (LocaleCompare(
"fill",option+1) == 0)
6978 (void) SetImageOption(image_info,option+1,
"none");
6981 (void) SetImageOption(image_info,option+1,argv[i+1]);
6984 if (LocaleCompare(
"filter",option+1) == 0)
6988 (void) SetImageOption(image_info,option+1,
"undefined");
6991 (void) SetImageOption(image_info,option+1,argv[i+1]);
6994 if (LocaleCompare(
"font",option+1) == 0)
6998 if (image_info->font != (
char *) NULL)
6999 image_info->font=DestroyString(image_info->font);
7002 (void) CloneString(&image_info->font,argv[i+1]);
7005 if (LocaleCompare(
"format",option+1) == 0)
7007 (void) SetImageOption(image_info,option+1,argv[i+1]);
7010 if (LocaleCompare(
"fuzz",option+1) == 0)
7014 image_info->fuzz=0.0;
7015 (void) SetImageOption(image_info,option+1,
"0");
7018 image_info->fuzz=StringToDoubleInterval(argv[i+1],(
double)
7020 (void) SetImageOption(image_info,option+1,argv[i+1]);
7027 if (LocaleCompare(
"gravity",option+1) == 0)
7031 (void) SetImageOption(image_info,option+1,
"undefined");
7034 (void) SetImageOption(image_info,option+1,argv[i+1]);
7037 if (LocaleCompare(
"green-primary",option+1) == 0)
7041 (void) SetImageOption(image_info,option+1,
"0.0");
7044 (void) SetImageOption(image_info,option+1,argv[i+1]);
7051 if (LocaleCompare(
"intensity",option+1) == 0)
7055 (void) SetImageOption(image_info,option+1,
"undefined");
7058 (void) SetImageOption(image_info,option+1,argv[i+1]);
7061 if (LocaleCompare(
"intent",option+1) == 0)
7065 (void) SetImageOption(image_info,option+1,
"undefined");
7068 (void) SetImageOption(image_info,option+1,argv[i+1]);
7071 if (LocaleCompare(
"interlace",option+1) == 0)
7075 image_info->interlace=UndefinedInterlace;
7076 (void) SetImageOption(image_info,option+1,
"undefined");
7079 image_info->interlace=(InterlaceType) ParseCommandOption(
7080 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7081 (void) SetImageOption(image_info,option+1,argv[i+1]);
7084 if (LocaleCompare(
"interline-spacing",option+1) == 0)
7088 (void) SetImageOption(image_info,option+1,
"undefined");
7091 (void) SetImageOption(image_info,option+1,argv[i+1]);
7094 if (LocaleCompare(
"interpolate",option+1) == 0)
7098 (void) SetImageOption(image_info,option+1,
"undefined");
7101 (void) SetImageOption(image_info,option+1,argv[i+1]);
7104 if (LocaleCompare(
"interword-spacing",option+1) == 0)
7108 (void) SetImageOption(image_info,option+1,
"undefined");
7111 (void) SetImageOption(image_info,option+1,argv[i+1]);
7118 if (LocaleCompare(
"kerning",option+1) == 0)
7122 (void) SetImageOption(image_info,option+1,
"undefined");
7125 (void) SetImageOption(image_info,option+1,argv[i+1]);
7132 if (LocaleCompare(
"label",option+1) == 0)
7136 (void) DeleteImageOption(image_info,option+1);
7139 (void) SetImageOption(image_info,option+1,argv[i+1]);
7142 if (LocaleCompare(
"limit",option+1) == 0)
7152 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7153 MagickFalse,argv[i+1]);
7154 limit=MagickResourceInfinity;
7155 if (LocaleCompare(
"unlimited",argv[i+2]) != 0)
7156 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7157 (void) SetMagickResourceLimit(type,limit);
7160 if (LocaleCompare(
"list",option+1) == 0)
7168 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7171 case MagickCoderOptions:
7173 (void) ListCoderInfo((FILE *) NULL,exception);
7176 case MagickColorOptions:
7178 (void) ListColorInfo((FILE *) NULL,exception);
7181 case MagickConfigureOptions:
7183 (void) ListConfigureInfo((FILE *) NULL,exception);
7186 case MagickDelegateOptions:
7188 (void) ListDelegateInfo((FILE *) NULL,exception);
7191 case MagickFontOptions:
7193 (void) ListTypeInfo((FILE *) NULL,exception);
7196 case MagickFormatOptions:
7198 (void) ListMagickInfo((FILE *) NULL,exception);
7201 case MagickLocaleOptions:
7203 (void) ListLocaleInfo((FILE *) NULL,exception);
7206 case MagickLogOptions:
7208 (void) ListLogInfo((FILE *) NULL,exception);
7211 case MagickMagicOptions:
7213 (void) ListMagicInfo((FILE *) NULL,exception);
7216 case MagickMimeOptions:
7218 (void) ListMimeInfo((FILE *) NULL,exception);
7221 case MagickModuleOptions:
7223 (void) ListModuleInfo((FILE *) NULL,exception);
7226 case MagickPolicyOptions:
7228 (void) ListPolicyInfo((FILE *) NULL,exception);
7231 case MagickResourceOptions:
7233 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7236 case MagickThresholdOptions:
7238 (void) ListThresholdMaps((FILE *) NULL,exception);
7243 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7250 if (LocaleCompare(
"log",option+1) == 0)
7254 (void) SetLogFormat(argv[i+1]);
7257 if (LocaleCompare(
"loop",option+1) == 0)
7261 (void) SetImageOption(image_info,option+1,
"0");
7264 (void) SetImageOption(image_info,option+1,argv[i+1]);
7271 if (LocaleCompare(
"matte",option+1) == 0)
7275 (void) SetImageOption(image_info,option+1,
"false");
7278 (void) SetImageOption(image_info,option+1,
"true");
7281 if (LocaleCompare(
"mattecolor",option+1) == 0)
7285 (void) SetImageOption(image_info,option+1,argv[i+1]);
7286 (void) QueryColorDatabase(MogrifyMatteColor,
7287 &image_info->matte_color,exception);
7290 (void) SetImageOption(image_info,option+1,argv[i+1]);
7291 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7295 if (LocaleCompare(
"metric",option+1) == 0)
7299 (void) DeleteImageOption(image_info,option+1);
7302 (void) SetImageOption(image_info,option+1,argv[i+1]);
7305 if (LocaleCompare(
"monitor",option+1) == 0)
7307 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7311 if (LocaleCompare(
"monochrome",option+1) == 0)
7313 image_info->monochrome=(*option ==
'-') ? MagickTrue : MagickFalse;
7320 if (LocaleCompare(
"orient",option+1) == 0)
7324 image_info->orientation=UndefinedOrientation;
7325 (void) SetImageOption(image_info,option+1,
"undefined");
7328 image_info->orientation=(OrientationType) ParseCommandOption(
7329 MagickOrientationOptions,MagickFalse,argv[i+1]);
7330 (void) SetImageOption(image_info,option+1,argv[i+1]);
7336 if (LocaleCompare(
"page",option+1) == 0)
7340 page[MaxTextExtent];
7353 (void) DeleteImageOption(image_info,option+1);
7354 (void) CloneString(&image_info->page,(
char *) NULL);
7357 (void) memset(&geometry,0,
sizeof(geometry));
7358 image_option=GetImageOption(image_info,
"page");
7359 if (image_option != (
const char *) NULL)
7360 (void) ParseAbsoluteGeometry(image_option,&geometry);
7361 canonical_page=GetPageGeometry(argv[i+1]);
7362 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7363 canonical_page=DestroyString(canonical_page);
7364 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu",
7365 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
7366 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7367 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu%+ld%+ld",
7368 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
7369 (
long) geometry.x,(long) geometry.y);
7370 (void) SetImageOption(image_info,option+1,page);
7371 (void) CloneString(&image_info->page,page);
7374 if (LocaleCompare(
"pen",option+1) == 0)
7378 (void) SetImageOption(image_info,option+1,
"none");
7381 (void) SetImageOption(image_info,option+1,argv[i+1]);
7384 if (LocaleCompare(
"ping",option+1) == 0)
7386 image_info->ping=(*option ==
'-') ? MagickTrue : MagickFalse;
7389 if (LocaleCompare(
"pointsize",option+1) == 0)
7392 geometry_info.rho=0.0;
7394 (
void) ParseGeometry(argv[i+1],&geometry_info);
7395 image_info->pointsize=geometry_info.rho;
7398 if (LocaleCompare(
"precision",option+1) == 0)
7400 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7403 if (LocaleCompare(
"preview",option+1) == 0)
7410 image_info->preview_type=UndefinedPreview;
7413 image_info->preview_type=(PreviewType) ParseCommandOption(
7414 MagickPreviewOptions,MagickFalse,argv[i+1]);
7421 if (LocaleCompare(
"quality",option+1) == 0)
7428 image_info->quality=UndefinedCompressionQuality;
7429 (void) SetImageOption(image_info,option+1,
"0");
7432 image_info->quality=StringToUnsignedLong(argv[i+1]);
7433 (void) SetImageOption(image_info,option+1,argv[i+1]);
7436 if (LocaleCompare(
"quiet",option+1) == 0)
7438 static WarningHandler
7439 warning_handler = (WarningHandler) NULL;
7446 warning_handler=SetWarningHandler(warning_handler);
7452 warning_handler=SetWarningHandler((WarningHandler) NULL);
7459 if (LocaleCompare(
"red-primary",option+1) == 0)
7463 (void) SetImageOption(image_info,option+1,
"0.0");
7466 (void) SetImageOption(image_info,option+1,argv[i+1]);
7473 if (LocaleCompare(
"sampling-factor",option+1) == 0)
7480 if (image_info->sampling_factor != (
char *) NULL)
7481 image_info->sampling_factor=DestroyString(
7482 image_info->sampling_factor);
7485 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7488 if (LocaleCompare(
"scene",option+1) == 0)
7495 image_info->scene=0;
7496 (void) SetImageOption(image_info,option+1,
"0");
7499 image_info->scene=StringToUnsignedLong(argv[i+1]);
7500 (void) SetImageOption(image_info,option+1,argv[i+1]);
7503 if (LocaleCompare(
"seed",option+1) == 0)
7510 seed=(
unsigned long) time((time_t *) NULL);
7511 SetRandomSecretKey(seed);
7514 seed=StringToUnsignedLong(argv[i+1]);
7515 SetRandomSecretKey(seed);
7518 if (LocaleCompare(
"size",option+1) == 0)
7522 if (image_info->size != (
char *) NULL)
7523 image_info->size=DestroyString(image_info->size);
7526 (void) CloneString(&image_info->size,argv[i+1]);
7529 if (LocaleCompare(
"stroke",option+1) == 0)
7532 (void) SetImageOption(image_info,option+1,
"none");
7534 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7537 if (LocaleCompare(
"strokewidth",option+1) == 0)
7540 (void) SetImageOption(image_info,option+1,
"0");
7542 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7545 if (LocaleCompare(
"style",option+1) == 0)
7548 (void) SetImageOption(image_info,option+1,
"none");
7550 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7553 if (LocaleCompare(
"synchronize",option+1) == 0)
7557 image_info->synchronize=MagickFalse;
7560 image_info->synchronize=MagickTrue;
7567 if (LocaleCompare(
"taint",option+1) == 0)
7571 (void) SetImageOption(image_info,option+1,
"false");
7574 (void) SetImageOption(image_info,option+1,
"true");
7577 if (LocaleCompare(
"texture",option+1) == 0)
7581 if (image_info->texture != (
char *) NULL)
7582 image_info->texture=DestroyString(image_info->texture);
7585 (void) CloneString(&image_info->texture,argv[i+1]);
7588 if (LocaleCompare(
"tile-offset",option+1) == 0)
7592 (void) SetImageOption(image_info,option+1,
"0");
7595 (void) SetImageOption(image_info,option+1,argv[i+1]);
7598 if (LocaleCompare(
"transparent-color",option+1) == 0)
7602 (void) QueryColorDatabase(
"none",&image_info->transparent_color, exception);
7603 (void) SetImageOption(image_info,option+1,
"none");
7606 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7608 (void) SetImageOption(image_info,option+1,argv[i+1]);
7611 if (LocaleCompare(
"type",option+1) == 0)
7615 image_info->type=UndefinedType;
7616 (void) SetImageOption(image_info,option+1,
"undefined");
7619 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7620 MagickFalse,argv[i+1]);
7621 (void) SetImageOption(image_info,option+1,argv[i+1]);
7628 if (LocaleCompare(
"undercolor",option+1) == 0)
7632 (void) DeleteImageOption(image_info,option+1);
7635 (void) SetImageOption(image_info,option+1,argv[i+1]);
7638 if (LocaleCompare(
"units",option+1) == 0)
7642 image_info->units=UndefinedResolution;
7643 (void) SetImageOption(image_info,option+1,
"undefined");
7646 image_info->units=(ResolutionType) ParseCommandOption(
7647 MagickResolutionOptions,MagickFalse,argv[i+1]);
7648 (void) SetImageOption(image_info,option+1,argv[i+1]);
7655 if (LocaleCompare(
"verbose",option+1) == 0)
7659 image_info->verbose=MagickFalse;
7662 image_info->verbose=MagickTrue;
7663 image_info->ping=MagickFalse;
7666 if (LocaleCompare(
"view",option+1) == 0)
7670 if (image_info->view != (
char *) NULL)
7671 image_info->view=DestroyString(image_info->view);
7674 (void) CloneString(&image_info->view,argv[i+1]);
7677 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
7681 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7682 (void) SetImageOption(image_info,option+1,
"undefined");
7685 image_info->virtual_pixel_method=(VirtualPixelMethod)
7686 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7688 (void) SetImageOption(image_info,option+1,argv[i+1]);
7695 if (LocaleCompare(
"weight",option+1) == 0)
7698 (void) SetImageOption(image_info,option+1,
"0");
7700 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7703 if (LocaleCompare(
"white-point",option+1) == 0)
7707 (void) SetImageOption(image_info,option+1,
"0.0");
7710 (void) SetImageOption(image_info,option+1,argv[i+1]);
7757 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7758 const int argc,
const char **argv,Image **images,ExceptionInfo *exception)
7785 assert(image_info != (ImageInfo *) NULL);
7786 assert(image_info->signature == MagickCoreSignature);
7787 assert(images != (Image **) NULL);
7788 assert((*images)->previous == (Image *) NULL);
7789 assert((*images)->signature == MagickCoreSignature);
7790 if (IsEventLogging() != MagickFalse)
7791 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
7792 (*images)->filename);
7793 if ((argc <= 0) || (*argv == (
char *) NULL))
7795 mogrify_info=CloneImageInfo(image_info);
7796 quantize_info=AcquireQuantizeInfo(mogrify_info);
7797 channel=mogrify_info->channel;
7799 for (i=0; i < (ssize_t) argc; i++)
7801 if (*images == (Image *) NULL)
7804 if (IsCommandOption(option) == MagickFalse)
7806 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7807 count=MagickMax(count,0L);
7808 if ((i+count) >= (ssize_t) argc)
7810 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
7811 switch (*(option+1))
7815 if (LocaleCompare(
"affinity",option+1) == 0)
7817 (void) SyncImagesSettings(mogrify_info,*images);
7820 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7821 InheritException(exception,&(*images)->exception);
7827 if (LocaleCompare(
"append",option+1) == 0)
7832 (void) SyncImagesSettings(mogrify_info,*images);
7833 append_image=AppendImages(*images,*option ==
'-' ? MagickTrue :
7834 MagickFalse,exception);
7835 if (append_image == (Image *) NULL)
7840 *images=DestroyImageList(*images);
7841 *images=append_image;
7844 if (LocaleCompare(
"average",option+1) == 0)
7852 (void) SyncImagesSettings(mogrify_info,*images);
7853 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7855 if (average_image == (Image *) NULL)
7860 *images=DestroyImageList(*images);
7861 *images=average_image;
7868 if (LocaleCompare(
"channel",option+1) == 0)
7872 channel=DefaultChannels;
7875 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7878 if (LocaleCompare(
"clut",option+1) == 0)
7884 (void) SyncImagesSettings(mogrify_info,*images);
7885 image=RemoveFirstImageFromList(images);
7886 clut_image=RemoveFirstImageFromList(images);
7887 if (clut_image == (Image *) NULL)
7889 (void) ThrowMagickException(exception,GetMagickModule(),
7890 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7891 image=DestroyImage(image);
7895 (void) ClutImageChannel(image,channel,clut_image);
7896 clut_image=DestroyImage(clut_image);
7897 InheritException(exception,&image->exception);
7898 *images=DestroyImageList(*images);
7902 if (LocaleCompare(
"coalesce",option+1) == 0)
7907 (void) SyncImagesSettings(mogrify_info,*images);
7908 coalesce_image=CoalesceImages(*images,exception);
7909 if (coalesce_image == (Image *) NULL)
7914 *images=DestroyImageList(*images);
7915 *images=coalesce_image;
7918 if (LocaleCompare(
"combine",option+1) == 0)
7923 (void) SyncImagesSettings(mogrify_info,*images);
7924 combine_image=CombineImages(*images,channel,exception);
7925 if (combine_image == (Image *) NULL)
7930 *images=DestroyImageList(*images);
7931 *images=combine_image;
7934 if (LocaleCompare(
"compare",option+1) == 0)
7951 (void) SyncImagesSettings(mogrify_info,*images);
7952 image=RemoveFirstImageFromList(images);
7953 reconstruct_image=RemoveFirstImageFromList(images);
7954 if (reconstruct_image == (Image *) NULL)
7956 (void) ThrowMagickException(exception,GetMagickModule(),
7957 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7958 image=DestroyImage(image);
7962 metric=UndefinedMetric;
7963 option=GetImageOption(image_info,
"metric");
7964 if (option != (
const char *) NULL)
7965 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7966 MagickFalse,option);
7967 difference_image=CompareImageChannels(image,reconstruct_image,
7968 channel,metric,&distortion,exception);
7969 if (difference_image == (Image *) NULL)
7971 reconstruct_image=DestroyImage(reconstruct_image);
7972 image=DestroyImage(image);
7973 if (*images != (Image *) NULL)
7974 *images=DestroyImageList(*images);
7975 *images=difference_image;
7978 if (LocaleCompare(
"complex",option+1) == 0)
7986 (void) SyncImageSettings(mogrify_info,*images);
7987 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7988 MagickFalse,argv[i+1]);
7989 complex_images=ComplexImages(*images,op,exception);
7990 if (complex_images == (Image *) NULL)
7995 *images=DestroyImageList(*images);
7996 *images=complex_images;
7999 if (LocaleCompare(
"composite",option+1) == 0)
8009 (void) SyncImagesSettings(mogrify_info,*images);
8010 image=RemoveFirstImageFromList(images);
8011 composite_image=RemoveFirstImageFromList(images);
8012 if (composite_image == (Image *) NULL)
8014 (void) ThrowMagickException(exception,GetMagickModule(),
8015 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8016 image=DestroyImage(image);
8020 (void) TransformImage(&composite_image,(
char *) NULL,
8021 composite_image->geometry);
8022 SetGeometry(composite_image,&geometry);
8023 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
8024 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8026 mask_image=RemoveFirstImageFromList(images);
8027 if (mask_image != (Image *) NULL)
8029 if ((image->compose == DisplaceCompositeOp) ||
8030 (image->compose == DistortCompositeOp))
8035 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8037 mask_image=DestroyImage(mask_image);
8044 if (image->mask != (Image *) NULL)
8045 image->mask=DestroyImage(image->mask);
8046 image->mask=mask_image;
8047 (void) NegateImage(image->mask,MagickFalse);
8050 (void) CompositeImageChannel(image,channel,image->compose,
8051 composite_image,geometry.x,geometry.y);
8052 if (mask_image != (Image *) NULL)
8054 image->mask=DestroyImage(image->mask);
8055 mask_image=image->mask;
8057 composite_image=DestroyImage(composite_image);
8058 InheritException(exception,&image->exception);
8059 *images=DestroyImageList(*images);
8063 if (LocaleCompare(
"copy",option+1) == 0)
8077 (void) SyncImageSettings(mogrify_info,*images);
8078 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8079 offset.x=geometry.x;
8080 offset.y=geometry.y;
8081 source_image=(*images);
8082 if (source_image->next != (Image *) NULL)
8083 source_image=source_image->next;
8084 (
void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8086 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8094 if (LocaleCompare(
"deconstruct",option+1) == 0)
8099 (void) SyncImagesSettings(mogrify_info,*images);
8100 deconstruct_image=DeconstructImages(*images,exception);
8101 if (deconstruct_image == (Image *) NULL)
8106 *images=DestroyImageList(*images);
8107 *images=deconstruct_image;
8110 if (LocaleCompare(
"delete",option+1) == 0)
8113 DeleteImages(images,
"-1",exception);
8115 DeleteImages(images,argv[i+1],exception);
8118 if (LocaleCompare(
"dither",option+1) == 0)
8122 quantize_info->dither=MagickFalse;
8125 quantize_info->dither=MagickTrue;
8126 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8127 MagickDitherOptions,MagickFalse,argv[i+1]);
8130 if (LocaleCompare(
"duplicate",option+1) == 0)
8136 duplicate_images=DuplicateImages(*images,1,
"-1",exception);
8145 number_duplicates=(size_t) StringToLong(argv[i+1]);
8146 p=strchr(argv[i+1],
',');
8147 if (p == (
const char *) NULL)
8148 duplicate_images=DuplicateImages(*images,number_duplicates,
8151 duplicate_images=DuplicateImages(*images,number_duplicates,
8154 AppendImageToList(images, duplicate_images);
8155 (void) SyncImagesSettings(mogrify_info,*images);
8162 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
8167 MagickEvaluateOperator
8170 (void) SyncImageSettings(mogrify_info,*images);
8171 op=(MagickEvaluateOperator) ParseCommandOption(
8172 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8173 evaluate_image=EvaluateImages(*images,op,exception);
8174 if (evaluate_image == (Image *) NULL)
8179 *images=DestroyImageList(*images);
8180 *images=evaluate_image;
8187 if (LocaleCompare(
"fft",option+1) == 0)
8195 (void) SyncImageSettings(mogrify_info,*images);
8196 fourier_image=ForwardFourierTransformImage(*images,*option ==
'-' ?
8197 MagickTrue : MagickFalse,exception);
8198 if (fourier_image == (Image *) NULL)
8200 *images=DestroyImageList(*images);
8201 *images=fourier_image;
8204 if (LocaleCompare(
"flatten",option+1) == 0)
8209 (void) SyncImagesSettings(mogrify_info,*images);
8210 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8211 if (flatten_image == (Image *) NULL)
8213 *images=DestroyImageList(*images);
8214 *images=flatten_image;
8217 if (LocaleCompare(
"fx",option+1) == 0)
8222 (void) SyncImagesSettings(mogrify_info,*images);
8223 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
8224 if (fx_image == (Image *) NULL)
8229 *images=DestroyImageList(*images);
8237 if (LocaleCompare(
"hald-clut",option+1) == 0)
8243 (void) SyncImagesSettings(mogrify_info,*images);
8244 image=RemoveFirstImageFromList(images);
8245 hald_image=RemoveFirstImageFromList(images);
8246 if (hald_image == (Image *) NULL)
8248 (void) ThrowMagickException(exception,GetMagickModule(),
8249 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8250 image=DestroyImage(image);
8254 (void) HaldClutImageChannel(image,channel,hald_image);
8255 hald_image=DestroyImage(hald_image);
8256 InheritException(exception,&image->exception);
8257 if (*images != (Image *) NULL)
8258 *images=DestroyImageList(*images);
8266 if (LocaleCompare(
"ift",option+1) == 0)
8276 (void) SyncImagesSettings(mogrify_info,*images);
8277 magnitude_image=RemoveFirstImageFromList(images);
8278 phase_image=RemoveFirstImageFromList(images);
8279 if (phase_image == (Image *) NULL)
8281 (void) ThrowMagickException(exception,GetMagickModule(),
8282 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8283 magnitude_image=DestroyImage(magnitude_image);
8287 fourier_image=InverseFourierTransformImage(magnitude_image,
8288 phase_image,*option ==
'-' ? MagickTrue : MagickFalse,exception);
8289 magnitude_image=DestroyImage(magnitude_image);
8290 phase_image=DestroyImage(phase_image);
8291 if (fourier_image == (Image *) NULL)
8293 if (*images != (Image *) NULL)
8294 *images=DestroyImageList(*images);
8295 *images=fourier_image;
8298 if (LocaleCompare(
"insert",option+1) == 0)
8306 index=(ssize_t) StringToLong(argv[i+1]);
8307 p=RemoveLastImageFromList(images);
8308 if (p == (Image *) NULL)
8310 (void) ThrowMagickException(exception,GetMagickModule(),
8311 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8317 PrependImageToList(images,q);
8319 if (index == (ssize_t) GetImageListLength(*images))
8320 AppendImageToList(images,q);
8323 q=GetImageFromList(*images,index-1);
8324 if (q == (Image *) NULL)
8327 (void) ThrowMagickException(exception,GetMagickModule(),
8328 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8332 InsertImageInList(&q,p);
8334 *images=GetFirstImageInList(q);
8341 if (LocaleCompare(
"layers",option+1) == 0)
8349 (void) SyncImagesSettings(mogrify_info,*images);
8350 layers=(Image *) NULL;
8351 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
8352 MagickFalse,argv[i+1]);
8357 layers=CoalesceImages(*images,exception);
8360 case CompareAnyLayer:
8361 case CompareClearLayer:
8362 case CompareOverlayLayer:
8365 layers=CompareImageLayers(*images,method,exception);
8371 case TrimBoundsLayer:
8373 layers=MergeImageLayers(*images,method,exception);
8378 layers=DisposeImages(*images,exception);
8381 case OptimizeImageLayer:
8383 layers=OptimizeImageLayers(*images,exception);
8386 case OptimizePlusLayer:
8388 layers=OptimizePlusImageLayers(*images,exception);
8391 case OptimizeTransLayer:
8393 OptimizeImageTransparency(*images,exception);
8396 case RemoveDupsLayer:
8398 RemoveDuplicateLayers(images,exception);
8401 case RemoveZeroLayer:
8403 RemoveZeroDelayLayers(images,exception);
8411 layers=CoalesceImages(*images,exception);
8412 if (layers == (Image *) NULL)
8417 InheritException(exception,&layers->exception);
8418 *images=DestroyImageList(*images);
8420 layers=OptimizeImageLayers(*images,exception);
8421 if (layers == (Image *) NULL)
8426 InheritException(exception,&layers->exception);
8427 *images=DestroyImageList(*images);
8429 layers=(Image *) NULL;
8430 OptimizeImageTransparency(*images,exception);
8431 InheritException(exception,&(*images)->exception);
8432 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8435 case CompositeLayer:
8450 while (source != (Image *) NULL)
8452 source=GetNextImageInList(source);
8453 if ((source != (Image *) NULL) &&
8454 (LocaleCompare(source->magick,
"NULL") == 0))
8457 if (source != (Image *) NULL)
8459 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8460 (GetNextImageInList(source) == (Image *) NULL))
8461 source=(Image *) NULL;
8467 source=SplitImageList(source->previous);
8468 DeleteImageFromList(&source);
8471 if (source == (Image *) NULL)
8473 (void) ThrowMagickException(exception,GetMagickModule(),
8474 OptionError,
"MissingNullSeparator",
"layers Composite");
8481 SetGeometry(*images,&geometry);
8482 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8483 geometry.width=source->page.width != 0 ?
8484 source->page.width : source->columns;
8485 geometry.height=source->page.height != 0 ?
8486 source->page.height : source->rows;
8487 GravityAdjustGeometry((*images)->page.width != 0 ?
8488 (*images)->page.width : (*images)->columns,
8489 (*images)->page.height != 0 ? (*images)->page.height :
8490 (*images)->rows,(*images)->gravity,&geometry);
8491 compose=OverCompositeOp;
8492 option=GetImageOption(mogrify_info,
"compose");
8493 if (option != (
const char *) NULL)
8494 compose=(CompositeOperator) ParseCommandOption(
8495 MagickComposeOptions,MagickFalse,option);
8496 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8498 source=DestroyImageList(source);
8502 if (layers == (Image *) NULL)
8504 InheritException(exception,&layers->exception);
8505 *images=DestroyImageList(*images);
8513 if (LocaleCompare(
"map",option+1) == 0)
8515 (void) SyncImagesSettings(mogrify_info,*images);
8518 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8519 InheritException(exception,&(*images)->exception);
8525 if (LocaleCompare(
"maximum",option+1) == 0)
8533 (void) SyncImagesSettings(mogrify_info,*images);
8534 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8535 if (maximum_image == (Image *) NULL)
8540 *images=DestroyImageList(*images);
8541 *images=maximum_image;
8544 if (LocaleCompare(
"minimum",option+1) == 0)
8552 (void) SyncImagesSettings(mogrify_info,*images);
8553 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8554 if (minimum_image == (Image *) NULL)
8559 *images=DestroyImageList(*images);
8560 *images=minimum_image;
8563 if (LocaleCompare(
"morph",option+1) == 0)
8568 (void) SyncImagesSettings(mogrify_info,*images);
8569 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8571 if (morph_image == (Image *) NULL)
8576 *images=DestroyImageList(*images);
8577 *images=morph_image;
8580 if (LocaleCompare(
"mosaic",option+1) == 0)
8585 (void) SyncImagesSettings(mogrify_info,*images);
8586 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8587 if (mosaic_image == (Image *) NULL)
8592 *images=DestroyImageList(*images);
8593 *images=mosaic_image;
8600 if (LocaleCompare(
"poly",option+1) == 0)
8604 token[MaxTextExtent];
8624 (void) SyncImageSettings(mogrify_info,*images);
8625 args=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8626 InheritException(exception,&(*images)->exception);
8627 if (args == (
char *) NULL)
8630 for (x=0; *p !=
'\0'; x++)
8632 (void) GetNextToken(p,&p,MaxTextExtent,token);
8634 (void) GetNextToken(p,&p,MaxTextExtent,token);
8636 number_arguments=(size_t) x;
8637 arguments=(
double *) AcquireQuantumMemory(number_arguments,
8638 sizeof(*arguments));
8639 if (arguments == (
double *) NULL)
8640 ThrowWandFatalException(ResourceLimitFatalError,
8641 "MemoryAllocationFailed",(*images)->filename);
8642 (void) memset(arguments,0,number_arguments*
8643 sizeof(*arguments));
8645 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
8647 (void) GetNextToken(p,&p,MaxTextExtent,token);
8649 (void) GetNextToken(p,&p,MaxTextExtent,token);
8650 arguments[x]=StringToDouble(token,(
char **) NULL);
8652 args=DestroyString(args);
8653 polynomial_image=PolynomialImageChannel(*images,channel,
8654 number_arguments >> 1,arguments,exception);
8655 arguments=(
double *) RelinquishMagickMemory(arguments);
8656 if (polynomial_image == (Image *) NULL)
8661 *images=DestroyImageList(*images);
8662 *images=polynomial_image;
8665 if (LocaleCompare(
"print",option+1) == 0)
8670 (void) SyncImagesSettings(mogrify_info,*images);
8671 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8672 if (
string == (
char *) NULL)
8674 InheritException(exception,&(*images)->exception);
8675 (void) FormatLocaleFile(stdout,
"%s",
string);
8676 string=DestroyString(
string);
8678 if (LocaleCompare(
"process",option+1) == 0)
8687 (void) SyncImagesSettings(mogrify_info,*images);
8688 arguments=StringToArgv(argv[i+1],&number_arguments);
8689 if (arguments == (
char **) NULL)
8691 if ((argc > 1) && (strchr(arguments[1],
'=') != (
char *) NULL))
8714 length=strlen(argv[i+1]);
8715 token=(
char *) NULL;
8716 if (~length >= (MaxTextExtent-1))
8717 token=(
char *) AcquireQuantumMemory(length+MaxTextExtent,
8719 if (token == (
char *) NULL)
8722 arguments=argv[i+1];
8723 token_info=AcquireTokenInfo();
8724 status=Tokenizer(token_info,0,token,length,arguments,
"",
"=",
8725 "\"",
'\0',&breaker,&next,"e);
8726 token_info=DestroyTokenInfo(token_info);
8732 argv=(&(arguments[next]));
8733 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8736 token=DestroyString(token);
8739 (void) SubstituteString(&arguments[1],
"-",
"");
8740 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8741 number_arguments-2,(
const char **) arguments+2,exception);
8742 for (j=0; j < number_arguments; j++)
8743 arguments[j]=DestroyString(arguments[j]);
8744 arguments=(
char **) RelinquishMagickMemory(arguments);
8751 if (LocaleCompare(
"reverse",option+1) == 0)
8753 ReverseImageList(images);
8754 InheritException(exception,&(*images)->exception);
8761 if (LocaleCompare(
"smush",option+1) == 0)
8769 (void) SyncImagesSettings(mogrify_info,*images);
8770 offset=(ssize_t) StringToLong(argv[i+1]);
8771 smush_image=SmushImages(*images,*option ==
'-' ? MagickTrue :
8772 MagickFalse,offset,exception);
8773 if (smush_image == (Image *) NULL)
8778 *images=DestroyImageList(*images);
8779 *images=smush_image;
8782 if (LocaleCompare(
"swap",option+1) == 0)
8804 flags=ParseGeometry(argv[i+1],&geometry_info);
8805 index=(ssize_t) geometry_info.rho;
8806 if ((flags & SigmaValue) != 0)
8807 swap_index=(ssize_t) geometry_info.sigma;
8809 p=GetImageFromList(*images,index);
8810 q=GetImageFromList(*images,swap_index);
8811 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8813 (void) ThrowMagickException(exception,GetMagickModule(),
8814 OptionError,
"NoSuchImage",
"`%s'",(*images)->filename);
8820 u=CloneImage(p,0,0,MagickTrue,exception);
8821 if (u == (Image *) NULL)
8823 v=CloneImage(q,0,0,MagickTrue,exception);
8824 if (v == (Image *) NULL)
8829 ReplaceImageInList(&p,v);
8830 ReplaceImageInList(&q,u);
8831 *images=GetFirstImageInList(q);
8838 if (LocaleCompare(
"write",option+1) == 0)
8849 (void) SyncImagesSettings(mogrify_info,*images);
8850 (void) FormatLocaleString(key,MaxTextExtent,
"cache:%s",argv[i+1]);
8851 (void) DeleteImageRegistry(key);
8852 write_images=CloneImageList(*images,exception);
8853 write_info=CloneImageInfo(mogrify_info);
8854 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8855 write_info=DestroyImageInfo(write_info);
8856 write_images=DestroyImageList(write_images);
8866 quantize_info=DestroyQuantizeInfo(quantize_info);
8867 mogrify_info=DestroyImageInfo(mogrify_info);
8868 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8869 return(status != 0 ? MagickTrue : MagickFalse);
8909 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8910 const MagickBooleanType post,
const int argc,
const char **argv,
8911 Image **images,ExceptionInfo *exception)
8913 #define MogrifyImageTag "Mogrify/Image"
8927 assert(image_info != (ImageInfo *) NULL);
8928 assert(image_info->signature == MagickCoreSignature);
8929 if (images == (Image **) NULL)
8930 return(MogrifyImage(image_info,argc,argv,images,exception));
8931 assert((*images)->previous == (Image *) NULL);
8932 assert((*images)->signature == MagickCoreSignature);
8933 if (IsEventLogging() != MagickFalse)
8934 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
8935 (*images)->filename);
8936 if ((argc <= 0) || (*argv == (
char *) NULL))
8938 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8942 (void) FormatLocaleFile(stderr,
"mogrify start %s %d (%s)\n",argv[0],argc,
8948 if (post == MagickFalse)
8949 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8954 n=GetImageListLength(*images);
8958 (void) FormatLocaleFile(stderr,
"mogrify %ld of %ld\n",(
long)
8959 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8961 status&=MogrifyImage(image_info,argc,argv,images,exception);
8962 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8963 if (proceed == MagickFalse)
8965 if ((*images)->next == (Image *) NULL)
8967 *images=(*images)->next;
8970 assert(*images != (Image *) NULL);
8972 (void) FormatLocaleFile(stderr,
"mogrify end %ld of %ld\n",(
long)
8973 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8978 *images=GetFirstImageInList(*images);
8979 if (post != MagickFalse)
8980 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8981 return(status != 0 ? MagickTrue : MagickFalse);