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) CloneString(&draw_info->family,argv[i+1]);
1584 if (LocaleCompare(
"features",option+1) == 0)
1588 (void) DeleteImageArtifact(*image,
"identify:features");
1591 (void) SetImageArtifact(*image,
"identify:features",argv[i+1]);
1592 (void) SetImageArtifact(*image,
"verbose",
"true");
1595 if (LocaleCompare(
"fill",option+1) == 0)
1600 GetMagickPixelPacket(*image,&fill);
1603 (void) QueryMagickColor(
"none",&fill,exception);
1604 (void) QueryColorDatabase(
"none",&draw_info->fill,exception);
1605 if (draw_info->fill_pattern != (Image *) NULL)
1606 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1609 sans=AcquireExceptionInfo();
1610 (void) QueryMagickColor(argv[i+1],&fill,sans);
1611 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1612 sans=DestroyExceptionInfo(sans);
1613 if (status == MagickFalse)
1614 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1618 if (LocaleCompare(
"flip",option+1) == 0)
1623 (void) SyncImageSettings(mogrify_info,*image);
1624 mogrify_image=FlipImage(*image,exception);
1627 if (LocaleCompare(
"floodfill",option+1) == 0)
1635 (void) SyncImageSettings(mogrify_info,*image);
1636 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1637 (void) QueryMagickColor(argv[i+2],&target,exception);
1638 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1639 geometry.x,geometry.y,*option ==
'-' ? MagickFalse : MagickTrue);
1640 InheritException(exception,&(*image)->exception);
1643 if (LocaleCompare(
"flop",option+1) == 0)
1648 (void) SyncImageSettings(mogrify_info,*image);
1649 mogrify_image=FlopImage(*image,exception);
1652 if (LocaleCompare(
"font",option+1) == 0)
1656 if (draw_info->font != (
char *) NULL)
1657 draw_info->font=DestroyString(draw_info->font);
1660 (void) CloneString(&draw_info->font,argv[i+1]);
1663 if (LocaleCompare(
"format",option+1) == 0)
1668 if (LocaleCompare(
"frame",option+1) == 0)
1676 (void) SyncImageSettings(mogrify_info,*image);
1677 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1678 frame_info.width=geometry.width;
1679 frame_info.height=geometry.height;
1680 frame_info.outer_bevel=geometry.x;
1681 frame_info.inner_bevel=geometry.y;
1682 frame_info.x=(ssize_t) frame_info.width;
1683 frame_info.y=(ssize_t) frame_info.height;
1684 frame_info.width=(*image)->columns+2*frame_info.width;
1685 frame_info.height=(*image)->rows+2*frame_info.height;
1686 mogrify_image=FrameImage(*image,&frame_info,exception);
1689 if (LocaleCompare(
"function",option+1) == 0)
1693 token[MaxTextExtent];
1713 (void) SyncImageSettings(mogrify_info,*image);
1714 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1715 MagickFalse,argv[i+1]);
1716 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1717 InheritException(exception,&(*image)->exception);
1718 if (arguments == (
char *) NULL)
1720 p=(
char *) arguments;
1721 for (x=0; *p !=
'\0'; x++)
1723 (void) GetNextToken(p,&p,MaxTextExtent,token);
1725 (void) GetNextToken(p,&p,MaxTextExtent,token);
1727 number_parameters=(size_t) x;
1728 parameters=(
double *) AcquireQuantumMemory(number_parameters,
1729 sizeof(*parameters));
1730 if (parameters == (
double *) NULL)
1731 ThrowWandFatalException(ResourceLimitFatalError,
1732 "MemoryAllocationFailed",(*image)->filename);
1733 (void) memset(parameters,0,number_parameters*
1734 sizeof(*parameters));
1735 p=(
char *) arguments;
1736 for (x=0; (x < (ssize_t) number_parameters) && (*p !=
'\0'); x++)
1738 (void) GetNextToken(p,&p,MaxTextExtent,token);
1740 (void) GetNextToken(p,&p,MaxTextExtent,token);
1741 parameters[x]=StringToDouble(token,(
char **) NULL);
1743 arguments=DestroyString(arguments);
1744 (void) FunctionImageChannel(*image,channel,
function,
1745 number_parameters,parameters,exception);
1746 parameters=(
double *) RelinquishMagickMemory(parameters);
1753 if (LocaleCompare(
"gamma",option+1) == 0)
1758 (void) SyncImageSettings(mogrify_info,*image);
1760 (*image)->gamma=StringToDouble(argv[i+1],(
char **) NULL);
1763 if (strchr(argv[i+1],
',') != (
char *) NULL)
1764 (void) GammaImage(*image,argv[i+1]);
1766 (
void) GammaImageChannel(*image,channel,
1767 StringToDouble(argv[i+1],(
char **) NULL));
1768 InheritException(exception,&(*image)->exception);
1772 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
1773 (LocaleCompare(
"gaussian",option+1) == 0))
1778 (void) SyncImageSettings(mogrify_info,*image);
1779 flags=ParseGeometry(argv[i+1],&geometry_info);
1780 if ((flags & SigmaValue) == 0)
1781 geometry_info.sigma=1.0;
1782 mogrify_image=GaussianBlurImageChannel(*image,channel,
1783 geometry_info.rho,geometry_info.sigma,exception);
1786 if (LocaleCompare(
"geometry",option+1) == 0)
1791 (void) SyncImageSettings(mogrify_info,*image);
1794 if ((*image)->geometry != (
char *) NULL)
1795 (*image)->geometry=DestroyString((*image)->geometry);
1798 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1799 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1800 (void) CloneString(&(*image)->geometry,argv[i+1]);
1802 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1803 (*image)->filter,(*image)->blur,exception);
1806 if (LocaleCompare(
"gravity",option+1) == 0)
1810 draw_info->gravity=UndefinedGravity;
1813 draw_info->gravity=(GravityType) ParseCommandOption(
1814 MagickGravityOptions,MagickFalse,argv[i+1]);
1817 if (LocaleCompare(
"grayscale",option+1) == 0)
1819 PixelIntensityMethod
1822 (void) SyncImagesSettings(mogrify_info,*image);
1823 method=(PixelIntensityMethod) ParseCommandOption(
1824 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1825 (void) GrayscaleImage(*image,method);
1826 InheritException(exception,&(*image)->exception);
1833 if (LocaleCompare(
"highlight-color",option+1) == 0)
1835 (void) SetImageArtifact(*image,
"compare:highlight-color",argv[i+1]);
1838 if (LocaleCompare(
"hough-lines",option+1) == 0)
1843 (void) SyncImageSettings(mogrify_info,*image);
1844 flags=ParseGeometry(argv[i+1],&geometry_info);
1845 if ((flags & SigmaValue) == 0)
1846 geometry_info.sigma=geometry_info.rho;
1847 if ((flags & XiValue) == 0)
1848 geometry_info.xi=40;
1849 mogrify_image=HoughLineImage(*image,(
size_t) geometry_info.rho,
1850 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,exception);
1857 if (LocaleCompare(
"identify",option+1) == 0)
1862 (void) SyncImageSettings(mogrify_info,*image);
1863 if (format == (
char *) NULL)
1865 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1866 InheritException(exception,&(*image)->exception);
1869 text=InterpretImageProperties(mogrify_info,*image,format);
1870 InheritException(exception,&(*image)->exception);
1871 if (text == (
char *) NULL)
1873 (void) fputs(text,stdout);
1874 text=DestroyString(text);
1877 if (LocaleCompare(
"implode",option+1) == 0)
1882 (void) SyncImageSettings(mogrify_info,*image);
1883 (void) ParseGeometry(argv[i+1],&geometry_info);
1884 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1887 if (LocaleCompare(
"interline-spacing",option+1) == 0)
1890 (void) ParseGeometry(
"0",&geometry_info);
1892 (
void) ParseGeometry(argv[i+1],&geometry_info);
1893 draw_info->interline_spacing=geometry_info.rho;
1896 if (LocaleCompare(
"interword-spacing",option+1) == 0)
1899 (void) ParseGeometry(
"0",&geometry_info);
1901 (
void) ParseGeometry(argv[i+1],&geometry_info);
1902 draw_info->interword_spacing=geometry_info.rho;
1905 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
1910 (void) SyncImageSettings(mogrify_info,*image);
1911 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1912 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1913 geometry.height,(*image)->interpolate,exception);
1920 if (LocaleCompare(
"kerning",option+1) == 0)
1923 (void) ParseGeometry(
"0",&geometry_info);
1925 (
void) ParseGeometry(argv[i+1],&geometry_info);
1926 draw_info->kerning=geometry_info.rho;
1929 if (LocaleCompare(
"kuwahara",option+1) == 0)
1934 (void) SyncImageSettings(mogrify_info,*image);
1935 flags=ParseGeometry(argv[i+1],&geometry_info);
1936 if ((flags & SigmaValue) == 0)
1937 geometry_info.sigma=geometry_info.rho-0.5;
1938 mogrify_image=KuwaharaImageChannel(*image,channel,geometry_info.rho,
1939 geometry_info.sigma,exception);
1946 if (LocaleCompare(
"lat",option+1) == 0)
1951 (void) SyncImageSettings(mogrify_info,*image);
1952 flags=ParseGeometry(argv[i+1],&geometry_info);
1953 if ((flags & SigmaValue) == 0)
1954 geometry_info.sigma=1.0;
1955 if ((flags & PercentValue) != 0)
1956 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1957 mogrify_image=AdaptiveThresholdImage(*image,(
size_t)
1958 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1959 geometry_info.xi,exception);
1962 if (LocaleCompare(
"level",option+1) == 0)
1975 (void) SyncImageSettings(mogrify_info,*image);
1976 flags=ParseGeometry(argv[i+1],&geometry_info);
1977 black_point=geometry_info.rho;
1978 white_point=(MagickRealType) QuantumRange;
1979 if ((flags & SigmaValue) != 0)
1980 white_point=geometry_info.sigma;
1982 if ((flags & XiValue) != 0)
1983 gamma=geometry_info.xi;
1984 if ((flags & PercentValue) != 0)
1986 black_point*=(MagickRealType) (QuantumRange/100.0);
1987 white_point*=(MagickRealType) (QuantumRange/100.0);
1989 if ((flags & SigmaValue) == 0)
1990 white_point=(MagickRealType) QuantumRange-black_point;
1991 if ((*option ==
'+') || ((flags & AspectValue) != 0))
1992 (
void) LevelizeImageChannel(*image,channel,black_point,
1995 (
void) LevelImageChannel(*image,channel,black_point,white_point,
1997 InheritException(exception,&(*image)->exception);
2000 if (LocaleCompare(
"level-colors",option+1) == 0)
2003 token[MaxTextExtent];
2012 p=(
const char *) argv[i+1];
2013 (void) GetNextToken(p,&p,MaxTextExtent,token);
2014 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2015 (void) QueryMagickColor(token,&black_point,exception);
2017 (
void) QueryMagickColor(
"#000000",&black_point,exception);
2018 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
2019 (void) GetNextToken(p,&p,MaxTextExtent,token);
2021 white_point=black_point;
2024 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
2025 (
void) GetNextToken(p,&p,MaxTextExtent,token);
2026 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2027 (void) QueryMagickColor(token,&white_point,exception);
2029 (
void) QueryMagickColor(
"#ffffff",&white_point,exception);
2031 (void) LevelColorsImageChannel(*image,channel,&black_point,
2032 &white_point,*option ==
'+' ? MagickTrue : MagickFalse);
2035 if (LocaleCompare(
"linear-stretch",option+1) == 0)
2044 (void) SyncImageSettings(mogrify_info,*image);
2045 flags=ParseGeometry(argv[i+1],&geometry_info);
2046 black_point=geometry_info.rho;
2047 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2048 if ((flags & SigmaValue) != 0)
2049 white_point=geometry_info.sigma;
2050 if ((flags & PercentValue) != 0)
2052 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2053 white_point*=(
double) (*image)->columns*(*image)->rows/100.0;
2055 if ((flags & SigmaValue) == 0)
2056 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2058 (void) LinearStretchImage(*image,black_point,white_point);
2059 InheritException(exception,&(*image)->exception);
2062 if (LocaleCompare(
"linewidth",option+1) == 0)
2064 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
2067 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
2072 (void) SyncImageSettings(mogrify_info,*image);
2073 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2074 if ((flags & XValue) == 0)
2076 if ((flags & YValue) == 0)
2078 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2079 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2082 if (LocaleCompare(
"local-contrast",option+1) == 0)
2087 (void) SyncImageSettings(mogrify_info,*image);
2088 flags=ParseGeometry(argv[i+1],&geometry_info);
2089 if ((flags & RhoValue) == 0)
2090 geometry_info.rho=10;
2091 if ((flags & SigmaValue) == 0)
2092 geometry_info.sigma=12.5;
2093 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
2094 geometry_info.sigma,exception);
2097 if (LocaleCompare(
"lowlight-color",option+1) == 0)
2099 (void) SetImageArtifact(*image,
"compare:lowlight-color",argv[i+1]);
2106 if (LocaleCompare(
"magnify",option+1) == 0)
2111 (void) SyncImageSettings(mogrify_info,*image);
2112 mogrify_image=MagnifyImage(*image,exception);
2115 if (LocaleCompare(
"map",option+1) == 0)
2123 (void) SyncImageSettings(mogrify_info,*image);
2126 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2127 if (remap_image == (Image *) NULL)
2129 (void) RemapImage(quantize_info,*image,remap_image);
2130 InheritException(exception,&(*image)->exception);
2131 remap_image=DestroyImage(remap_image);
2134 if (LocaleCompare(
"mask",option+1) == 0)
2139 (void) SyncImageSettings(mogrify_info,*image);
2145 (void) SetImageMask(*image,(Image *) NULL);
2146 InheritException(exception,&(*image)->exception);
2152 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2153 if (mask == (Image *) NULL)
2155 (void) SetImageMask(*image,mask);
2156 mask=DestroyImage(mask);
2157 InheritException(exception,&(*image)->exception);
2160 if (LocaleCompare(
"matte",option+1) == 0)
2162 (void) SetImageAlphaChannel(*image,(*option ==
'-') ?
2163 SetAlphaChannel : DeactivateAlphaChannel );
2164 InheritException(exception,&(*image)->exception);
2167 if (LocaleCompare(
"mean-shift",option+1) == 0)
2172 (void) SyncImageSettings(mogrify_info,*image);
2173 flags=ParseGeometry(argv[i+1],&geometry_info);
2174 if ((flags & SigmaValue) == 0)
2175 geometry_info.sigma=geometry_info.rho;
2176 if ((flags & XiValue) == 0)
2177 geometry_info.xi=0.10*QuantumRange;
2178 if ((flags & PercentValue) != 0)
2179 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2180 mogrify_image=MeanShiftImage(*image,(
size_t) geometry_info.rho,
2181 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2184 if (LocaleCompare(
"median",option+1) == 0)
2189 (void) SyncImageSettings(mogrify_info,*image);
2190 (void) ParseGeometry(argv[i+1],&geometry_info);
2191 mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic,
2192 (
size_t) geometry_info.rho,(
size_t) geometry_info.rho,exception);
2195 if (LocaleCompare(
"mode",option+1) == 0)
2200 (void) SyncImageSettings(mogrify_info,*image);
2201 (void) ParseGeometry(argv[i+1],&geometry_info);
2202 mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic,
2203 (
size_t) geometry_info.rho,(
size_t) geometry_info.rho,exception);
2206 if (LocaleCompare(
"modulate",option+1) == 0)
2208 (void) SyncImageSettings(mogrify_info,*image);
2209 (void) ModulateImage(*image,argv[i+1]);
2210 InheritException(exception,&(*image)->exception);
2213 if (LocaleCompare(
"moments",option+1) == 0)
2217 (void) DeleteImageArtifact(*image,
"identify:moments");
2220 (void) SetImageArtifact(*image,
"identify:moments",argv[i+1]);
2221 (void) SetImageArtifact(*image,
"verbose",
"true");
2224 if (LocaleCompare(
"monitor",option+1) == 0)
2228 (void) SetImageProgressMonitor(*image,
2229 (MagickProgressMonitor) NULL,(
void *) NULL);
2232 (void) SetImageProgressMonitor(*image,MonitorProgress,
2236 if (LocaleCompare(
"monochrome",option+1) == 0)
2238 (void) SyncImageSettings(mogrify_info,*image);
2239 (void) SetImageType(*image,BilevelType);
2240 InheritException(exception,&(*image)->exception);
2243 if (LocaleCompare(
"morphology",option+1) == 0)
2246 token[MaxTextExtent];
2263 (void) SyncImageSettings(mogrify_info,*image);
2265 (void) GetNextToken(p,&p,MaxTextExtent,token);
2266 method=(MorphologyMethod) ParseCommandOption(
2267 MagickMorphologyOptions,MagickFalse,token);
2269 (void) GetNextToken(p,&p,MaxTextExtent,token);
2270 if ((*p ==
':') || (*p ==
','))
2271 (void) GetNextToken(p,&p,MaxTextExtent,token);
2273 iterations=(ssize_t) StringToLong(p);
2274 kernel=AcquireKernelInfo(argv[i+2]);
2275 if (kernel == (KernelInfo *) NULL)
2277 (void) ThrowMagickException(exception,GetMagickModule(),
2278 OptionError,
"UnabletoParseKernel",
"morphology");
2282 mogrify_image=MorphologyImageChannel(*image,channel,method,
2283 iterations,kernel,exception);
2284 kernel=DestroyKernelInfo(kernel);
2287 if (LocaleCompare(
"motion-blur",option+1) == 0)
2292 (void) SyncImageSettings(mogrify_info,*image);
2293 flags=ParseGeometry(argv[i+1],&geometry_info);
2294 if ((flags & SigmaValue) == 0)
2295 geometry_info.sigma=1.0;
2296 mogrify_image=MotionBlurImageChannel(*image,channel,
2297 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2304 if (LocaleCompare(
"negate",option+1) == 0)
2306 (void) SyncImageSettings(mogrify_info,*image);
2307 (void) NegateImageChannel(*image,channel,*option ==
'+' ?
2308 MagickTrue : MagickFalse);
2309 InheritException(exception,&(*image)->exception);
2312 if (LocaleCompare(
"noise",option+1) == 0)
2314 (void) SyncImageSettings(mogrify_info,*image);
2317 flags=ParseGeometry(argv[i+1],&geometry_info);
2318 if ((flags & SigmaValue) == 0)
2319 geometry_info.sigma=geometry_info.rho;
2320 mogrify_image=StatisticImageChannel(*image,channel,
2321 NonpeakStatistic,(
size_t) geometry_info.rho,(
size_t)
2322 geometry_info.sigma,exception);
2329 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2330 MagickFalse,argv[i+1]);
2331 mogrify_image=AddNoiseImageChannel(*image,channel,noise,
2336 if (LocaleCompare(
"normalize",option+1) == 0)
2338 (void) SyncImageSettings(mogrify_info,*image);
2339 (void) NormalizeImageChannel(*image,channel);
2340 InheritException(exception,&(*image)->exception);
2347 if (LocaleCompare(
"opaque",option+1) == 0)
2352 (void) SyncImageSettings(mogrify_info,*image);
2353 (void) QueryMagickColor(argv[i+1],&target,exception);
2354 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2355 *option ==
'-' ? MagickFalse : MagickTrue);
2358 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2360 (void) SyncImageSettings(mogrify_info,*image);
2361 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2369 if (LocaleCompare(
"paint",option+1) == 0)
2371 (void) SyncImageSettings(mogrify_info,*image);
2372 (void) ParseGeometry(argv[i+1],&geometry_info);
2373 mogrify_image=OilPaintImage(*image,geometry_info.rho,exception);
2376 if (LocaleCompare(
"pen",option+1) == 0)
2380 (void) QueryColorDatabase(
"none",&draw_info->fill,exception);
2383 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2386 if (LocaleCompare(
"perceptible",option+1) == 0)
2391 (void) SyncImageSettings(mogrify_info,*image);
2392 (void) PerceptibleImageChannel(*image,channel,StringToDouble(
2393 argv[i+1],(
char **) NULL));
2394 InheritException(exception,&(*image)->exception);
2397 if (LocaleCompare(
"pointsize",option+1) == 0)
2400 (void) ParseGeometry(
"12",&geometry_info);
2402 (
void) ParseGeometry(argv[i+1],&geometry_info);
2403 draw_info->pointsize=geometry_info.rho;
2406 if (LocaleCompare(
"polaroid",option+1) == 0)
2417 (void) SyncImageSettings(mogrify_info,*image);
2418 random_info=AcquireRandomInfo();
2419 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2420 random_info=DestroyRandomInfo(random_info);
2423 SetGeometryInfo(&geometry_info);
2424 flags=ParseGeometry(argv[i+1],&geometry_info);
2425 angle=geometry_info.rho;
2427 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2430 if (LocaleCompare(
"posterize",option+1) == 0)
2435 (void) SyncImageSettings(mogrify_info,*image);
2436 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2437 quantize_info->dither);
2438 InheritException(exception,&(*image)->exception);
2441 if (LocaleCompare(
"preview",option+1) == 0)
2449 (void) SyncImageSettings(mogrify_info,*image);
2451 preview_type=UndefinedPreview;
2453 preview_type=(PreviewType) ParseCommandOption(
2454 MagickPreviewOptions,MagickFalse,argv[i+1]);
2455 mogrify_image=PreviewImage(*image,preview_type,exception);
2458 if (LocaleCompare(
"profile",option+1) == 0)
2475 (void) SyncImageSettings(mogrify_info,*image);
2481 (void) ProfileImage(*image,argv[i+1],(
const unsigned char *)
2483 InheritException(exception,&(*image)->exception);
2489 profile_info=CloneImageInfo(mogrify_info);
2490 profile=GetImageProfile(*image,
"iptc");
2491 if (profile != (StringInfo *) NULL)
2492 profile_info->profile=(
void *) CloneStringInfo(profile);
2493 sans_exception=AcquireExceptionInfo();
2494 profile_image=GetImageCache(profile_info,argv[i+1],sans_exception);
2495 sans_exception=DestroyExceptionInfo(sans_exception);
2496 profile_info=DestroyImageInfo(profile_info);
2497 if (profile_image == (Image *) NULL)
2502 profile_info=CloneImageInfo(mogrify_info);
2503 (void) CopyMagickString(profile_info->filename,argv[i+1],
2505 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2506 if (profile != (StringInfo *) NULL)
2508 (void) SetImageInfo(profile_info,0,exception);
2509 (void) ProfileImage(*image,profile_info->magick,
2510 GetStringInfoDatum(profile),(size_t)
2511 GetStringInfoLength(profile),MagickFalse);
2512 profile=DestroyStringInfo(profile);
2514 profile_info=DestroyImageInfo(profile_info);
2517 ResetImageProfileIterator(profile_image);
2518 name=GetNextImageProfile(profile_image);
2519 while (name != (
const char *) NULL)
2521 profile=GetImageProfile(profile_image,name);
2522 if (profile != (StringInfo *) NULL)
2523 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2524 (size_t) GetStringInfoLength(profile),MagickFalse);
2525 name=GetNextImageProfile(profile_image);
2527 profile_image=DestroyImage(profile_image);
2534 if (LocaleCompare(
"quantize",option+1) == 0)
2538 quantize_info->colorspace=UndefinedColorspace;
2541 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2542 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2549 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
2550 LocaleCompare(
"rotational-blur",option+1) == 0)
2555 (void) SyncImageSettings(mogrify_info,*image);
2556 mogrify_image=RotationalBlurImageChannel(*image,channel,
2557 StringToDouble(argv[i+1],(
char **) NULL),exception);
2560 if (LocaleCompare(
"raise",option+1) == 0)
2565 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2566 (void) RaiseImage(*image,&geometry,*option ==
'-' ? MagickTrue :
2568 InheritException(exception,&(*image)->exception);
2571 if (LocaleCompare(
"random-threshold",option+1) == 0)
2576 (void) SyncImageSettings(mogrify_info,*image);
2577 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2581 if (LocaleCompare(
"recolor",option+1) == 0)
2586 (void) SyncImageSettings(mogrify_info,*image);
2587 kernel=AcquireKernelInfo(argv[i+1]);
2588 if (kernel == (KernelInfo *) NULL)
2590 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2591 kernel=DestroyKernelInfo(kernel);
2594 if (LocaleCompare(
"region",option+1) == 0)
2596 (void) SyncImageSettings(mogrify_info,*image);
2597 if (region_image != (Image *) NULL)
2602 (void) CompositeImage(region_image,region_image->matte !=
2603 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2604 region_geometry.x,region_geometry.y);
2605 InheritException(exception,®ion_image->exception);
2606 *image=DestroyImage(*image);
2607 *image=region_image;
2608 region_image=(Image *) NULL;
2615 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2617 mogrify_image=CropImage(*image,®ion_geometry,exception);
2618 if (mogrify_image == (Image *) NULL)
2620 region_image=(*image);
2621 *image=mogrify_image;
2622 mogrify_image=(Image *) NULL;
2625 if (LocaleCompare(
"render",option+1) == 0)
2627 (void) SyncImageSettings(mogrify_info,*image);
2628 draw_info->render=(*option ==
'+') ? MagickTrue : MagickFalse;
2631 if (LocaleCompare(
"remap",option+1) == 0)
2639 (void) SyncImageSettings(mogrify_info,*image);
2642 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2643 if (remap_image == (Image *) NULL)
2645 (void) RemapImage(quantize_info,*image,remap_image);
2646 InheritException(exception,&(*image)->exception);
2647 remap_image=DestroyImage(remap_image);
2650 if (LocaleCompare(
"repage",option+1) == 0)
2654 (void) ParseAbsoluteGeometry(
"0x0+0+0",&(*image)->page);
2657 (void) ResetImagePage(*image,argv[i+1]);
2658 InheritException(exception,&(*image)->exception);
2661 if (LocaleCompare(
"resample",option+1) == 0)
2666 (void) SyncImageSettings(mogrify_info,*image);
2667 flags=ParseGeometry(argv[i+1],&geometry_info);
2668 if ((flags & SigmaValue) == 0)
2669 geometry_info.sigma=geometry_info.rho;
2670 mogrify_image=ResampleImage(*image,geometry_info.rho,
2671 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2674 if (LocaleCompare(
"resize",option+1) == 0)
2679 (void) SyncImageSettings(mogrify_info,*image);
2680 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2681 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2682 (*image)->filter,(*image)->blur,exception);
2685 if (LocaleCompare(
"roll",option+1) == 0)
2690 (void) SyncImageSettings(mogrify_info,*image);
2691 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2692 if ((flags & PercentValue) != 0)
2694 geometry.x*=(double) (*image)->columns/100.0;
2695 geometry.y*=(
double) (*image)->rows/100.0;
2697 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2700 if (LocaleCompare(
"rotate",option+1) == 0)
2708 (void) SyncImageSettings(mogrify_info,*image);
2709 if (strchr(argv[i+1],
'>') != (
char *) NULL)
2710 if ((*image)->columns <= (*image)->rows)
2712 if (strchr(argv[i+1],
'<') != (
char *) NULL)
2713 if ((*image)->columns >= (*image)->rows)
2718 geometry=ConstantString(argv[i+1]);
2719 (void) SubstituteString(&geometry,
">",
"");
2720 (void) SubstituteString(&geometry,
"<",
"");
2721 (void) ParseGeometry(geometry,&geometry_info);
2722 geometry=DestroyString(geometry);
2723 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2730 if (LocaleCompare(
"sample",option+1) == 0)
2735 (void) SyncImageSettings(mogrify_info,*image);
2736 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2737 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2741 if (LocaleCompare(
"scale",option+1) == 0)
2746 (void) SyncImageSettings(mogrify_info,*image);
2747 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2748 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2752 if (LocaleCompare(
"selective-blur",option+1) == 0)
2757 (void) SyncImageSettings(mogrify_info,*image);
2758 flags=ParseGeometry(argv[i+1],&geometry_info);
2759 if ((flags & PercentValue) != 0)
2760 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2761 mogrify_image=SelectiveBlurImageChannel(*image,channel,
2762 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2765 if (LocaleCompare(
"separate",option+1) == 0)
2771 (void) SyncImageSettings(mogrify_info,*image);
2772 mogrify_image=SeparateImages(*image,channel,exception);
2775 if (LocaleCompare(
"sepia-tone",option+1) == 0)
2783 (void) SyncImageSettings(mogrify_info,*image);
2784 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2786 mogrify_image=SepiaToneImage(*image,threshold,exception);
2789 if (LocaleCompare(
"segment",option+1) == 0)
2794 (void) SyncImageSettings(mogrify_info,*image);
2795 flags=ParseGeometry(argv[i+1],&geometry_info);
2796 if ((flags & SigmaValue) == 0)
2797 geometry_info.sigma=1.0;
2798 (void) SegmentImage(*image,(*image)->colorspace,
2799 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2800 InheritException(exception,&(*image)->exception);
2803 if (LocaleCompare(
"set",option+1) == 0)
2813 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2814 (void) DeleteImageRegistry(argv[i+1]+9);
2816 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2818 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2819 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2822 (
void) DeleteImageProperty(*image,argv[i+1]);
2825 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2826 InheritException(exception,&(*image)->exception);
2827 if (value == (
char *) NULL)
2829 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
2830 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2833 if (LocaleNCompare(argv[i+1],
"option:",7) == 0)
2835 (void) SetImageOption(image_info,argv[i+1]+7,value);
2836 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2837 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2840 (
void) SetImageProperty(*image,argv[i+1],value);
2841 value=DestroyString(value);
2844 if (LocaleCompare(
"shade",option+1) == 0)
2849 (void) SyncImageSettings(mogrify_info,*image);
2850 flags=ParseGeometry(argv[i+1],&geometry_info);
2851 if ((flags & SigmaValue) == 0)
2852 geometry_info.sigma=1.0;
2853 mogrify_image=ShadeImage(*image,(*option ==
'-') ? MagickTrue :
2854 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2857 if (LocaleCompare(
"shadow",option+1) == 0)
2862 (void) SyncImageSettings(mogrify_info,*image);
2863 flags=ParseGeometry(argv[i+1],&geometry_info);
2864 if ((flags & SigmaValue) == 0)
2865 geometry_info.sigma=1.0;
2866 if ((flags & XiValue) == 0)
2867 geometry_info.xi=4.0;
2868 if ((flags & PsiValue) == 0)
2869 geometry_info.psi=4.0;
2870 mogrify_image=ShadowImage(*image,geometry_info.rho,
2871 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2872 ceil(geometry_info.psi-0.5),exception);
2875 if (LocaleCompare(
"sharpen",option+1) == 0)
2880 (void) SyncImageSettings(mogrify_info,*image);
2881 flags=ParseGeometry(argv[i+1],&geometry_info);
2882 if ((flags & SigmaValue) == 0)
2883 geometry_info.sigma=1.0;
2884 mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2885 geometry_info.sigma,exception);
2888 if (LocaleCompare(
"shave",option+1) == 0)
2893 (void) SyncImageSettings(mogrify_info,*image);
2894 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2895 mogrify_image=ShaveImage(*image,&geometry,exception);
2898 if (LocaleCompare(
"shear",option+1) == 0)
2903 (void) SyncImageSettings(mogrify_info,*image);
2904 flags=ParseGeometry(argv[i+1],&geometry_info);
2905 if ((flags & SigmaValue) == 0)
2906 geometry_info.sigma=geometry_info.rho;
2907 mogrify_image=ShearImage(*image,geometry_info.rho,
2908 geometry_info.sigma,exception);
2911 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
2916 (void) SyncImageSettings(mogrify_info,*image);
2917 flags=ParseGeometry(argv[i+1],&geometry_info);
2918 if ((flags & SigmaValue) == 0)
2919 geometry_info.sigma=(double) QuantumRange/2.0;
2920 if ((flags & PercentValue) != 0)
2921 geometry_info.sigma=(
double) QuantumRange*geometry_info.sigma/
2923 (void) SigmoidalContrastImageChannel(*image,channel,
2924 (*option ==
'-') ? MagickTrue : MagickFalse,geometry_info.rho,
2925 geometry_info.sigma);
2926 InheritException(exception,&(*image)->exception);
2929 if (LocaleCompare(
"sketch",option+1) == 0)
2934 (void) SyncImageSettings(mogrify_info,*image);
2935 flags=ParseGeometry(argv[i+1],&geometry_info);
2936 if ((flags & SigmaValue) == 0)
2937 geometry_info.sigma=1.0;
2938 mogrify_image=SketchImage(*image,geometry_info.rho,
2939 geometry_info.sigma,geometry_info.xi,exception);
2942 if (LocaleCompare(
"solarize",option+1) == 0)
2947 (void) SyncImageSettings(mogrify_info,*image);
2948 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
2950 (void) SolarizeImageChannel(*image,channel,threshold,exception);
2953 if (LocaleCompare(
"sparse-color",option+1) == 0)
2964 (void) SyncImageSettings(mogrify_info,*image);
2965 method=(SparseColorMethod) ParseCommandOption(
2966 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2967 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2968 InheritException(exception,&(*image)->exception);
2969 if (arguments == (
char *) NULL)
2971 mogrify_image=SparseColorOption(*image,channel,method,arguments,
2972 option[0] ==
'+' ? MagickTrue : MagickFalse,exception);
2973 arguments=DestroyString(arguments);
2976 if (LocaleCompare(
"splice",option+1) == 0)
2981 (void) SyncImageSettings(mogrify_info,*image);
2982 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2983 mogrify_image=SpliceImage(*image,&geometry,exception);
2986 if (LocaleCompare(
"spread",option+1) == 0)
2991 (void) SyncImageSettings(mogrify_info,*image);
2992 (void) ParseGeometry(argv[i+1],&geometry_info);
2993 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
2996 if (LocaleCompare(
"statistic",option+1) == 0)
3001 (void) SyncImageSettings(mogrify_info,*image);
3002 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
3003 MagickFalse,argv[i+1]);
3004 (void) ParseGeometry(argv[i+2],&geometry_info);
3005 mogrify_image=StatisticImageChannel(*image,channel,type,(
size_t)
3006 geometry_info.rho,(
size_t) geometry_info.sigma,exception);
3009 if (LocaleCompare(
"stretch",option+1) == 0)
3013 draw_info->stretch=UndefinedStretch;
3016 draw_info->stretch=(StretchType) ParseCommandOption(
3017 MagickStretchOptions,MagickFalse,argv[i+1]);
3020 if (LocaleCompare(
"strip",option+1) == 0)
3025 (void) SyncImageSettings(mogrify_info,*image);
3026 (void) StripImage(*image);
3027 InheritException(exception,&(*image)->exception);
3030 if (LocaleCompare(
"stroke",option+1) == 0)
3037 (void) QueryColorDatabase(
"none",&draw_info->stroke,exception);
3038 if (draw_info->stroke_pattern != (Image *) NULL)
3039 draw_info->stroke_pattern=DestroyImage(
3040 draw_info->stroke_pattern);
3043 sans=AcquireExceptionInfo();
3044 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3045 sans=DestroyExceptionInfo(sans);
3046 if (status == MagickFalse)
3047 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3051 if (LocaleCompare(
"strokewidth",option+1) == 0)
3053 draw_info->stroke_width=StringToDouble(argv[i+1],(
char **) NULL);
3056 if (LocaleCompare(
"style",option+1) == 0)
3060 draw_info->style=UndefinedStyle;
3063 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3064 MagickFalse,argv[i+1]);
3067 if (LocaleCompare(
"swirl",option+1) == 0)
3072 (void) SyncImageSettings(mogrify_info,*image);
3073 (void) ParseGeometry(argv[i+1],&geometry_info);
3074 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
3081 if (LocaleCompare(
"threshold",option+1) == 0)
3089 (void) SyncImageSettings(mogrify_info,*image);
3091 threshold=(double) QuantumRange/2;
3093 threshold=StringToDoubleInterval(argv[i+1],(
double) QuantumRange+
3095 (void) BilevelImageChannel(*image,channel,threshold);
3096 InheritException(exception,&(*image)->exception);
3099 if (LocaleCompare(
"thumbnail",option+1) == 0)
3104 (void) SyncImageSettings(mogrify_info,*image);
3105 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3106 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3110 if (LocaleCompare(
"tile",option+1) == 0)
3114 if (draw_info->fill_pattern != (Image *) NULL)
3115 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3118 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3122 if (LocaleCompare(
"tint",option+1) == 0)
3127 (void) SyncImageSettings(mogrify_info,*image);
3128 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3131 if (LocaleCompare(
"transform",option+1) == 0)
3136 (void) SyncImageSettings(mogrify_info,*image);
3137 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3141 if (LocaleCompare(
"transparent",option+1) == 0)
3146 (void) SyncImageSettings(mogrify_info,*image);
3147 (void) QueryMagickColor(argv[i+1],&target,exception);
3148 (void) TransparentPaintImage(*image,&target,(Quantum)
3149 TransparentOpacity,*option ==
'-' ? MagickFalse : MagickTrue);
3150 InheritException(exception,&(*image)->exception);
3153 if (LocaleCompare(
"transpose",option+1) == 0)
3158 (void) SyncImageSettings(mogrify_info,*image);
3159 mogrify_image=TransposeImage(*image,exception);
3162 if (LocaleCompare(
"transverse",option+1) == 0)
3167 (void) SyncImageSettings(mogrify_info,*image);
3168 mogrify_image=TransverseImage(*image,exception);
3171 if (LocaleCompare(
"treedepth",option+1) == 0)
3173 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3176 if (LocaleCompare(
"trim",option+1) == 0)
3181 (void) SyncImageSettings(mogrify_info,*image);
3182 mogrify_image=TrimImage(*image,exception);
3185 if (LocaleCompare(
"type",option+1) == 0)
3190 (void) SyncImageSettings(mogrify_info,*image);
3194 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3196 (*image)->type=UndefinedType;
3197 (void) SetImageType(*image,type);
3198 InheritException(exception,&(*image)->exception);
3205 if (LocaleCompare(
"undercolor",option+1) == 0)
3207 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3211 if (LocaleCompare(
"unique",option+1) == 0)
3215 (void) DeleteImageArtifact(*image,
"identify:unique-colors");
3218 (void) SetImageArtifact(*image,
"identify:unique-colors",
"true");
3219 (void) SetImageArtifact(*image,
"verbose",
"true");
3222 if (LocaleCompare(
"unique-colors",option+1) == 0)
3227 (void) SyncImageSettings(mogrify_info,*image);
3228 mogrify_image=UniqueImageColors(*image,exception);
3231 if (LocaleCompare(
"unsharp",option+1) == 0)
3236 (void) SyncImageSettings(mogrify_info,*image);
3237 flags=ParseGeometry(argv[i+1],&geometry_info);
3238 if ((flags & SigmaValue) == 0)
3239 geometry_info.sigma=1.0;
3240 if ((flags & XiValue) == 0)
3241 geometry_info.xi=1.0;
3242 if ((flags & PsiValue) == 0)
3243 geometry_info.psi=0.05;
3244 mogrify_image=UnsharpMaskImageChannel(*image,channel,
3245 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3246 geometry_info.psi,exception);
3253 if (LocaleCompare(
"verbose",option+1) == 0)
3255 (void) SetImageArtifact(*image,option+1,
3256 *option ==
'+' ?
"false" :
"true");
3259 if (LocaleCompare(
"vignette",option+1) == 0)
3264 (void) SyncImageSettings(mogrify_info,*image);
3265 flags=ParseGeometry(argv[i+1],&geometry_info);
3266 if ((flags & SigmaValue) == 0)
3267 geometry_info.sigma=1.0;
3268 if ((flags & XiValue) == 0)
3269 geometry_info.xi=0.1*(*image)->columns;
3270 if ((flags & PsiValue) == 0)
3271 geometry_info.psi=0.1*(*image)->rows;
3272 if ((flags & PercentValue) != 0)
3274 geometry_info.xi*=(double) (*image)->columns/100.0;
3275 geometry_info.psi*=(
double) (*image)->rows/100.0;
3277 mogrify_image=VignetteImage(*image,geometry_info.rho,
3278 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3279 ceil(geometry_info.psi-0.5),exception);
3282 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
3286 (void) SetImageVirtualPixelMethod(*image,
3287 UndefinedVirtualPixelMethod);
3290 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3291 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3299 if (LocaleCompare(
"wave",option+1) == 0)
3304 (void) SyncImageSettings(mogrify_info,*image);
3305 flags=ParseGeometry(argv[i+1],&geometry_info);
3306 if ((flags & SigmaValue) == 0)
3307 geometry_info.sigma=1.0;
3308 mogrify_image=WaveImage(*image,geometry_info.rho,
3309 geometry_info.sigma,exception);
3312 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3317 (void) SyncImageSettings(mogrify_info,*image);
3318 flags=ParseGeometry(argv[i+1],&geometry_info);
3319 if ((flags & PercentValue) != 0)
3321 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
3322 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
3324 if ((flags & SigmaValue) == 0)
3325 geometry_info.sigma=0.0;
3326 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3327 geometry_info.sigma,exception);
3330 if (LocaleCompare(
"weight",option+1) == 0)
3335 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3338 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3339 draw_info->weight=(size_t) weight;
3342 if (LocaleCompare(
"white-threshold",option+1) == 0)
3347 (void) SyncImageSettings(mogrify_info,*image);
3348 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3350 InheritException(exception,&(*image)->exception);
3361 if (mogrify_image != (Image *) NULL)
3362 ReplaceImageInListReturnLast(image,mogrify_image);
3365 if (region_image != (Image *) NULL)
3370 (void) SyncImageSettings(mogrify_info,*image);
3371 (void) CompositeImage(region_image,region_image->matte != MagickFalse ?
3372 CopyCompositeOp : OverCompositeOp,*image,region_geometry.x,
3374 InheritException(exception,®ion_image->exception);
3375 *image=DestroyImage(*image);
3376 *image=region_image;
3377 region_image = (Image *) NULL;
3382 quantize_info=DestroyQuantizeInfo(quantize_info);
3383 draw_info=DestroyDrawInfo(draw_info);
3384 mogrify_info=DestroyImageInfo(mogrify_info);
3385 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3386 return(status == 0 ? MagickFalse : MagickTrue);
3423 static MagickBooleanType MogrifyUsage(
void)
3427 " -debug events display copious debugging information\n"
3428 " -distribute-cache port\n"
3429 " distributed pixel cache spanning one or more servers\n"
3430 " -help print program options\n"
3431 " -list type print a list of supported option arguments\n"
3432 " -log format format of debugging information\n"
3433 " -version print version information",
3435 " -adaptive-blur geometry\n"
3436 " adaptively blur pixels; decrease effect near edges\n"
3437 " -adaptive-resize geometry\n"
3438 " adaptively resize image using 'mesh' interpolation\n"
3439 " -adaptive-sharpen geometry\n"
3440 " adaptively sharpen pixels; increase effect near edges\n"
3441 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3442 " transparent, extract, background, or shape\n"
3443 " -annotate geometry text\n"
3444 " annotate the image with text\n"
3445 " -auto-gamma automagically adjust gamma level of image\n"
3446 " -auto-level automagically adjust color levels of image\n"
3447 " -auto-orient automagically orient (rotate) image\n"
3448 " -bench iterations measure performance\n"
3449 " -black-threshold value\n"
3450 " force all pixels below the threshold into black\n"
3451 " -blue-shift simulate a scene at nighttime in the moonlight\n"
3452 " -blur geometry reduce image noise and reduce detail levels\n"
3453 " -border geometry surround image with a border of color\n"
3454 " -bordercolor color border color\n"
3455 " -brightness-contrast geometry\n"
3456 " improve brightness / contrast of the image\n"
3457 " -canny geometry detect edges in the image\n"
3458 " -cdl filename color correct with a color decision list\n"
3459 " -charcoal radius simulate a charcoal drawing\n"
3460 " -chop geometry remove pixels from the image interior\n"
3461 " -clamp keep pixel values in range (0-QuantumRange)\n"
3462 " -clip clip along the first path from the 8BIM profile\n"
3463 " -clip-mask filename associate a clip mask with the image\n"
3464 " -clip-path id clip along a named path from the 8BIM profile\n"
3465 " -colorize value colorize the image with the fill color\n"
3466 " -color-matrix matrix apply color correction to the image\n"
3467 " -connected-components connectivity\n"
3468 " connected-components uniquely labeled\n"
3469 " -contrast enhance or reduce the image contrast\n"
3470 " -contrast-stretch geometry\n"
3471 " improve contrast by `stretching' the intensity range\n"
3472 " -convolve coefficients\n"
3473 " apply a convolution kernel to the image\n"
3474 " -cycle amount cycle the image colormap\n"
3475 " -decipher filename convert cipher pixels to plain pixels\n"
3476 " -deskew threshold straighten an image\n"
3477 " -despeckle reduce the speckles within an image\n"
3478 " -distort method args\n"
3479 " distort images according to given method ad args\n"
3480 " -draw string annotate the image with a graphic primitive\n"
3481 " -edge radius apply a filter to detect edges in the image\n"
3482 " -encipher filename convert plain pixels to cipher pixels\n"
3483 " -emboss radius emboss an image\n"
3484 " -enhance apply a digital filter to enhance a noisy image\n"
3485 " -equalize perform histogram equalization to an image\n"
3486 " -evaluate operator value\n"
3487 " evaluate an arithmetic, relational, or logical expression\n"
3488 " -extent geometry set the image size\n"
3489 " -extract geometry extract area from image\n"
3490 " -hough-lines geometry\n"
3491 " identify lines in the image\n"
3492 " -features distance analyze image features (e.g. contrast, correlation)\n"
3493 " -fft implements the discrete Fourier transform (DFT)\n"
3494 " -flip flip image vertically\n"
3495 " -floodfill geometry color\n"
3496 " floodfill the image with color\n"
3497 " -flop flop image horizontally\n"
3498 " -frame geometry surround image with an ornamental border\n"
3499 " -function name parameters\n"
3500 " apply function over image values\n"
3501 " -gamma value level of gamma correction\n"
3502 " -gaussian-blur geometry\n"
3503 " reduce image noise and reduce detail levels\n"
3504 " -geometry geometry preferred size or location of the image\n"
3505 " -grayscale method convert image to grayscale\n"
3506 " -help print program options\n"
3507 " -identify identify the format and characteristics of the image\n"
3508 " -ift implements the inverse discrete Fourier transform (DFT)\n"
3509 " -implode amount implode image pixels about the center\n"
3510 " -kuwahara geometry edge preserving noise reduction filter\n"
3511 " -lat geometry local adaptive thresholding\n"
3512 " -layers method optimize, merge, or compare image layers\n"
3513 " -level value adjust the level of image contrast\n"
3514 " -level-colors color,color\n"
3515 " level image with the given colors\n"
3516 " -linear-stretch geometry\n"
3517 " improve contrast by `stretching with saturation'\n"
3518 " -liquid-rescale geometry\n"
3519 " rescale image with seam-carving\n"
3520 " -local-contrast geometry\n"
3521 " enhance local contrast\n"
3522 " -magnify double the size of the image with pixel art scaling\n"
3523 " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3524 " -median geometry apply a median filter to the image\n"
3525 " -mode geometry make each pixel the 'predominant color' of the\n"
3527 " -modulate value vary the brightness, saturation, and hue\n"
3528 " -monochrome transform image to black and white\n"
3529 " -morphology method kernel\n"
3530 " apply a morphology method to the image\n"
3531 " -motion-blur geometry\n"
3532 " simulate motion blur\n"
3533 " -negate replace every pixel with its complementary color \n"
3534 " -noise geometry add or reduce noise in an image\n"
3535 " -normalize transform image to span the full range of colors\n"
3536 " -opaque color change this color to the fill color\n"
3537 " -ordered-dither NxN\n"
3538 " add a noise pattern to the image with specific\n"
3540 " -paint radius simulate an oil painting\n"
3541 " -perceptible epsilon\n"
3542 " pixel value less than |epsilon| become epsilon or\n"
3544 " -polaroid angle simulate a Polaroid picture\n"
3545 " -posterize levels reduce the image to a limited number of color levels\n"
3546 " -profile filename add, delete, or apply an image profile\n"
3547 " -quantize colorspace reduce colors in this colorspace\n"
3548 " -radial-blur angle radial blur the image\n"
3549 " -raise value lighten/darken image edges to create a 3-D effect\n"
3550 " -random-threshold low,high\n"
3551 " random threshold the image\n"
3552 " -region geometry apply options to a portion of the image\n"
3553 " -render render vector graphics\n"
3554 " -resample geometry change the resolution of an image\n"
3555 " -resize geometry resize the image\n"
3556 " -roll geometry roll an image vertically or horizontally\n"
3557 " -rotate degrees apply Paeth rotation to the image\n"
3558 " -sample geometry scale image with pixel sampling\n"
3559 " -scale geometry scale the image\n"
3560 " -segment values segment an image\n"
3561 " -selective-blur geometry\n"
3562 " selectively blur pixels within a contrast threshold\n"
3563 " -sepia-tone threshold\n"
3564 " simulate a sepia-toned photo\n"
3565 " -set property value set an image property\n"
3566 " -shade degrees shade the image using a distant light source\n"
3567 " -shadow geometry simulate an image shadow\n"
3568 " -sharpen geometry sharpen the image\n"
3569 " -shave geometry shave pixels from the image edges\n"
3570 " -shear geometry slide one edge of the image along the X or Y axis\n"
3571 " -sigmoidal-contrast geometry\n"
3572 " increase the contrast without saturating highlights or\n"
3574 " -sketch geometry simulate a pencil sketch\n"
3575 " -solarize threshold negate all pixels above the threshold level\n"
3576 " -sparse-color method args\n"
3577 " fill in a image based on a few color points\n"
3578 " -splice geometry splice the background color into the image\n"
3579 " -spread radius displace image pixels by a random amount\n"
3580 " -statistic type radius\n"
3581 " replace each pixel with corresponding statistic from the neighborhood\n"
3582 " -strip strip image of all profiles and comments\n"
3583 " -swirl degrees swirl image pixels about the center\n"
3584 " -threshold value threshold the image\n"
3585 " -thumbnail geometry create a thumbnail of the image\n"
3586 " -tile filename tile image when filling a graphic primitive\n"
3587 " -tint value tint the image with the fill color\n"
3588 " -transform affine transform image\n"
3589 " -transparent color make this color transparent within the image\n"
3590 " -transpose flip image vertically and rotate 90 degrees\n"
3591 " -transverse flop image horizontally and rotate 270 degrees\n"
3592 " -trim trim image edges\n"
3593 " -type type image type\n"
3594 " -unique-colors discard all but one of any pixel color\n"
3595 " -unsharp geometry sharpen the image\n"
3596 " -vignette geometry soften the edges of the image in vignette style\n"
3597 " -wave geometry alter an image along a sine wave\n"
3598 " -wavelet-denoise threshold\n"
3599 " removes noise from the image using a wavelet transform\n"
3600 " -white-threshold value\n"
3601 " force all pixels above the threshold into white",
3602 sequence_operators[] =
3603 " -affinity filename transform image colors to match this set of colors\n"
3604 " -append append an image sequence\n"
3605 " -clut apply a color lookup table to the image\n"
3606 " -coalesce merge a sequence of images\n"
3607 " -combine combine a sequence of images\n"
3608 " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3609 " -complex operator perform complex mathematics on an image sequence\n"
3610 " -composite composite image\n"
3611 " -copy geometry offset\n"
3612 " copy pixels from one area of an image to another\n"
3613 " -crop geometry cut out a rectangular region of the image\n"
3614 " -deconstruct break down an image sequence into constituent parts\n"
3615 " -evaluate-sequence operator\n"
3616 " evaluate an arithmetic, relational, or logical expression\n"
3617 " -flatten flatten a sequence of images\n"
3618 " -fx expression apply mathematical expression to an image channel(s)\n"
3619 " -hald-clut apply a Hald color lookup table to the image\n"
3620 " -layers method optimize, merge, or compare image layers\n"
3621 " -morph value morph an image sequence\n"
3622 " -mosaic create a mosaic from an image sequence\n"
3623 " -poly terms build a polynomial from the image sequence and the corresponding\n"
3624 " terms (coefficients and degree pairs).\n"
3625 " -print string interpret string and print to console\n"
3626 " -process arguments process the image with a custom image filter\n"
3627 " -separate separate an image channel into a grayscale image\n"
3628 " -smush geometry smush an image sequence together\n"
3629 " -write filename write images to this file",
3631 " -adjoin join images into a single multi-image file\n"
3632 " -affine matrix affine transform matrix\n"
3633 " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3634 " -antialias remove pixel-aliasing\n"
3635 " -authenticate password\n"
3636 " decipher image with this password\n"
3637 " -attenuate value lessen (or intensify) when adding noise to an image\n"
3638 " -background color background color\n"
3639 " -bias value add bias when convolving an image\n"
3640 " -black-point-compensation\n"
3641 " use black point compensation\n"
3642 " -blue-primary point chromaticity blue primary point\n"
3643 " -bordercolor color border color\n"
3644 " -caption string assign a caption to an image\n"
3645 " -cdl filename color correct with a color decision list\n"
3646 " -channel type apply option to select image channels\n"
3647 " -colors value preferred number of colors in the image\n"
3648 " -colorspace type alternate image colorspace\n"
3649 " -comment string annotate image with comment\n"
3650 " -compose operator set image composite operator\n"
3651 " -compress type type of pixel compression when writing the image\n"
3652 " -decipher filename convert cipher pixels to plain pixels\n"
3653 " -define format:option\n"
3654 " define one or more image format options\n"
3655 " -delay value display the next image after pausing\n"
3656 " -density geometry horizontal and vertical density of the image\n"
3657 " -depth value image depth\n"
3658 " -direction type render text right-to-left or left-to-right\n"
3659 " -display server get image or font from this X server\n"
3660 " -dispose method layer disposal method\n"
3661 " -dither method apply error diffusion to image\n"
3662 " -encipher filename convert plain pixels to cipher pixels\n"
3663 " -encoding type text encoding type\n"
3664 " -endian type endianness (MSB or LSB) of the image\n"
3665 " -family name render text with this font family\n"
3666 " -features distance analyze image features (e.g. contrast, correlation)\n"
3667 " -fill color color to use when filling a graphic primitive\n"
3668 " -filter type use this filter when resizing an image\n"
3669 " -flatten flatten a sequence of images\n"
3670 " -font name render text with this font\n"
3671 " -format \"string\" output formatted image characteristics\n"
3672 " -function name apply a function to the image\n"
3673 " -fuzz distance colors within this distance are considered equal\n"
3674 " -gravity type horizontal and vertical text placement\n"
3675 " -green-primary point chromaticity green primary point\n"
3676 " -intensity method method to generate intensity value from pixel\n"
3677 " -intent type type of rendering intent when managing the image color\n"
3678 " -interlace type type of image interlacing scheme\n"
3679 " -interline-spacing value\n"
3680 " set the space between two text lines\n"
3681 " -interpolate method pixel color interpolation method\n"
3682 " -interword-spacing value\n"
3683 " set the space between two words\n"
3684 " -kerning value set the space between two letters\n"
3685 " -label string assign a label to an image\n"
3686 " -limit type value pixel cache resource limit\n"
3687 " -loop iterations add Netscape loop extension to your GIF animation\n"
3688 " -mask filename associate a mask with the image\n"
3689 " -matte store matte channel if the image has one\n"
3690 " -mattecolor color frame color\n"
3691 " -monitor monitor progress\n"
3692 " -morphology method kernel\n"
3693 " apply a morphology method to the image\n"
3694 " -orient type image orientation\n"
3695 " -page geometry size and location of an image canvas (setting)\n"
3696 " -path path write images to this path on disk\n"
3697 " -ping efficiently determine image attributes\n"
3698 " -pointsize value font point size\n"
3699 " -precision value maximum number of significant digits to print\n"
3700 " -preview type image preview type\n"
3701 " -quality value JPEG/MIFF/PNG compression level\n"
3702 " -quiet suppress all warning messages\n"
3703 " -red-primary point chromaticity red primary point\n"
3704 " -regard-warnings pay attention to warning messages\n"
3705 " -remap filename transform image colors to match this set of colors\n"
3706 " -repage geometry size and location of an image canvas\n"
3707 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3708 " -sampling-factor geometry\n"
3709 " horizontal and vertical sampling factor\n"
3710 " -scene value image scene number\n"
3711 " -seed value seed a new sequence of pseudo-random numbers\n"
3712 " -size geometry width and height of image\n"
3713 " -stretch type render text with this font stretch\n"
3714 " -stroke color graphic primitive stroke color\n"
3715 " -strokewidth value graphic primitive stroke width\n"
3716 " -style type render text with this font style\n"
3717 " -synchronize synchronize image to storage device\n"
3718 " -taint declare the image as modified\n"
3719 " -texture filename name of texture to tile onto the image background\n"
3720 " -tile-offset geometry\n"
3722 " -treedepth value color tree depth\n"
3723 " -transparent-color color\n"
3724 " transparent color\n"
3725 " -undercolor color annotation bounding box color\n"
3726 " -units type the units of image resolution\n"
3727 " -verbose print detailed information about the image\n"
3728 " -view FlashPix viewing transforms\n"
3729 " -virtual-pixel method\n"
3730 " virtual pixel access method\n"
3731 " -weight type render text with this font weight\n"
3732 " -white-point point chromaticity white point",
3734 " -delete indexes delete the image from the image sequence\n"
3735 " -duplicate count,indexes\n"
3736 " duplicate an image one or more times\n"
3737 " -insert index insert last image into the image sequence\n"
3738 " -reverse reverse image sequence\n"
3739 " -swap indexes swap two images in the image sequence";
3741 ListMagickVersion(stdout);
3742 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
3744 (void) printf(
"\nImage Settings:\n");
3745 (void) puts(settings);
3746 (void) printf(
"\nImage Operators:\n");
3747 (void) puts(operators);
3748 (void) printf(
"\nImage Sequence Operators:\n");
3749 (void) puts(sequence_operators);
3750 (void) printf(
"\nImage Stack Operators:\n");
3751 (void) puts(stack_operators);
3752 (void) printf(
"\nMiscellaneous Options:\n");
3753 (void) puts(miscellaneous);
3755 "\nBy default, the image format of `file' is determined by its magic\n");
3757 "number. To specify a particular image format, precede the filename\n");
3759 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3761 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3762 (void) printf(
"'-' for standard input or output.\n");
3766 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3767 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
3769 #define DestroyMogrify() \
3771 if (format != (char *) NULL) \
3772 format=DestroyString(format); \
3773 if (path != (char *) NULL) \
3774 path=DestroyString(path); \
3775 DestroyImageStack(); \
3776 for (i=0; i < (ssize_t) argc; i++) \
3777 argv[i]=DestroyString(argv[i]); \
3778 argv=(char **) RelinquishMagickMemory(argv); \
3780 #define ThrowMogrifyException(asperity,tag,option) \
3782 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3785 return(MagickFalse); \
3787 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3789 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3790 "InvalidArgument","`%s': %s",argument,option); \
3792 return(MagickFalse); \
3804 image_stack[MaxImageStackDepth+1];
3812 respect_parenthesis;
3824 wand_unreferenced(metadata);
3829 assert(image_info != (ImageInfo *) NULL);
3830 assert(image_info->signature == MagickCoreSignature);
3831 assert(exception != (ExceptionInfo *) NULL);
3832 if (IsEventLogging() != MagickFalse)
3833 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3837 if ((LocaleCompare(
"version",option+1) == 0) ||
3838 (LocaleCompare(
"-version",option+1) == 0))
3840 ListMagickVersion(stdout);
3845 return(MogrifyUsage());
3846 format=(
char *) NULL;
3848 global_colormap=MagickFalse;
3852 option=(
char *) NULL;
3854 respect_parenthesis=MagickFalse;
3859 ReadCommandlLine(argc,&argv);
3860 status=ExpandFilenames(&argc,&argv);
3861 if (status == MagickFalse)
3862 ThrowMogrifyException(ResourceLimitError,
"MemoryAllocationFailed",
3863 GetExceptionMessage(errno));
3864 for (i=1; i < (ssize_t) argc; i++)
3867 if (LocaleCompare(option,
"(") == 0)
3869 FireImageStack(MagickFalse,MagickTrue,pend);
3870 if (k == MaxImageStackDepth)
3871 ThrowMogrifyException(OptionError,
"ParenthesisNestedTooDeeply",
3876 if (LocaleCompare(option,
")") == 0)
3878 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3880 ThrowMogrifyException(OptionError,
"UnableToParseExpression",option);
3884 if (IsCommandOption(option) == MagickFalse)
3887 backup_filename[MaxTextExtent],
3889 magic[MagickPathExtent];
3900 FireImageStack(MagickFalse,MagickFalse,pend);
3902 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
3904 (void) SetImageOption(image_info,
"filename",filename);
3905 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3906 images=ReadImages(image_info,exception);
3907 status&=(images != (Image *) NULL) &&
3908 (exception->severity < ErrorException);
3909 if (images == (Image *) NULL)
3911 properties=(*GetBlobProperties(images));
3912 if (format != (
char *) NULL)
3913 GetPathComponent(images->magick_filename,BasePathSansCompressExtension,
3915 if (path != (
char *) NULL)
3917 GetPathComponent(option,TailPath,filename);
3918 (void) FormatLocaleString(images->filename,MaxTextExtent,
"%s%c%s",
3919 path,*DirectorySeparator,filename);
3921 if (format != (
char *) NULL)
3922 AppendImageFormat(format,images->filename);
3923 AppendImageStack(images);
3924 FinalizeImageSettings(image_info,image,MagickFalse);
3925 if (image == (Image *) NULL)
3927 if (global_colormap != MagickFalse)
3932 quantize_info=AcquireQuantizeInfo(image_info);
3933 (void) RemapImages(quantize_info,images,(Image *) NULL);
3934 quantize_info=DestroyQuantizeInfo(quantize_info);
3936 *backup_filename=
'\0';
3938 GetPathComponent(filename,MagickPath,magic);
3942 filename[MagickPathExtent];
3944 if (format != (
char *) NULL)
3945 (void) CopyMagickString(magic,format,MagickPathExtent);
3946 (void) FormatLocaleString(filename,MagickPathExtent,
"%s:%s",magic,
3948 (void) CopyMagickString(image->filename,filename,MagickPathExtent);
3950 if ((LocaleCompare(image->filename,
"-") != 0) &&
3951 (IsPathWritable(image->filename) != MagickFalse))
3959 (void) CopyMagickString(backup_filename,image->filename,
3961 for (i=0; i < 6; i++)
3963 (void) ConcatenateMagickString(backup_filename,
"~",MaxTextExtent);
3964 if (IsPathAccessible(backup_filename) == MagickFalse)
3967 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3968 (rename_utf8(image->filename,backup_filename) != 0))
3969 *backup_filename=
'\0';
3974 image_info->synchronize=MagickTrue;
3975 status&=WriteImages(image_info,image,image->filename,exception);
3976 if (status != MagickFalse)
3978 #if defined(MAGICKCORE_HAVE_UTIME)
3983 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3984 "preserve-timestamp"));
3985 if (preserve_timestamp != MagickFalse)
3990 timestamp.actime=properties.st_atime;
3991 timestamp.modtime=properties.st_mtime;
3992 (void) utime(image->filename,×tamp);
3996 if (*backup_filename !=
'\0')
3997 (void) remove_utf8(backup_filename);
3999 RemoveAllImageStack();
4002 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4003 switch (*(option+1))
4007 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
4010 if (i == (ssize_t) argc)
4011 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4012 if (IsGeometry(argv[i]) == MagickFalse)
4013 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4016 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
4019 if (i == (ssize_t) argc)
4020 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4021 if (IsGeometry(argv[i]) == MagickFalse)
4022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4025 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
4028 if (i == (ssize_t) argc)
4029 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4030 if (IsGeometry(argv[i]) == MagickFalse)
4031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4034 if (LocaleCompare(
"affine",option+1) == 0)
4039 if (i == (ssize_t) argc)
4040 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4041 if (IsGeometry(argv[i]) == MagickFalse)
4042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4045 if (LocaleCompare(
"alpha",option+1) == 0)
4053 if (i == (ssize_t) argc)
4054 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4055 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
4057 ThrowMogrifyException(OptionError,
"UnrecognizedAlphaChannelType",
4061 if (LocaleCompare(
"annotate",option+1) == 0)
4066 if (i == (ssize_t) argc)
4067 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4068 if (IsGeometry(argv[i]) == MagickFalse)
4069 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4070 if (i == (ssize_t) argc)
4071 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4075 if (LocaleCompare(
"antialias",option+1) == 0)
4077 if (LocaleCompare(
"append",option+1) == 0)
4079 if (LocaleCompare(
"attenuate",option+1) == 0)
4084 if (i == (ssize_t) argc)
4085 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4086 if (IsGeometry(argv[i]) == MagickFalse)
4087 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4090 if (LocaleCompare(
"authenticate",option+1) == 0)
4095 if (i == (ssize_t) argc)
4096 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4099 if (LocaleCompare(
"auto-gamma",option+1) == 0)
4101 if (LocaleCompare(
"auto-level",option+1) == 0)
4103 if (LocaleCompare(
"auto-orient",option+1) == 0)
4105 if (LocaleCompare(
"average",option+1) == 0)
4107 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4111 if (LocaleCompare(
"background",option+1) == 0)
4116 if (i == (ssize_t) argc)
4117 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4120 if (LocaleCompare(
"bias",option+1) == 0)
4125 if (i == (ssize_t) argc)
4126 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4127 if (IsGeometry(argv[i]) == MagickFalse)
4128 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4131 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
4133 if (LocaleCompare(
"black-threshold",option+1) == 0)
4138 if (i == (ssize_t) argc)
4139 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4140 if (IsGeometry(argv[i]) == MagickFalse)
4141 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4144 if (LocaleCompare(
"blue-primary",option+1) == 0)
4149 if (i == (ssize_t) argc)
4150 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4151 if (IsGeometry(argv[i]) == MagickFalse)
4152 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4155 if (LocaleCompare(
"blue-shift",option+1) == 0)
4158 if (i == (ssize_t) argc)
4159 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4160 if (IsGeometry(argv[i]) == MagickFalse)
4161 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4164 if (LocaleCompare(
"blur",option+1) == 0)
4167 if (i == (ssize_t) argc)
4168 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4169 if (IsGeometry(argv[i]) == MagickFalse)
4170 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4173 if (LocaleCompare(
"border",option+1) == 0)
4178 if (i == (ssize_t) argc)
4179 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4180 if (IsGeometry(argv[i]) == MagickFalse)
4181 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4184 if (LocaleCompare(
"bordercolor",option+1) == 0)
4189 if (i == (ssize_t) argc)
4190 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4193 if (LocaleCompare(
"box",option+1) == 0)
4198 if (i == (ssize_t) argc)
4199 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4202 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
4205 if (i == (ssize_t) argc)
4206 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4207 if (IsGeometry(argv[i]) == MagickFalse)
4208 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4211 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4215 if (LocaleCompare(
"cache",option+1) == 0)
4220 if (i == (ssize_t) argc)
4221 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4222 if (IsGeometry(argv[i]) == MagickFalse)
4223 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4226 if (LocaleCompare(
"canny",option+1) == 0)
4231 if (i == (ssize_t) argc)
4232 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4233 if (IsGeometry(argv[i]) == MagickFalse)
4234 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4237 if (LocaleCompare(
"caption",option+1) == 0)
4242 if (i == (ssize_t) argc)
4243 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4246 if (LocaleCompare(
"channel",option+1) == 0)
4254 if (i == (ssize_t) argc)
4255 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4256 channel=ParseChannelOption(argv[i]);
4258 ThrowMogrifyException(OptionError,
"UnrecognizedChannelType",
4262 if (LocaleCompare(
"cdl",option+1) == 0)
4267 if (i == (ssize_t) argc)
4268 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4271 if (LocaleCompare(
"charcoal",option+1) == 0)
4276 if (i == (ssize_t) argc)
4277 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4278 if (IsGeometry(argv[i]) == MagickFalse)
4279 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4282 if (LocaleCompare(
"chop",option+1) == 0)
4287 if (i == (ssize_t) argc)
4288 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4289 if (IsGeometry(argv[i]) == MagickFalse)
4290 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4293 if (LocaleCompare(
"clamp",option+1) == 0)
4295 if (LocaleCompare(
"clip",option+1) == 0)
4297 if (LocaleCompare(
"clip-mask",option+1) == 0)
4302 if (i == (ssize_t) argc)
4303 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4306 if (LocaleCompare(
"clut",option+1) == 0)
4308 if (LocaleCompare(
"coalesce",option+1) == 0)
4310 if (LocaleCompare(
"colorize",option+1) == 0)
4315 if (i == (ssize_t) argc)
4316 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4317 if (IsGeometry(argv[i]) == MagickFalse)
4318 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4321 if (LocaleCompare(
"color-matrix",option+1) == 0)
4329 if (i == (ssize_t) argc)
4330 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4331 kernel_info=AcquireKernelInfo(argv[i]);
4332 if (kernel_info == (KernelInfo *) NULL)
4333 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4334 kernel_info=DestroyKernelInfo(kernel_info);
4337 if (LocaleCompare(
"colors",option+1) == 0)
4342 if (i == (ssize_t) argc)
4343 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4344 if (IsGeometry(argv[i]) == MagickFalse)
4345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4348 if (LocaleCompare(
"colorspace",option+1) == 0)
4356 if (i == (ssize_t) argc)
4357 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4358 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4361 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
4365 if (LocaleCompare(
"combine",option+1) == 0)
4370 if (i == (ssize_t) argc)
4371 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4374 if (LocaleCompare(
"comment",option+1) == 0)
4379 if (i == (ssize_t) argc)
4380 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4383 if (LocaleCompare(
"compare",option+1) == 0)
4385 if (LocaleCompare(
"complex",option+1) == 0)
4393 if (i == (ssize_t) argc)
4394 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4395 op=ParseCommandOption(MagickComplexOptions,MagickFalse,argv[i]);
4397 ThrowMogrifyException(OptionError,
"UnrecognizedComplexOperator",
4401 if (LocaleCompare(
"compose",option+1) == 0)
4409 if (i == (ssize_t) argc)
4410 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4411 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4414 ThrowMogrifyException(OptionError,
"UnrecognizedComposeOperator",
4418 if (LocaleCompare(
"composite",option+1) == 0)
4420 if (LocaleCompare(
"compress",option+1) == 0)
4428 if (i == (ssize_t) argc)
4429 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4430 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4433 ThrowMogrifyException(OptionError,
"UnrecognizedImageCompression",
4437 if (LocaleCompare(
"concurrent",option+1) == 0)
4439 if (LocaleCompare(
"connected-components",option+1) == 0)
4442 if (i == (ssize_t) argc)
4443 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4444 if (IsGeometry(argv[i]) == MagickFalse)
4445 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4448 if (LocaleCompare(
"contrast",option+1) == 0)
4450 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
4453 if (i == (ssize_t) argc)
4454 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4455 if (IsGeometry(argv[i]) == MagickFalse)
4456 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4459 if (LocaleCompare(
"convolve",option+1) == 0)
4467 if (i == (ssize_t) argc)
4468 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4469 kernel_info=AcquireKernelInfo(argv[i]);
4470 if (kernel_info == (KernelInfo *) NULL)
4471 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4472 kernel_info=DestroyKernelInfo(kernel_info);
4475 if (LocaleCompare(
"copy",option+1) == 0)
4480 if (i == (ssize_t) argc)
4481 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4482 if (IsGeometry(argv[i]) == MagickFalse)
4483 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4485 if (i == (ssize_t) argc)
4486 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4487 if (IsGeometry(argv[i]) == MagickFalse)
4488 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4491 if (LocaleCompare(
"crop",option+1) == 0)
4496 if (i == (ssize_t) argc)
4497 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4498 if (IsGeometry(argv[i]) == MagickFalse)
4499 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4502 if (LocaleCompare(
"cycle",option+1) == 0)
4507 if (i == (ssize_t) argc)
4508 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4509 if (IsGeometry(argv[i]) == MagickFalse)
4510 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4513 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4517 if (LocaleCompare(
"decipher",option+1) == 0)
4522 if (i == (ssize_t) argc)
4523 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4526 if (LocaleCompare(
"deconstruct",option+1) == 0)
4528 if (LocaleCompare(
"debug",option+1) == 0)
4536 if (i == (ssize_t) argc)
4537 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4538 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4540 ThrowMogrifyException(OptionError,
"UnrecognizedEventType",
4542 (void) SetLogEventMask(argv[i]);
4545 if (LocaleCompare(
"define",option+1) == 0)
4548 if (i == (ssize_t) argc)
4549 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4555 define=GetImageOption(image_info,argv[i]);
4556 if (define == (
const char *) NULL)
4557 ThrowMogrifyException(OptionError,
"NoSuchOption",argv[i]);
4562 if (LocaleCompare(
"delay",option+1) == 0)
4567 if (i == (ssize_t) argc)
4568 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4569 if (IsGeometry(argv[i]) == MagickFalse)
4570 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4573 if (LocaleCompare(
"delete",option+1) == 0)
4578 if (i == (ssize_t) argc)
4579 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4580 if (LocaleNCompare(argv[i],
"registry:",9) == 0)
4582 (void) DeleteImageRegistry(argv[i]+9);
4585 if (IsGeometry(argv[i]) == MagickFalse)
4586 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4589 if (LocaleCompare(
"density",option+1) == 0)
4594 if (i == (ssize_t) argc)
4595 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4596 if (IsGeometry(argv[i]) == MagickFalse)
4597 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4600 if (LocaleCompare(
"depth",option+1) == 0)
4605 if (i == (ssize_t) argc)
4606 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4607 if (IsGeometry(argv[i]) == MagickFalse)
4608 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4611 if (LocaleCompare(
"deskew",option+1) == 0)
4616 if (i == (ssize_t) argc)
4617 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4618 if (IsGeometry(argv[i]) == MagickFalse)
4619 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4622 if (LocaleCompare(
"despeckle",option+1) == 0)
4624 if (LocaleCompare(
"dft",option+1) == 0)
4626 if (LocaleCompare(
"direction",option+1) == 0)
4634 if (i == (ssize_t) argc)
4635 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4636 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4639 ThrowMogrifyException(OptionError,
"UnrecognizedDirectionType",
4643 if (LocaleCompare(
"display",option+1) == 0)
4648 if (i == (ssize_t) argc)
4649 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4652 if (LocaleCompare(
"dispose",option+1) == 0)
4660 if (i == (ssize_t) argc)
4661 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4662 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4665 ThrowMogrifyException(OptionError,
"UnrecognizedDisposeMethod",
4669 if (LocaleCompare(
"distort",option+1) == 0)
4675 if (i == (ssize_t) argc)
4676 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4677 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4679 ThrowMogrifyException(OptionError,
"UnrecognizedDistortMethod",
4682 if (i == (ssize_t) argc)
4683 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4686 if (LocaleCompare(
"dither",option+1) == 0)
4694 if (i == (ssize_t) argc)
4695 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4696 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4698 ThrowMogrifyException(OptionError,
"UnrecognizedDitherMethod",
4702 if (LocaleCompare(
"draw",option+1) == 0)
4707 if (i == (ssize_t) argc)
4708 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4711 if (LocaleCompare(
"duplicate",option+1) == 0)
4716 if (i == (ssize_t) argc)
4717 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4718 if (IsGeometry(argv[i]) == MagickFalse)
4719 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4722 if (LocaleCompare(
"duration",option+1) == 0)
4727 if (i == (ssize_t) argc)
4728 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4729 if (IsGeometry(argv[i]) == MagickFalse)
4730 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4733 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4737 if (LocaleCompare(
"edge",option+1) == 0)
4742 if (i == (ssize_t) argc)
4743 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4744 if (IsGeometry(argv[i]) == MagickFalse)
4745 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4748 if (LocaleCompare(
"emboss",option+1) == 0)
4753 if (i == (ssize_t) argc)
4754 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4755 if (IsGeometry(argv[i]) == MagickFalse)
4756 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4759 if (LocaleCompare(
"encipher",option+1) == 0)
4764 if (i == (ssize_t) argc)
4765 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4768 if (LocaleCompare(
"encoding",option+1) == 0)
4773 if (i == (ssize_t) argc)
4774 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4777 if (LocaleCompare(
"endian",option+1) == 0)
4785 if (i == (ssize_t) argc)
4786 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4787 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4789 ThrowMogrifyException(OptionError,
"UnrecognizedEndianType",
4793 if (LocaleCompare(
"enhance",option+1) == 0)
4795 if (LocaleCompare(
"equalize",option+1) == 0)
4797 if (LocaleCompare(
"evaluate",option+1) == 0)
4805 if (i == (ssize_t) argc)
4806 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4807 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4809 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4812 if (i == (ssize_t) argc)
4813 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4814 if (IsGeometry(argv[i]) == MagickFalse)
4815 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4818 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4826 if (i == (ssize_t) argc)
4827 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4828 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4830 ThrowMogrifyException(OptionError,
"UnrecognizedEvaluateOperator",
4834 if (LocaleCompare(
"extent",option+1) == 0)
4839 if (i == (ssize_t) argc)
4840 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4841 if (IsGeometry(argv[i]) == MagickFalse)
4842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4845 if (LocaleCompare(
"extract",option+1) == 0)
4850 if (i == (ssize_t) argc)
4851 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4852 if (IsGeometry(argv[i]) == MagickFalse)
4853 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4856 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
4860 if (LocaleCompare(
"family",option+1) == 0)
4865 if (i == (ssize_t) argc)
4866 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4869 if (LocaleCompare(
"features",option+1) == 0)
4874 if (i == (ssize_t) argc)
4875 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4876 if (IsGeometry(argv[i]) == MagickFalse)
4877 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4880 if (LocaleCompare(
"fill",option+1) == 0)
4885 if (i == (ssize_t) argc)
4886 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4889 if (LocaleCompare(
"filter",option+1) == 0)
4897 if (i == (ssize_t) argc)
4898 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4899 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4901 ThrowMogrifyException(OptionError,
"UnrecognizedImageFilter",
4905 if (LocaleCompare(
"flatten",option+1) == 0)
4907 if (LocaleCompare(
"flip",option+1) == 0)
4909 if (LocaleCompare(
"flop",option+1) == 0)
4911 if (LocaleCompare(
"floodfill",option+1) == 0)
4916 if (i == (ssize_t) argc)
4917 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4918 if (IsGeometry(argv[i]) == MagickFalse)
4919 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4921 if (i == (ssize_t) argc)
4922 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4925 if (LocaleCompare(
"font",option+1) == 0)
4930 if (i == (ssize_t) argc)
4931 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4934 if (LocaleCompare(
"format",option+1) == 0)
4936 (void) CopyMagickString(argv[i]+1,
"sans",MaxTextExtent);
4937 (void) CloneString(&format,(
char *) NULL);
4941 if (i == (ssize_t) argc)
4942 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4943 (void) CloneString(&format,argv[i]);
4944 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4945 (void) ConcatenateMagickString(image_info->filename,
":",
4947 (void) SetImageInfo(image_info,0,exception);
4948 if (*image_info->magick ==
'\0')
4949 ThrowMogrifyException(OptionError,
"UnrecognizedImageFormat",
4953 if (LocaleCompare(
"frame",option+1) == 0)
4958 if (i == (ssize_t) argc)
4959 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4960 if (IsGeometry(argv[i]) == MagickFalse)
4961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4964 if (LocaleCompare(
"function",option+1) == 0)
4972 if (i == (ssize_t) argc)
4973 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4974 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4976 ThrowMogrifyException(OptionError,
"UnrecognizedFunction",argv[i]);
4978 if (i == (ssize_t) argc)
4979 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4982 if (LocaleCompare(
"fuzz",option+1) == 0)
4987 if (i == (ssize_t) argc)
4988 ThrowMogrifyException(OptionError,
"MissingArgument",option);
4989 if (IsGeometry(argv[i]) == MagickFalse)
4990 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4993 if (LocaleCompare(
"fx",option+1) == 0)
4998 if (i == (ssize_t) argc)
4999 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5002 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5006 if (LocaleCompare(
"gamma",option+1) == 0)
5009 if (i == (ssize_t) argc)
5010 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5011 if (IsGeometry(argv[i]) == MagickFalse)
5012 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5015 if ((LocaleCompare(
"gaussian-blur",option+1) == 0) ||
5016 (LocaleCompare(
"gaussian",option+1) == 0))
5019 if (i == (ssize_t) argc)
5020 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5021 if (IsGeometry(argv[i]) == MagickFalse)
5022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5025 if (LocaleCompare(
"geometry",option+1) == 0)
5030 if (i == (ssize_t) argc)
5031 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5032 if (IsGeometry(argv[i]) == MagickFalse)
5033 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5036 if (LocaleCompare(
"gravity",option+1) == 0)
5044 if (i == (ssize_t) argc)
5045 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5046 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5049 ThrowMogrifyException(OptionError,
"UnrecognizedGravityType",
5053 if (LocaleCompare(
"grayscale",option+1) == 0)
5061 if (i == (ssize_t) argc)
5062 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5063 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5066 ThrowMogrifyException(OptionError,
"UnrecognizedIntensityMethod",
5070 if (LocaleCompare(
"green-primary",option+1) == 0)
5075 if (i == (ssize_t) argc)
5076 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5077 if (IsGeometry(argv[i]) == MagickFalse)
5078 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5081 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5085 if (LocaleCompare(
"hald-clut",option+1) == 0)
5087 if (LocaleCompare(
"hough-lines",option+1) == 0)
5092 if (i == (ssize_t) argc)
5093 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5094 if (IsGeometry(argv[i]) == MagickFalse)
5095 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5098 if ((LocaleCompare(
"help",option+1) == 0) ||
5099 (LocaleCompare(
"-help",option+1) == 0))
5102 return(MogrifyUsage());
5104 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5108 if (LocaleCompare(
"identify",option+1) == 0)
5110 if (LocaleCompare(
"idft",option+1) == 0)
5112 if (LocaleCompare(
"implode",option+1) == 0)
5117 if (i == (ssize_t) argc)
5118 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5119 if (IsGeometry(argv[i]) == MagickFalse)
5120 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5123 if (LocaleCompare(
"intensity",option+1) == 0)
5131 if (i == (ssize_t) argc)
5132 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5133 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5134 MagickFalse,argv[i]);
5136 ThrowMogrifyException(OptionError,
5137 "UnrecognizedPixelIntensityMethod",argv[i]);
5140 if (LocaleCompare(
"intent",option+1) == 0)
5148 if (i == (ssize_t) argc)
5149 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5150 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5152 ThrowMogrifyException(OptionError,
"UnrecognizedIntentType",
5156 if (LocaleCompare(
"interlace",option+1) == 0)
5164 if (i == (ssize_t) argc)
5165 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5166 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5169 ThrowMogrifyException(OptionError,
"UnrecognizedInterlaceType",
5173 if (LocaleCompare(
"interline-spacing",option+1) == 0)
5178 if (i == (ssize_t) argc)
5179 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5180 if (IsGeometry(argv[i]) == MagickFalse)
5181 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5184 if (LocaleCompare(
"interpolate",option+1) == 0)
5192 if (i == (ssize_t) argc)
5193 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5194 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5196 if (interpolate < 0)
5197 ThrowMogrifyException(OptionError,
"UnrecognizedInterpolateMethod",
5201 if (LocaleCompare(
"interword-spacing",option+1) == 0)
5206 if (i == (ssize_t) argc)
5207 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5208 if (IsGeometry(argv[i]) == MagickFalse)
5209 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5212 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5216 if (LocaleCompare(
"kerning",option+1) == 0)
5221 if (i == (ssize_t) argc)
5222 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5223 if (IsGeometry(argv[i]) == MagickFalse)
5224 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5227 if (LocaleCompare(
"kuwahara",option+1) == 0)
5230 if (i == (ssize_t) argc)
5231 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5232 if (IsGeometry(argv[i]) == MagickFalse)
5233 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5236 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5240 if (LocaleCompare(
"label",option+1) == 0)
5245 if (i == (ssize_t) argc)
5246 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5249 if (LocaleCompare(
"lat",option+1) == 0)
5254 if (i == (ssize_t) argc)
5255 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5256 if (IsGeometry(argv[i]) == MagickFalse)
5257 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5260 if (LocaleCompare(
"layers",option+1) == 0)
5268 if (i == (ssize_t) argc)
5269 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5270 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5272 ThrowMogrifyException(OptionError,
"UnrecognizedLayerMethod",
5276 if (LocaleCompare(
"level",option+1) == 0)
5279 if (i == (ssize_t) argc)
5280 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5281 if (IsGeometry(argv[i]) == MagickFalse)
5282 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5285 if (LocaleCompare(
"level-colors",option+1) == 0)
5288 if (i == (ssize_t) argc)
5289 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5292 if (LocaleCompare(
"linewidth",option+1) == 0)
5297 if (i == (ssize_t) argc)
5298 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5299 if (IsGeometry(argv[i]) == MagickFalse)
5300 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5303 if (LocaleCompare(
"limit",option+1) == 0)
5317 if (i == (ssize_t) argc)
5318 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5319 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5322 ThrowMogrifyException(OptionError,
"UnrecognizedResourceType",
5325 if (i == (ssize_t) argc)
5326 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5327 value=StringToDouble(argv[i],&p);
5329 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
5330 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5333 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
5336 if (i == (ssize_t) argc)
5337 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5338 if (IsGeometry(argv[i]) == MagickFalse)
5339 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5342 if (LocaleCompare(
"list",option+1) == 0)
5350 if (i == (ssize_t) argc)
5351 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5352 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5354 ThrowMogrifyException(OptionError,
"UnrecognizedListType",argv[i]);
5355 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
5357 return(status == 0 ? MagickFalse : MagickTrue);
5359 if (LocaleCompare(
"local-contrast",option+1) == 0)
5362 if (i == (ssize_t) argc)
5363 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5364 if (IsGeometry(argv[i]) == MagickFalse)
5365 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5368 if (LocaleCompare(
"log",option+1) == 0)
5373 if ((i == (ssize_t) argc) ||
5374 (strchr(argv[i],
'%') == (
char *) NULL))
5375 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5378 if (LocaleCompare(
"loop",option+1) == 0)
5383 if (i == (ssize_t) argc)
5384 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5385 if (IsGeometry(argv[i]) == MagickFalse)
5386 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5389 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5393 if (LocaleCompare(
"magnify",option+1) == 0)
5395 if (LocaleCompare(
"map",option+1) == 0)
5397 global_colormap=(*option ==
'+') ? MagickTrue : MagickFalse;
5401 if (i == (ssize_t) argc)
5402 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5405 if (LocaleCompare(
"mask",option+1) == 0)
5410 if (i == (ssize_t) argc)
5411 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5414 if (LocaleCompare(
"matte",option+1) == 0)
5416 if (LocaleCompare(
"mattecolor",option+1) == 0)
5421 if (i == (ssize_t) argc)
5422 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5425 if (LocaleCompare(
"metric",option+1) == 0)
5433 if (i == (ssize_t) argc)
5434 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5435 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5437 ThrowMogrifyException(OptionError,
"UnrecognizedMetricType",
5441 if (LocaleCompare(
"maximum",option+1) == 0)
5443 if (LocaleCompare(
"mean-shift",option+1) == 0)
5448 if (i == (ssize_t) argc)
5449 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5450 if (IsGeometry(argv[i]) == MagickFalse)
5451 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5454 if (LocaleCompare(
"median",option+1) == 0)
5459 if (i == (ssize_t) argc)
5460 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5461 if (IsGeometry(argv[i]) == MagickFalse)
5462 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5465 if (LocaleCompare(
"minimum",option+1) == 0)
5467 if (LocaleCompare(
"modulate",option+1) == 0)
5472 if (i == (ssize_t) argc)
5473 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5474 if (IsGeometry(argv[i]) == MagickFalse)
5475 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5478 if (LocaleCompare(
"mode",option+1) == 0)
5483 if (i == (ssize_t) argc)
5484 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5485 if (IsGeometry(argv[i]) == MagickFalse)
5486 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5489 if (LocaleCompare(
"monitor",option+1) == 0)
5491 if (LocaleCompare(
"monochrome",option+1) == 0)
5493 if (LocaleCompare(
"morph",option+1) == 0)
5498 if (i == (ssize_t) argc)
5499 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5500 if (IsGeometry(argv[i]) == MagickFalse)
5501 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5504 if (LocaleCompare(
"morphology",option+1) == 0)
5507 token[MaxTextExtent];
5516 if (i == (ssize_t) argc)
5517 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5518 (void) GetNextToken(argv[i],(
const char **) NULL,MaxTextExtent,token);
5519 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5521 ThrowMogrifyException(OptionError,
"UnrecognizedMorphologyMethod",
5524 if (i == (ssize_t) argc)
5525 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5526 kernel_info=AcquireKernelInfo(argv[i]);
5527 if (kernel_info == (KernelInfo *) NULL)
5528 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5529 kernel_info=DestroyKernelInfo(kernel_info);
5532 if (LocaleCompare(
"mosaic",option+1) == 0)
5534 if (LocaleCompare(
"motion-blur",option+1) == 0)
5539 if (i == (ssize_t) argc)
5540 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5541 if (IsGeometry(argv[i]) == MagickFalse)
5542 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5545 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5549 if (LocaleCompare(
"negate",option+1) == 0)
5551 if (LocaleCompare(
"noise",option+1) == 0)
5554 if (i == (ssize_t) argc)
5555 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5561 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5563 ThrowMogrifyException(OptionError,
"UnrecognizedNoiseType",
5567 if (IsGeometry(argv[i]) == MagickFalse)
5568 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5571 if (LocaleCompare(
"noop",option+1) == 0)
5573 if (LocaleCompare(
"normalize",option+1) == 0)
5575 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5579 if (LocaleCompare(
"opaque",option+1) == 0)
5582 if (i == (ssize_t) argc)
5583 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5586 if (LocaleCompare(
"ordered-dither",option+1) == 0)
5591 if (i == (ssize_t) argc)
5592 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5595 if (LocaleCompare(
"orient",option+1) == 0)
5600 orientation=UndefinedOrientation;
5604 if (i == (ssize_t) argc)
5605 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5606 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5608 if (orientation < 0)
5609 ThrowMogrifyException(OptionError,
"UnrecognizedImageOrientation",
5613 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5617 if (LocaleCompare(
"page",option+1) == 0)
5622 if (i == (ssize_t) argc)
5623 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5626 if (LocaleCompare(
"paint",option+1) == 0)
5631 if (i == (ssize_t) argc)
5632 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5633 if (IsGeometry(argv[i]) == MagickFalse)
5634 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5637 if (LocaleCompare(
"path",option+1) == 0)
5639 (void) CloneString(&path,(
char *) NULL);
5643 if (i == (ssize_t) argc)
5644 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5645 (void) CloneString(&path,argv[i]);
5648 if (LocaleCompare(
"perceptible",option+1) == 0)
5653 if (i == (ssize_t) argc)
5654 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5655 if (IsGeometry(argv[i]) == MagickFalse)
5656 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5659 if (LocaleCompare(
"pointsize",option+1) == 0)
5664 if (i == (ssize_t) argc)
5665 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5666 if (IsGeometry(argv[i]) == MagickFalse)
5667 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5670 if (LocaleCompare(
"polaroid",option+1) == 0)
5675 if (i == (ssize_t) argc)
5676 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5677 if (IsGeometry(argv[i]) == MagickFalse)
5678 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5681 if (LocaleCompare(
"poly",option+1) == 0)
5686 if (i == (ssize_t) argc)
5687 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5688 if (IsGeometry(argv[i]) == MagickFalse)
5689 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5692 if (LocaleCompare(
"posterize",option+1) == 0)
5697 if (i == (ssize_t) argc)
5698 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5699 if (IsGeometry(argv[i]) == MagickFalse)
5700 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5703 if (LocaleCompare(
"precision",option+1) == 0)
5708 if (i == (ssize_t) argc)
5709 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5710 if (IsGeometry(argv[i]) == MagickFalse)
5711 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5714 if (LocaleCompare(
"print",option+1) == 0)
5719 if (i == (ssize_t) argc)
5720 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5723 if (LocaleCompare(
"process",option+1) == 0)
5728 if (i == (ssize_t) argc)
5729 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5732 if (LocaleCompare(
"profile",option+1) == 0)
5735 if (i == (ssize_t) argc)
5736 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5739 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5743 if (LocaleCompare(
"quality",option+1) == 0)
5748 if (i == (ssize_t) argc)
5749 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5750 if (IsGeometry(argv[i]) == MagickFalse)
5751 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5754 if (LocaleCompare(
"quantize",option+1) == 0)
5762 if (i == (ssize_t) argc)
5763 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5764 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5767 ThrowMogrifyException(OptionError,
"UnrecognizedColorspace",
5771 if (LocaleCompare(
"quiet",option+1) == 0)
5773 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5777 if (LocaleCompare(
"radial-blur",option+1) == 0 ||
5778 LocaleCompare(
"rotational-blur",option+1) == 0)
5781 if (i == (ssize_t) argc)
5782 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5783 if (IsGeometry(argv[i]) == MagickFalse)
5784 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5787 if (LocaleCompare(
"raise",option+1) == 0)
5790 if (i == (ssize_t) argc)
5791 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5792 if (IsGeometry(argv[i]) == MagickFalse)
5793 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5796 if (LocaleCompare(
"random-threshold",option+1) == 0)
5801 if (i == (ssize_t) argc)
5802 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5803 if (IsGeometry(argv[i]) == MagickFalse)
5804 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5807 if (LocaleCompare(
"recolor",option+1) == 0)
5812 if (i == (ssize_t) argc)
5813 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5814 if (IsGeometry(argv[i]) == MagickFalse)
5815 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5818 if (LocaleCompare(
"red-primary",option+1) == 0)
5823 if (i == (ssize_t) argc)
5824 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5825 if (IsGeometry(argv[i]) == MagickFalse)
5826 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5828 if (LocaleCompare(
"regard-warnings",option+1) == 0)
5830 if (LocaleCompare(
"region",option+1) == 0)
5835 if (i == (ssize_t) argc)
5836 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5837 if (IsGeometry(argv[i]) == MagickFalse)
5838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5841 if (LocaleCompare(
"remap",option+1) == 0)
5846 if (i == (ssize_t) argc)
5847 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5850 if (LocaleCompare(
"render",option+1) == 0)
5852 if (LocaleCompare(
"repage",option+1) == 0)
5857 if (i == (ssize_t) argc)
5858 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5859 if (IsGeometry(argv[i]) == MagickFalse)
5860 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5863 if (LocaleCompare(
"resample",option+1) == 0)
5868 if (i == (ssize_t) argc)
5869 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5870 if (IsGeometry(argv[i]) == MagickFalse)
5871 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5874 if (LocaleCompare(
"resize",option+1) == 0)
5879 if (i == (ssize_t) argc)
5880 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5881 if (IsGeometry(argv[i]) == MagickFalse)
5882 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5885 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
5887 respect_parenthesis=(*option ==
'-') ? MagickTrue : MagickFalse;
5890 if (LocaleCompare(
"reverse",option+1) == 0)
5892 if (LocaleCompare(
"roll",option+1) == 0)
5897 if (i == (ssize_t) argc)
5898 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5899 if (IsGeometry(argv[i]) == MagickFalse)
5900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5903 if (LocaleCompare(
"rotate",option+1) == 0)
5906 if (i == (ssize_t) argc)
5907 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5908 if (IsGeometry(argv[i]) == MagickFalse)
5909 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5912 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
5916 if (LocaleCompare(
"sample",option+1) == 0)
5921 if (i == (ssize_t) argc)
5922 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5923 if (IsGeometry(argv[i]) == MagickFalse)
5924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5927 if (LocaleCompare(
"sampling-factor",option+1) == 0)
5932 if (i == (ssize_t) argc)
5933 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5934 if (IsGeometry(argv[i]) == MagickFalse)
5935 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5938 if (LocaleCompare(
"scale",option+1) == 0)
5943 if (i == (ssize_t) argc)
5944 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5945 if (IsGeometry(argv[i]) == MagickFalse)
5946 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5949 if (LocaleCompare(
"scene",option+1) == 0)
5954 if (i == (ssize_t) argc)
5955 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5956 if (IsGeometry(argv[i]) == MagickFalse)
5957 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5960 if (LocaleCompare(
"seed",option+1) == 0)
5965 if (i == (ssize_t) argc)
5966 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5967 if (IsGeometry(argv[i]) == MagickFalse)
5968 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5971 if (LocaleCompare(
"segment",option+1) == 0)
5976 if (i == (ssize_t) argc)
5977 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5978 if (IsGeometry(argv[i]) == MagickFalse)
5979 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5982 if (LocaleCompare(
"selective-blur",option+1) == 0)
5985 if (i == (ssize_t) argc)
5986 ThrowMogrifyException(OptionError,
"MissingArgument",option);
5987 if (IsGeometry(argv[i]) == MagickFalse)
5988 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5991 if (LocaleCompare(
"separate",option+1) == 0)
5993 if (LocaleCompare(
"sepia-tone",option+1) == 0)
5998 if (i == (ssize_t) argc)
5999 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6000 if (IsGeometry(argv[i]) == MagickFalse)
6001 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6004 if (LocaleCompare(
"set",option+1) == 0)
6007 if (i == (ssize_t) argc)
6008 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6012 if (i == (ssize_t) argc)
6013 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6016 if (LocaleCompare(
"shade",option+1) == 0)
6019 if (i == (ssize_t) argc)
6020 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6021 if (IsGeometry(argv[i]) == MagickFalse)
6022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6025 if (LocaleCompare(
"shadow",option+1) == 0)
6030 if (i == (ssize_t) argc)
6031 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6032 if (IsGeometry(argv[i]) == MagickFalse)
6033 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6036 if (LocaleCompare(
"sharpen",option+1) == 0)
6039 if (i == (ssize_t) argc)
6040 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6041 if (IsGeometry(argv[i]) == MagickFalse)
6042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6045 if (LocaleCompare(
"shave",option+1) == 0)
6050 if (i == (ssize_t) argc)
6051 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6052 if (IsGeometry(argv[i]) == MagickFalse)
6053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6056 if (LocaleCompare(
"shear",option+1) == 0)
6059 if (i == (ssize_t) argc)
6060 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6061 if (IsGeometry(argv[i]) == MagickFalse)
6062 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6065 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
6068 if (i == (ssize_t) argc)
6069 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6070 if (IsGeometry(argv[i]) == MagickFalse)
6071 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6074 if (LocaleCompare(
"size",option+1) == 0)
6079 if (i == (ssize_t) argc)
6080 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6081 if (IsGeometry(argv[i]) == MagickFalse)
6082 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6085 if (LocaleCompare(
"sketch",option+1) == 0)
6090 if (i == (ssize_t) argc)
6091 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6092 if (IsGeometry(argv[i]) == MagickFalse)
6093 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6096 if (LocaleCompare(
"smush",option+1) == 0)
6099 if (i == (ssize_t) argc)
6100 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6101 if (IsGeometry(argv[i]) == MagickFalse)
6102 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6106 if (LocaleCompare(
"solarize",option+1) == 0)
6111 if (i == (ssize_t) argc)
6112 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6113 if (IsGeometry(argv[i]) == MagickFalse)
6114 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6117 if (LocaleCompare(
"sparse-color",option+1) == 0)
6123 if (i == (ssize_t) argc)
6124 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6125 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6127 ThrowMogrifyException(OptionError,
"UnrecognizedSparseColorMethod",
6130 if (i == (ssize_t) argc)
6131 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6134 if (LocaleCompare(
"splice",option+1) == 0)
6139 if (i == (ssize_t) argc)
6140 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6141 if (IsGeometry(argv[i]) == MagickFalse)
6142 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6145 if (LocaleCompare(
"spread",option+1) == 0)
6150 if (i == (ssize_t) argc)
6151 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6152 if (IsGeometry(argv[i]) == MagickFalse)
6153 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6156 if (LocaleCompare(
"statistic",option+1) == 0)
6164 if (i == (ssize_t) argc)
6165 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6166 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6168 ThrowMogrifyException(OptionError,
"UnrecognizedStatisticType",
6171 if (i == (ssize_t) argc)
6172 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6173 if (IsGeometry(argv[i]) == MagickFalse)
6174 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6177 if (LocaleCompare(
"stretch",option+1) == 0)
6185 if (i == (ssize_t) argc)
6186 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6187 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
6189 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6193 if (LocaleCompare(
"strip",option+1) == 0)
6195 if (LocaleCompare(
"stroke",option+1) == 0)
6200 if (i == (ssize_t) argc)
6201 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6204 if (LocaleCompare(
"strokewidth",option+1) == 0)
6209 if (i == (ssize_t) argc)
6210 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6211 if (IsGeometry(argv[i]) == MagickFalse)
6212 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6215 if (LocaleCompare(
"style",option+1) == 0)
6223 if (i == (ssize_t) argc)
6224 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6225 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6227 ThrowMogrifyException(OptionError,
"UnrecognizedStyleType",
6231 if (LocaleCompare(
"swap",option+1) == 0)
6236 if (i == (ssize_t) argc)
6237 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6238 if (IsGeometry(argv[i]) == MagickFalse)
6239 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6242 if (LocaleCompare(
"swirl",option+1) == 0)
6247 if (i == (ssize_t) argc)
6248 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6249 if (IsGeometry(argv[i]) == MagickFalse)
6250 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6253 if (LocaleCompare(
"synchronize",option+1) == 0)
6255 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6259 if (LocaleCompare(
"taint",option+1) == 0)
6261 if (LocaleCompare(
"texture",option+1) == 0)
6266 if (i == (ssize_t) argc)
6267 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6270 if (LocaleCompare(
"tile",option+1) == 0)
6275 if (i == (ssize_t) argc)
6276 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6279 if (LocaleCompare(
"tile-offset",option+1) == 0)
6284 if (i == (ssize_t) argc)
6285 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6286 if (IsGeometry(argv[i]) == MagickFalse)
6287 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6290 if (LocaleCompare(
"tint",option+1) == 0)
6295 if (i == (ssize_t) argc)
6296 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6297 if (IsGeometry(argv[i]) == MagickFalse)
6298 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6301 if (LocaleCompare(
"transform",option+1) == 0)
6303 if (LocaleCompare(
"transpose",option+1) == 0)
6305 if (LocaleCompare(
"transverse",option+1) == 0)
6307 if (LocaleCompare(
"threshold",option+1) == 0)
6312 if (i == (ssize_t) argc)
6313 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6314 if (IsGeometry(argv[i]) == MagickFalse)
6315 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6318 if (LocaleCompare(
"thumbnail",option+1) == 0)
6323 if (i == (ssize_t) argc)
6324 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6325 if (IsGeometry(argv[i]) == MagickFalse)
6326 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6329 if (LocaleCompare(
"transparent",option+1) == 0)
6332 if (i == (ssize_t) argc)
6333 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6336 if (LocaleCompare(
"transparent-color",option+1) == 0)
6341 if (i == (ssize_t) argc)
6342 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6345 if (LocaleCompare(
"treedepth",option+1) == 0)
6350 if (i == (ssize_t) argc)
6351 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6352 if (IsGeometry(argv[i]) == MagickFalse)
6353 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6356 if (LocaleCompare(
"trim",option+1) == 0)
6358 if (LocaleCompare(
"type",option+1) == 0)
6366 if (i == (ssize_t) argc)
6367 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6368 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6370 ThrowMogrifyException(OptionError,
"UnrecognizedImageType",
6374 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6378 if (LocaleCompare(
"undercolor",option+1) == 0)
6383 if (i == (ssize_t) argc)
6384 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6387 if (LocaleCompare(
"unique-colors",option+1) == 0)
6389 if (LocaleCompare(
"units",option+1) == 0)
6397 if (i == (ssize_t) argc)
6398 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6399 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6402 ThrowMogrifyException(OptionError,
"UnrecognizedUnitsType",
6406 if (LocaleCompare(
"unsharp",option+1) == 0)
6409 if (i == (ssize_t) argc)
6410 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6411 if (IsGeometry(argv[i]) == MagickFalse)
6412 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6415 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6419 if (LocaleCompare(
"verbose",option+1) == 0)
6421 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
6424 if ((LocaleCompare(
"version",option+1) == 0) ||
6425 (LocaleCompare(
"-version",option+1) == 0))
6427 ListMagickVersion(stdout);
6430 if (LocaleCompare(
"view",option+1) == 0)
6435 if (i == (ssize_t) argc)
6436 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6439 if (LocaleCompare(
"vignette",option+1) == 0)
6444 if (i == (ssize_t) argc)
6445 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6446 if (IsGeometry(argv[i]) == MagickFalse)
6447 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6450 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
6458 if (i == (ssize_t) argc)
6459 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6460 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6463 ThrowMogrifyException(OptionError,
6464 "UnrecognizedVirtualPixelMethod",argv[i]);
6467 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6471 if (LocaleCompare(
"wave",option+1) == 0)
6474 if (i == (ssize_t) argc)
6475 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6476 if (IsGeometry(argv[i]) == MagickFalse)
6477 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6480 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
6483 if (i == (ssize_t) argc)
6484 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6485 if (IsGeometry(argv[i]) == MagickFalse)
6486 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6489 if (LocaleCompare(
"weight",option+1) == 0)
6494 if (i == (ssize_t) argc)
6495 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6498 if (LocaleCompare(
"white-point",option+1) == 0)
6503 if (i == (ssize_t) argc)
6504 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6505 if (IsGeometry(argv[i]) == MagickFalse)
6506 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6509 if (LocaleCompare(
"white-threshold",option+1) == 0)
6514 if (i == (ssize_t) argc)
6515 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6516 if (IsGeometry(argv[i]) == MagickFalse)
6517 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6520 if (LocaleCompare(
"write",option+1) == 0)
6523 if (i == (ssize_t) argc)
6524 ThrowMogrifyException(OptionError,
"MissingArgument",option);
6527 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6532 ThrowMogrifyException(OptionError,
"UnrecognizedOption",option)
6534 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6535 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6536 if (fire != MagickFalse)
6537 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6540 ThrowMogrifyException(OptionError,
"UnbalancedParenthesis",argv[i]);
6541 if (i != (ssize_t) argc)
6542 ThrowMogrifyException(OptionError,
"MissingAnImageFilename",argv[i]);
6544 return(status != 0 ? MagickTrue : MagickFalse);
6579 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6580 const int argc,
const char **argv,ExceptionInfo *exception)
6597 assert(image_info != (ImageInfo *) NULL);
6598 assert(image_info->signature == MagickCoreSignature);
6599 if (IsEventLogging() != MagickFalse)
6600 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
6601 image_info->filename);
6607 for (i=0; i < (ssize_t) argc; i++)
6610 if (IsCommandOption(option) == MagickFalse)
6612 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6613 count=MagickMax(count,0L);
6614 if ((i+count) >= (ssize_t) argc)
6616 switch (*(option+1))
6620 if (LocaleCompare(
"adjoin",option+1) == 0)
6622 image_info->adjoin=(*option ==
'-') ? MagickTrue : MagickFalse;
6625 if (LocaleCompare(
"antialias",option+1) == 0)
6627 image_info->antialias=(*option ==
'-') ? MagickTrue : MagickFalse;
6630 if (LocaleCompare(
"attenuate",option+1) == 0)
6634 (void) DeleteImageOption(image_info,option+1);
6637 (void) SetImageOption(image_info,option+1,argv[i+1]);
6640 if (LocaleCompare(
"authenticate",option+1) == 0)
6643 (void) CloneString(&image_info->authenticate,(
char *) NULL);
6645 (
void) CloneString(&image_info->authenticate,argv[i+1]);
6652 if (LocaleCompare(
"background",option+1) == 0)
6656 (void) DeleteImageOption(image_info,option+1);
6657 (void) QueryColorDatabase(MogrifyBackgroundColor,
6658 &image_info->background_color,exception);
6661 (void) SetImageOption(image_info,option+1,argv[i+1]);
6662 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6666 if (LocaleCompare(
"bias",option+1) == 0)
6670 (void) SetImageOption(image_info,option+1,
"0.0");
6673 (void) SetImageOption(image_info,option+1,argv[i+1]);
6676 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
6680 (void) SetImageOption(image_info,option+1,
"false");
6683 (void) SetImageOption(image_info,option+1,
"true");
6686 if (LocaleCompare(
"blue-primary",option+1) == 0)
6690 (void) SetImageOption(image_info,option+1,
"0.0");
6693 (void) SetImageOption(image_info,option+1,argv[i+1]);
6696 if (LocaleCompare(
"bordercolor",option+1) == 0)
6700 (void) DeleteImageOption(image_info,option+1);
6701 (void) QueryColorDatabase(MogrifyBorderColor,
6702 &image_info->border_color,exception);
6705 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6707 (void) SetImageOption(image_info,option+1,argv[i+1]);
6710 if (LocaleCompare(
"box",option+1) == 0)
6714 (void) SetImageOption(image_info,
"undercolor",
"none");
6717 (void) SetImageOption(image_info,
"undercolor",argv[i+1]);
6724 if (LocaleCompare(
"cache",option+1) == 0)
6729 limit=MagickResourceInfinity;
6730 if (LocaleCompare(
"unlimited",argv[i+1]) != 0)
6731 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],100.0);
6732 (void) SetMagickResourceLimit(MemoryResource,limit);
6733 (void) SetMagickResourceLimit(MapResource,2*limit);
6736 if (LocaleCompare(
"caption",option+1) == 0)
6740 (void) DeleteImageOption(image_info,option+1);
6743 (void) SetImageOption(image_info,option+1,argv[i+1]);
6746 if (LocaleCompare(
"channel",option+1) == 0)
6750 image_info->channel=DefaultChannels;
6753 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6756 if (LocaleCompare(
"colors",option+1) == 0)
6758 image_info->colors=StringToUnsignedLong(argv[i+1]);
6761 if (LocaleCompare(
"colorspace",option+1) == 0)
6765 image_info->colorspace=UndefinedColorspace;
6766 (void) SetImageOption(image_info,option+1,
"undefined");
6769 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6770 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6771 (void) SetImageOption(image_info,option+1,argv[i+1]);
6774 if (LocaleCompare(
"comment",option+1) == 0)
6778 (void) DeleteImageOption(image_info,option+1);
6781 (void) SetImageOption(image_info,option+1,argv[i+1]);
6784 if (LocaleCompare(
"compose",option+1) == 0)
6788 (void) SetImageOption(image_info,option+1,
"undefined");
6791 (void) SetImageOption(image_info,option+1,argv[i+1]);
6794 if (LocaleCompare(
"compress",option+1) == 0)
6798 image_info->compression=UndefinedCompression;
6799 (void) SetImageOption(image_info,option+1,
"undefined");
6802 image_info->compression=(CompressionType) ParseCommandOption(
6803 MagickCompressOptions,MagickFalse,argv[i+1]);
6804 (void) SetImageOption(image_info,option+1,argv[i+1]);
6811 if (LocaleCompare(
"debug",option+1) == 0)
6814 (void) SetLogEventMask(
"none");
6816 (
void) SetLogEventMask(argv[i+1]);
6817 image_info->debug=IsEventLogging();
6820 if (LocaleCompare(
"define",option+1) == 0)
6824 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6825 (void) DeleteImageRegistry(argv[i+1]+9);
6827 (
void) DeleteImageOption(image_info,argv[i+1]);
6830 if (LocaleNCompare(argv[i+1],
"registry:",9) == 0)
6832 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6836 (void) DefineImageOption(image_info,argv[i+1]);
6839 if (LocaleCompare(
"delay",option+1) == 0)
6843 (void) SetImageOption(image_info,option+1,
"0");
6846 (void) SetImageOption(image_info,option+1,argv[i+1]);
6849 if (LocaleCompare(
"density",option+1) == 0)
6856 if (image_info->density != (
char *) NULL)
6857 image_info->density=DestroyString(image_info->density);
6858 (void) SetImageOption(image_info,option+1,
"72");
6861 (void) CloneString(&image_info->density,argv[i+1]);
6862 (void) SetImageOption(image_info,option+1,argv[i+1]);
6865 if (LocaleCompare(
"depth",option+1) == 0)
6869 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6872 image_info->depth=StringToUnsignedLong(argv[i+1]);
6875 if (LocaleCompare(
"direction",option+1) == 0)
6879 (void) SetImageOption(image_info,option+1,
"undefined");
6882 (void) SetImageOption(image_info,option+1,argv[i+1]);
6885 if (LocaleCompare(
"display",option+1) == 0)
6889 if (image_info->server_name != (
char *) NULL)
6890 image_info->server_name=DestroyString(
6891 image_info->server_name);
6894 (void) CloneString(&image_info->server_name,argv[i+1]);
6897 if (LocaleCompare(
"dispose",option+1) == 0)
6901 (void) SetImageOption(image_info,option+1,
"undefined");
6904 (void) SetImageOption(image_info,option+1,argv[i+1]);
6907 if (LocaleCompare(
"dither",option+1) == 0)
6911 image_info->dither=MagickFalse;
6912 (void) SetImageOption(image_info,option+1,
"none");
6915 (void) SetImageOption(image_info,option+1,argv[i+1]);
6916 image_info->dither=MagickTrue;
6923 if (LocaleCompare(
"encoding",option+1) == 0)
6927 (void) SetImageOption(image_info,option+1,
"undefined");
6930 (void) SetImageOption(image_info,option+1,argv[i+1]);
6933 if (LocaleCompare(
"endian",option+1) == 0)
6937 image_info->endian=UndefinedEndian;
6938 (void) SetImageOption(image_info,option+1,
"undefined");
6941 image_info->endian=(EndianType) ParseCommandOption(
6942 MagickEndianOptions,MagickFalse,argv[i+1]);
6943 (void) SetImageOption(image_info,option+1,argv[i+1]);
6946 if (LocaleCompare(
"extract",option+1) == 0)
6953 if (image_info->extract != (
char *) NULL)
6954 image_info->extract=DestroyString(image_info->extract);
6957 (void) CloneString(&image_info->extract,argv[i+1]);
6964 if (LocaleCompare(
"family",option+1) == 0)
6967 (void) SetImageOption(image_info,option+1,argv[i+1]);
6970 if (LocaleCompare(
"fill",option+1) == 0)
6974 (void) SetImageOption(image_info,option+1,
"none");
6977 (void) SetImageOption(image_info,option+1,argv[i+1]);
6980 if (LocaleCompare(
"filter",option+1) == 0)
6984 (void) SetImageOption(image_info,option+1,
"undefined");
6987 (void) SetImageOption(image_info,option+1,argv[i+1]);
6990 if (LocaleCompare(
"font",option+1) == 0)
6994 if (image_info->font != (
char *) NULL)
6995 image_info->font=DestroyString(image_info->font);
6998 (void) CloneString(&image_info->font,argv[i+1]);
7001 if (LocaleCompare(
"format",option+1) == 0)
7003 (void) SetImageOption(image_info,option+1,argv[i+1]);
7006 if (LocaleCompare(
"fuzz",option+1) == 0)
7010 image_info->fuzz=0.0;
7011 (void) SetImageOption(image_info,option+1,
"0");
7014 image_info->fuzz=StringToDoubleInterval(argv[i+1],(
double)
7016 (void) SetImageOption(image_info,option+1,argv[i+1]);
7023 if (LocaleCompare(
"gravity",option+1) == 0)
7027 (void) SetImageOption(image_info,option+1,
"undefined");
7030 (void) SetImageOption(image_info,option+1,argv[i+1]);
7033 if (LocaleCompare(
"green-primary",option+1) == 0)
7037 (void) SetImageOption(image_info,option+1,
"0.0");
7040 (void) SetImageOption(image_info,option+1,argv[i+1]);
7047 if (LocaleCompare(
"intensity",option+1) == 0)
7051 (void) SetImageOption(image_info,option+1,
"undefined");
7054 (void) SetImageOption(image_info,option+1,argv[i+1]);
7057 if (LocaleCompare(
"intent",option+1) == 0)
7061 (void) SetImageOption(image_info,option+1,
"undefined");
7064 (void) SetImageOption(image_info,option+1,argv[i+1]);
7067 if (LocaleCompare(
"interlace",option+1) == 0)
7071 image_info->interlace=UndefinedInterlace;
7072 (void) SetImageOption(image_info,option+1,
"undefined");
7075 image_info->interlace=(InterlaceType) ParseCommandOption(
7076 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7077 (void) SetImageOption(image_info,option+1,argv[i+1]);
7080 if (LocaleCompare(
"interline-spacing",option+1) == 0)
7084 (void) SetImageOption(image_info,option+1,
"undefined");
7087 (void) SetImageOption(image_info,option+1,argv[i+1]);
7090 if (LocaleCompare(
"interpolate",option+1) == 0)
7094 (void) SetImageOption(image_info,option+1,
"undefined");
7097 (void) SetImageOption(image_info,option+1,argv[i+1]);
7100 if (LocaleCompare(
"interword-spacing",option+1) == 0)
7104 (void) SetImageOption(image_info,option+1,
"undefined");
7107 (void) SetImageOption(image_info,option+1,argv[i+1]);
7114 if (LocaleCompare(
"kerning",option+1) == 0)
7118 (void) SetImageOption(image_info,option+1,
"undefined");
7121 (void) SetImageOption(image_info,option+1,argv[i+1]);
7128 if (LocaleCompare(
"label",option+1) == 0)
7132 (void) DeleteImageOption(image_info,option+1);
7135 (void) SetImageOption(image_info,option+1,argv[i+1]);
7138 if (LocaleCompare(
"limit",option+1) == 0)
7148 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7149 MagickFalse,argv[i+1]);
7150 limit=MagickResourceInfinity;
7151 if (LocaleCompare(
"unlimited",argv[i+2]) != 0)
7152 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7153 (void) SetMagickResourceLimit(type,limit);
7156 if (LocaleCompare(
"list",option+1) == 0)
7164 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7167 case MagickCoderOptions:
7169 (void) ListCoderInfo((FILE *) NULL,exception);
7172 case MagickColorOptions:
7174 (void) ListColorInfo((FILE *) NULL,exception);
7177 case MagickConfigureOptions:
7179 (void) ListConfigureInfo((FILE *) NULL,exception);
7182 case MagickDelegateOptions:
7184 (void) ListDelegateInfo((FILE *) NULL,exception);
7187 case MagickFontOptions:
7189 (void) ListTypeInfo((FILE *) NULL,exception);
7192 case MagickFormatOptions:
7194 (void) ListMagickInfo((FILE *) NULL,exception);
7197 case MagickLocaleOptions:
7199 (void) ListLocaleInfo((FILE *) NULL,exception);
7202 case MagickLogOptions:
7204 (void) ListLogInfo((FILE *) NULL,exception);
7207 case MagickMagicOptions:
7209 (void) ListMagicInfo((FILE *) NULL,exception);
7212 case MagickMimeOptions:
7214 (void) ListMimeInfo((FILE *) NULL,exception);
7217 case MagickModuleOptions:
7219 (void) ListModuleInfo((FILE *) NULL,exception);
7222 case MagickPolicyOptions:
7224 (void) ListPolicyInfo((FILE *) NULL,exception);
7227 case MagickResourceOptions:
7229 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7232 case MagickThresholdOptions:
7234 (void) ListThresholdMaps((FILE *) NULL,exception);
7239 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7246 if (LocaleCompare(
"log",option+1) == 0)
7250 (void) SetLogFormat(argv[i+1]);
7253 if (LocaleCompare(
"loop",option+1) == 0)
7257 (void) SetImageOption(image_info,option+1,
"0");
7260 (void) SetImageOption(image_info,option+1,argv[i+1]);
7267 if (LocaleCompare(
"matte",option+1) == 0)
7271 (void) SetImageOption(image_info,option+1,
"false");
7274 (void) SetImageOption(image_info,option+1,
"true");
7277 if (LocaleCompare(
"mattecolor",option+1) == 0)
7281 (void) SetImageOption(image_info,option+1,argv[i+1]);
7282 (void) QueryColorDatabase(MogrifyMatteColor,
7283 &image_info->matte_color,exception);
7286 (void) SetImageOption(image_info,option+1,argv[i+1]);
7287 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7291 if (LocaleCompare(
"metric",option+1) == 0)
7295 (void) DeleteImageOption(image_info,option+1);
7298 (void) SetImageOption(image_info,option+1,argv[i+1]);
7301 if (LocaleCompare(
"monitor",option+1) == 0)
7303 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7307 if (LocaleCompare(
"monochrome",option+1) == 0)
7309 image_info->monochrome=(*option ==
'-') ? MagickTrue : MagickFalse;
7316 if (LocaleCompare(
"orient",option+1) == 0)
7320 image_info->orientation=UndefinedOrientation;
7321 (void) SetImageOption(image_info,option+1,
"undefined");
7324 image_info->orientation=(OrientationType) ParseCommandOption(
7325 MagickOrientationOptions,MagickFalse,argv[i+1]);
7326 (void) SetImageOption(image_info,option+1,argv[i+1]);
7332 if (LocaleCompare(
"page",option+1) == 0)
7336 page[MaxTextExtent];
7349 (void) DeleteImageOption(image_info,option+1);
7350 (void) CloneString(&image_info->page,(
char *) NULL);
7353 (void) memset(&geometry,0,
sizeof(geometry));
7354 image_option=GetImageOption(image_info,
"page");
7355 if (image_option != (
const char *) NULL)
7356 (void) ParseAbsoluteGeometry(image_option,&geometry);
7357 canonical_page=GetPageGeometry(argv[i+1]);
7358 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7359 canonical_page=DestroyString(canonical_page);
7360 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu",
7361 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
7362 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7363 (void) FormatLocaleString(page,MaxTextExtent,
"%lux%lu%+ld%+ld",
7364 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
7365 (
long) geometry.x,(long) geometry.y);
7366 (void) SetImageOption(image_info,option+1,page);
7367 (void) CloneString(&image_info->page,page);
7370 if (LocaleCompare(
"pen",option+1) == 0)
7374 (void) SetImageOption(image_info,option+1,
"none");
7377 (void) SetImageOption(image_info,option+1,argv[i+1]);
7380 if (LocaleCompare(
"ping",option+1) == 0)
7382 image_info->ping=(*option ==
'-') ? MagickTrue : MagickFalse;
7385 if (LocaleCompare(
"pointsize",option+1) == 0)
7388 geometry_info.rho=0.0;
7390 (
void) ParseGeometry(argv[i+1],&geometry_info);
7391 image_info->pointsize=geometry_info.rho;
7394 if (LocaleCompare(
"precision",option+1) == 0)
7396 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7399 if (LocaleCompare(
"preview",option+1) == 0)
7406 image_info->preview_type=UndefinedPreview;
7409 image_info->preview_type=(PreviewType) ParseCommandOption(
7410 MagickPreviewOptions,MagickFalse,argv[i+1]);
7417 if (LocaleCompare(
"quality",option+1) == 0)
7424 image_info->quality=UndefinedCompressionQuality;
7425 (void) SetImageOption(image_info,option+1,
"0");
7428 image_info->quality=StringToUnsignedLong(argv[i+1]);
7429 (void) SetImageOption(image_info,option+1,argv[i+1]);
7432 if (LocaleCompare(
"quiet",option+1) == 0)
7434 static WarningHandler
7435 warning_handler = (WarningHandler) NULL;
7442 warning_handler=SetWarningHandler(warning_handler);
7448 warning_handler=SetWarningHandler((WarningHandler) NULL);
7455 if (LocaleCompare(
"red-primary",option+1) == 0)
7459 (void) SetImageOption(image_info,option+1,
"0.0");
7462 (void) SetImageOption(image_info,option+1,argv[i+1]);
7469 if (LocaleCompare(
"sampling-factor",option+1) == 0)
7476 if (image_info->sampling_factor != (
char *) NULL)
7477 image_info->sampling_factor=DestroyString(
7478 image_info->sampling_factor);
7481 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7484 if (LocaleCompare(
"scene",option+1) == 0)
7491 image_info->scene=0;
7492 (void) SetImageOption(image_info,option+1,
"0");
7495 image_info->scene=StringToUnsignedLong(argv[i+1]);
7496 (void) SetImageOption(image_info,option+1,argv[i+1]);
7499 if (LocaleCompare(
"seed",option+1) == 0)
7506 seed=(
unsigned long) time((time_t *) NULL);
7507 SetRandomSecretKey(seed);
7510 seed=StringToUnsignedLong(argv[i+1]);
7511 SetRandomSecretKey(seed);
7514 if (LocaleCompare(
"size",option+1) == 0)
7518 if (image_info->size != (
char *) NULL)
7519 image_info->size=DestroyString(image_info->size);
7522 (void) CloneString(&image_info->size,argv[i+1]);
7525 if (LocaleCompare(
"stroke",option+1) == 0)
7528 (void) SetImageOption(image_info,option+1,
"none");
7530 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7533 if (LocaleCompare(
"strokewidth",option+1) == 0)
7536 (void) SetImageOption(image_info,option+1,
"0");
7538 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7541 if (LocaleCompare(
"style",option+1) == 0)
7544 (void) SetImageOption(image_info,option+1,
"none");
7546 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7549 if (LocaleCompare(
"synchronize",option+1) == 0)
7553 image_info->synchronize=MagickFalse;
7556 image_info->synchronize=MagickTrue;
7563 if (LocaleCompare(
"taint",option+1) == 0)
7567 (void) SetImageOption(image_info,option+1,
"false");
7570 (void) SetImageOption(image_info,option+1,
"true");
7573 if (LocaleCompare(
"texture",option+1) == 0)
7577 if (image_info->texture != (
char *) NULL)
7578 image_info->texture=DestroyString(image_info->texture);
7581 (void) CloneString(&image_info->texture,argv[i+1]);
7584 if (LocaleCompare(
"tile-offset",option+1) == 0)
7588 (void) SetImageOption(image_info,option+1,
"0");
7591 (void) SetImageOption(image_info,option+1,argv[i+1]);
7594 if (LocaleCompare(
"transparent-color",option+1) == 0)
7598 (void) QueryColorDatabase(
"none",&image_info->transparent_color, exception);
7599 (void) SetImageOption(image_info,option+1,
"none");
7602 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7604 (void) SetImageOption(image_info,option+1,argv[i+1]);
7607 if (LocaleCompare(
"type",option+1) == 0)
7611 image_info->type=UndefinedType;
7612 (void) SetImageOption(image_info,option+1,
"undefined");
7615 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7616 MagickFalse,argv[i+1]);
7617 (void) SetImageOption(image_info,option+1,argv[i+1]);
7624 if (LocaleCompare(
"undercolor",option+1) == 0)
7628 (void) DeleteImageOption(image_info,option+1);
7631 (void) SetImageOption(image_info,option+1,argv[i+1]);
7634 if (LocaleCompare(
"units",option+1) == 0)
7638 image_info->units=UndefinedResolution;
7639 (void) SetImageOption(image_info,option+1,
"undefined");
7642 image_info->units=(ResolutionType) ParseCommandOption(
7643 MagickResolutionOptions,MagickFalse,argv[i+1]);
7644 (void) SetImageOption(image_info,option+1,argv[i+1]);
7651 if (LocaleCompare(
"verbose",option+1) == 0)
7655 image_info->verbose=MagickFalse;
7658 image_info->verbose=MagickTrue;
7659 image_info->ping=MagickFalse;
7662 if (LocaleCompare(
"view",option+1) == 0)
7666 if (image_info->view != (
char *) NULL)
7667 image_info->view=DestroyString(image_info->view);
7670 (void) CloneString(&image_info->view,argv[i+1]);
7673 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
7677 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7678 (void) SetImageOption(image_info,option+1,
"undefined");
7681 image_info->virtual_pixel_method=(VirtualPixelMethod)
7682 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7684 (void) SetImageOption(image_info,option+1,argv[i+1]);
7691 if (LocaleCompare(
"weight",option+1) == 0)
7694 (void) SetImageOption(image_info,option+1,
"0");
7696 (
void) SetImageOption(image_info,option+1,argv[i+1]);
7699 if (LocaleCompare(
"white-point",option+1) == 0)
7703 (void) SetImageOption(image_info,option+1,
"0.0");
7706 (void) SetImageOption(image_info,option+1,argv[i+1]);
7753 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7754 const int argc,
const char **argv,Image **images,ExceptionInfo *exception)
7781 assert(image_info != (ImageInfo *) NULL);
7782 assert(image_info->signature == MagickCoreSignature);
7783 assert(images != (Image **) NULL);
7784 assert((*images)->previous == (Image *) NULL);
7785 assert((*images)->signature == MagickCoreSignature);
7786 if (IsEventLogging() != MagickFalse)
7787 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
7788 (*images)->filename);
7789 if ((argc <= 0) || (*argv == (
char *) NULL))
7791 mogrify_info=CloneImageInfo(image_info);
7792 quantize_info=AcquireQuantizeInfo(mogrify_info);
7793 channel=mogrify_info->channel;
7795 for (i=0; i < (ssize_t) argc; i++)
7797 if (*images == (Image *) NULL)
7800 if (IsCommandOption(option) == MagickFalse)
7802 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7803 count=MagickMax(count,0L);
7804 if ((i+count) >= (ssize_t) argc)
7806 status=MogrifyImageInfo(mogrify_info,(
int) count+1,argv+i,exception);
7807 switch (*(option+1))
7811 if (LocaleCompare(
"affinity",option+1) == 0)
7813 (void) SyncImagesSettings(mogrify_info,*images);
7816 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7817 InheritException(exception,&(*images)->exception);
7823 if (LocaleCompare(
"append",option+1) == 0)
7828 (void) SyncImagesSettings(mogrify_info,*images);
7829 append_image=AppendImages(*images,*option ==
'-' ? MagickTrue :
7830 MagickFalse,exception);
7831 if (append_image == (Image *) NULL)
7836 *images=DestroyImageList(*images);
7837 *images=append_image;
7840 if (LocaleCompare(
"average",option+1) == 0)
7848 (void) SyncImagesSettings(mogrify_info,*images);
7849 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7851 if (average_image == (Image *) NULL)
7856 *images=DestroyImageList(*images);
7857 *images=average_image;
7864 if (LocaleCompare(
"channel",option+1) == 0)
7868 channel=DefaultChannels;
7871 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7874 if (LocaleCompare(
"clut",option+1) == 0)
7880 (void) SyncImagesSettings(mogrify_info,*images);
7881 image=RemoveFirstImageFromList(images);
7882 clut_image=RemoveFirstImageFromList(images);
7883 if (clut_image == (Image *) NULL)
7885 (void) ThrowMagickException(exception,GetMagickModule(),
7886 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7887 image=DestroyImage(image);
7891 (void) ClutImageChannel(image,channel,clut_image);
7892 clut_image=DestroyImage(clut_image);
7893 InheritException(exception,&image->exception);
7894 *images=DestroyImageList(*images);
7898 if (LocaleCompare(
"coalesce",option+1) == 0)
7903 (void) SyncImagesSettings(mogrify_info,*images);
7904 coalesce_image=CoalesceImages(*images,exception);
7905 if (coalesce_image == (Image *) NULL)
7910 *images=DestroyImageList(*images);
7911 *images=coalesce_image;
7914 if (LocaleCompare(
"combine",option+1) == 0)
7919 (void) SyncImagesSettings(mogrify_info,*images);
7920 combine_image=CombineImages(*images,channel,exception);
7921 if (combine_image == (Image *) NULL)
7926 *images=DestroyImageList(*images);
7927 *images=combine_image;
7930 if (LocaleCompare(
"compare",option+1) == 0)
7947 (void) SyncImagesSettings(mogrify_info,*images);
7948 image=RemoveFirstImageFromList(images);
7949 reconstruct_image=RemoveFirstImageFromList(images);
7950 if (reconstruct_image == (Image *) NULL)
7952 (void) ThrowMagickException(exception,GetMagickModule(),
7953 OptionError,
"ImageSequenceRequired",
"`%s'",option);
7954 image=DestroyImage(image);
7958 metric=UndefinedMetric;
7959 option=GetImageOption(image_info,
"metric");
7960 if (option != (
const char *) NULL)
7961 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7962 MagickFalse,option);
7963 difference_image=CompareImageChannels(image,reconstruct_image,
7964 channel,metric,&distortion,exception);
7965 if (difference_image == (Image *) NULL)
7967 reconstruct_image=DestroyImage(reconstruct_image);
7968 image=DestroyImage(image);
7969 if (*images != (Image *) NULL)
7970 *images=DestroyImageList(*images);
7971 *images=difference_image;
7974 if (LocaleCompare(
"complex",option+1) == 0)
7982 (void) SyncImageSettings(mogrify_info,*images);
7983 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7984 MagickFalse,argv[i+1]);
7985 complex_images=ComplexImages(*images,op,exception);
7986 if (complex_images == (Image *) NULL)
7991 *images=DestroyImageList(*images);
7992 *images=complex_images;
7995 if (LocaleCompare(
"composite",option+1) == 0)
8005 (void) SyncImagesSettings(mogrify_info,*images);
8006 image=RemoveFirstImageFromList(images);
8007 composite_image=RemoveFirstImageFromList(images);
8008 if (composite_image == (Image *) NULL)
8010 (void) ThrowMagickException(exception,GetMagickModule(),
8011 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8012 image=DestroyImage(image);
8016 (void) TransformImage(&composite_image,(
char *) NULL,
8017 composite_image->geometry);
8018 SetGeometry(composite_image,&geometry);
8019 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
8020 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8022 mask_image=RemoveFirstImageFromList(images);
8023 if (mask_image != (Image *) NULL)
8025 if ((image->compose == DisplaceCompositeOp) ||
8026 (image->compose == DistortCompositeOp))
8031 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8033 mask_image=DestroyImage(mask_image);
8040 if (image->mask != (Image *) NULL)
8041 image->mask=DestroyImage(image->mask);
8042 image->mask=mask_image;
8043 (void) NegateImage(image->mask,MagickFalse);
8046 (void) CompositeImageChannel(image,channel,image->compose,
8047 composite_image,geometry.x,geometry.y);
8048 if (mask_image != (Image *) NULL)
8050 image->mask=DestroyImage(image->mask);
8051 mask_image=image->mask;
8053 composite_image=DestroyImage(composite_image);
8054 InheritException(exception,&image->exception);
8055 *images=DestroyImageList(*images);
8059 if (LocaleCompare(
"copy",option+1) == 0)
8073 (void) SyncImageSettings(mogrify_info,*images);
8074 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8075 offset.x=geometry.x;
8076 offset.y=geometry.y;
8077 source_image=(*images);
8078 if (source_image->next != (Image *) NULL)
8079 source_image=source_image->next;
8080 (
void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8082 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8090 if (LocaleCompare(
"deconstruct",option+1) == 0)
8095 (void) SyncImagesSettings(mogrify_info,*images);
8096 deconstruct_image=DeconstructImages(*images,exception);
8097 if (deconstruct_image == (Image *) NULL)
8102 *images=DestroyImageList(*images);
8103 *images=deconstruct_image;
8106 if (LocaleCompare(
"delete",option+1) == 0)
8109 DeleteImages(images,
"-1",exception);
8111 DeleteImages(images,argv[i+1],exception);
8114 if (LocaleCompare(
"dither",option+1) == 0)
8118 quantize_info->dither=MagickFalse;
8121 quantize_info->dither=MagickTrue;
8122 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8123 MagickDitherOptions,MagickFalse,argv[i+1]);
8126 if (LocaleCompare(
"duplicate",option+1) == 0)
8132 duplicate_images=DuplicateImages(*images,1,
"-1",exception);
8141 number_duplicates=(size_t) StringToLong(argv[i+1]);
8142 p=strchr(argv[i+1],
',');
8143 if (p == (
const char *) NULL)
8144 duplicate_images=DuplicateImages(*images,number_duplicates,
8147 duplicate_images=DuplicateImages(*images,number_duplicates,
8150 AppendImageToList(images, duplicate_images);
8151 (void) SyncImagesSettings(mogrify_info,*images);
8158 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
8163 MagickEvaluateOperator
8166 (void) SyncImageSettings(mogrify_info,*images);
8167 op=(MagickEvaluateOperator) ParseCommandOption(
8168 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8169 evaluate_image=EvaluateImages(*images,op,exception);
8170 if (evaluate_image == (Image *) NULL)
8175 *images=DestroyImageList(*images);
8176 *images=evaluate_image;
8183 if (LocaleCompare(
"fft",option+1) == 0)
8191 (void) SyncImageSettings(mogrify_info,*images);
8192 fourier_image=ForwardFourierTransformImage(*images,*option ==
'-' ?
8193 MagickTrue : MagickFalse,exception);
8194 if (fourier_image == (Image *) NULL)
8196 *images=DestroyImageList(*images);
8197 *images=fourier_image;
8200 if (LocaleCompare(
"flatten",option+1) == 0)
8205 (void) SyncImagesSettings(mogrify_info,*images);
8206 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8207 if (flatten_image == (Image *) NULL)
8209 *images=DestroyImageList(*images);
8210 *images=flatten_image;
8213 if (LocaleCompare(
"fx",option+1) == 0)
8218 (void) SyncImagesSettings(mogrify_info,*images);
8219 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
8220 if (fx_image == (Image *) NULL)
8225 *images=DestroyImageList(*images);
8233 if (LocaleCompare(
"hald-clut",option+1) == 0)
8239 (void) SyncImagesSettings(mogrify_info,*images);
8240 image=RemoveFirstImageFromList(images);
8241 hald_image=RemoveFirstImageFromList(images);
8242 if (hald_image == (Image *) NULL)
8244 (void) ThrowMagickException(exception,GetMagickModule(),
8245 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8246 image=DestroyImage(image);
8250 (void) HaldClutImageChannel(image,channel,hald_image);
8251 hald_image=DestroyImage(hald_image);
8252 InheritException(exception,&image->exception);
8253 if (*images != (Image *) NULL)
8254 *images=DestroyImageList(*images);
8262 if (LocaleCompare(
"ift",option+1) == 0)
8272 (void) SyncImagesSettings(mogrify_info,*images);
8273 magnitude_image=RemoveFirstImageFromList(images);
8274 phase_image=RemoveFirstImageFromList(images);
8275 if (phase_image == (Image *) NULL)
8277 (void) ThrowMagickException(exception,GetMagickModule(),
8278 OptionError,
"ImageSequenceRequired",
"`%s'",option);
8279 magnitude_image=DestroyImage(magnitude_image);
8283 fourier_image=InverseFourierTransformImage(magnitude_image,
8284 phase_image,*option ==
'-' ? MagickTrue : MagickFalse,exception);
8285 magnitude_image=DestroyImage(magnitude_image);
8286 phase_image=DestroyImage(phase_image);
8287 if (fourier_image == (Image *) NULL)
8289 if (*images != (Image *) NULL)
8290 *images=DestroyImageList(*images);
8291 *images=fourier_image;
8294 if (LocaleCompare(
"insert",option+1) == 0)
8302 index=(ssize_t) StringToLong(argv[i+1]);
8303 p=RemoveLastImageFromList(images);
8304 if (p == (Image *) NULL)
8306 (void) ThrowMagickException(exception,GetMagickModule(),
8307 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8313 PrependImageToList(images,q);
8315 if (index == (ssize_t) GetImageListLength(*images))
8316 AppendImageToList(images,q);
8319 q=GetImageFromList(*images,index-1);
8320 if (q == (Image *) NULL)
8323 (void) ThrowMagickException(exception,GetMagickModule(),
8324 OptionError,
"NoSuchImage",
"`%s'",argv[i+1]);
8328 InsertImageInList(&q,p);
8330 *images=GetFirstImageInList(q);
8337 if (LocaleCompare(
"layers",option+1) == 0)
8345 (void) SyncImagesSettings(mogrify_info,*images);
8346 layers=(Image *) NULL;
8347 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
8348 MagickFalse,argv[i+1]);
8353 layers=CoalesceImages(*images,exception);
8356 case CompareAnyLayer:
8357 case CompareClearLayer:
8358 case CompareOverlayLayer:
8361 layers=CompareImageLayers(*images,method,exception);
8367 case TrimBoundsLayer:
8369 layers=MergeImageLayers(*images,method,exception);
8374 layers=DisposeImages(*images,exception);
8377 case OptimizeImageLayer:
8379 layers=OptimizeImageLayers(*images,exception);
8382 case OptimizePlusLayer:
8384 layers=OptimizePlusImageLayers(*images,exception);
8387 case OptimizeTransLayer:
8389 OptimizeImageTransparency(*images,exception);
8392 case RemoveDupsLayer:
8394 RemoveDuplicateLayers(images,exception);
8397 case RemoveZeroLayer:
8399 RemoveZeroDelayLayers(images,exception);
8407 layers=CoalesceImages(*images,exception);
8408 if (layers == (Image *) NULL)
8413 InheritException(exception,&layers->exception);
8414 *images=DestroyImageList(*images);
8416 layers=OptimizeImageLayers(*images,exception);
8417 if (layers == (Image *) NULL)
8422 InheritException(exception,&layers->exception);
8423 *images=DestroyImageList(*images);
8425 layers=(Image *) NULL;
8426 OptimizeImageTransparency(*images,exception);
8427 InheritException(exception,&(*images)->exception);
8428 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8431 case CompositeLayer:
8446 while (source != (Image *) NULL)
8448 source=GetNextImageInList(source);
8449 if ((source != (Image *) NULL) &&
8450 (LocaleCompare(source->magick,
"NULL") == 0))
8453 if (source != (Image *) NULL)
8455 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8456 (GetNextImageInList(source) == (Image *) NULL))
8457 source=(Image *) NULL;
8463 source=SplitImageList(source->previous);
8464 DeleteImageFromList(&source);
8467 if (source == (Image *) NULL)
8469 (void) ThrowMagickException(exception,GetMagickModule(),
8470 OptionError,
"MissingNullSeparator",
"layers Composite");
8477 SetGeometry(*images,&geometry);
8478 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8479 geometry.width=source->page.width != 0 ?
8480 source->page.width : source->columns;
8481 geometry.height=source->page.height != 0 ?
8482 source->page.height : source->rows;
8483 GravityAdjustGeometry((*images)->page.width != 0 ?
8484 (*images)->page.width : (*images)->columns,
8485 (*images)->page.height != 0 ? (*images)->page.height :
8486 (*images)->rows,(*images)->gravity,&geometry);
8487 compose=OverCompositeOp;
8488 option=GetImageOption(mogrify_info,
"compose");
8489 if (option != (
const char *) NULL)
8490 compose=(CompositeOperator) ParseCommandOption(
8491 MagickComposeOptions,MagickFalse,option);
8492 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8494 source=DestroyImageList(source);
8498 if (layers == (Image *) NULL)
8500 InheritException(exception,&layers->exception);
8501 *images=DestroyImageList(*images);
8509 if (LocaleCompare(
"map",option+1) == 0)
8511 (void) SyncImagesSettings(mogrify_info,*images);
8514 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8515 InheritException(exception,&(*images)->exception);
8521 if (LocaleCompare(
"maximum",option+1) == 0)
8529 (void) SyncImagesSettings(mogrify_info,*images);
8530 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8531 if (maximum_image == (Image *) NULL)
8536 *images=DestroyImageList(*images);
8537 *images=maximum_image;
8540 if (LocaleCompare(
"minimum",option+1) == 0)
8548 (void) SyncImagesSettings(mogrify_info,*images);
8549 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8550 if (minimum_image == (Image *) NULL)
8555 *images=DestroyImageList(*images);
8556 *images=minimum_image;
8559 if (LocaleCompare(
"morph",option+1) == 0)
8564 (void) SyncImagesSettings(mogrify_info,*images);
8565 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8567 if (morph_image == (Image *) NULL)
8572 *images=DestroyImageList(*images);
8573 *images=morph_image;
8576 if (LocaleCompare(
"mosaic",option+1) == 0)
8581 (void) SyncImagesSettings(mogrify_info,*images);
8582 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8583 if (mosaic_image == (Image *) NULL)
8588 *images=DestroyImageList(*images);
8589 *images=mosaic_image;
8596 if (LocaleCompare(
"poly",option+1) == 0)
8600 token[MaxTextExtent];
8620 (void) SyncImageSettings(mogrify_info,*images);
8621 args=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8622 InheritException(exception,&(*images)->exception);
8623 if (args == (
char *) NULL)
8626 for (x=0; *p !=
'\0'; x++)
8628 (void) GetNextToken(p,&p,MaxTextExtent,token);
8630 (void) GetNextToken(p,&p,MaxTextExtent,token);
8632 number_arguments=(size_t) x;
8633 arguments=(
double *) AcquireQuantumMemory(number_arguments,
8634 sizeof(*arguments));
8635 if (arguments == (
double *) NULL)
8636 ThrowWandFatalException(ResourceLimitFatalError,
8637 "MemoryAllocationFailed",(*images)->filename);
8638 (void) memset(arguments,0,number_arguments*
8639 sizeof(*arguments));
8641 for (x=0; (x < (ssize_t) number_arguments) && (*p !=
'\0'); x++)
8643 (void) GetNextToken(p,&p,MaxTextExtent,token);
8645 (void) GetNextToken(p,&p,MaxTextExtent,token);
8646 arguments[x]=StringToDouble(token,(
char **) NULL);
8648 args=DestroyString(args);
8649 polynomial_image=PolynomialImageChannel(*images,channel,
8650 number_arguments >> 1,arguments,exception);
8651 arguments=(
double *) RelinquishMagickMemory(arguments);
8652 if (polynomial_image == (Image *) NULL)
8657 *images=DestroyImageList(*images);
8658 *images=polynomial_image;
8661 if (LocaleCompare(
"print",option+1) == 0)
8666 (void) SyncImagesSettings(mogrify_info,*images);
8667 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8668 if (
string == (
char *) NULL)
8670 InheritException(exception,&(*images)->exception);
8671 (void) FormatLocaleFile(stdout,
"%s",
string);
8672 string=DestroyString(
string);
8674 if (LocaleCompare(
"process",option+1) == 0)
8683 (void) SyncImagesSettings(mogrify_info,*images);
8684 arguments=StringToArgv(argv[i+1],&number_arguments);
8685 if (arguments == (
char **) NULL)
8687 if ((argc > 1) && (strchr(arguments[1],
'=') != (
char *) NULL))
8710 length=strlen(argv[i+1]);
8711 token=(
char *) NULL;
8712 if (~length >= (MaxTextExtent-1))
8713 token=(
char *) AcquireQuantumMemory(length+MaxTextExtent,
8715 if (token == (
char *) NULL)
8718 arguments=argv[i+1];
8719 token_info=AcquireTokenInfo();
8720 status=Tokenizer(token_info,0,token,length,arguments,
"",
"=",
8721 "\"",
'\0',&breaker,&next,"e);
8722 token_info=DestroyTokenInfo(token_info);
8728 argv=(&(arguments[next]));
8729 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8732 token=DestroyString(token);
8735 (void) SubstituteString(&arguments[1],
"-",
"");
8736 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8737 number_arguments-2,(
const char **) arguments+2,exception);
8738 for (j=0; j < number_arguments; j++)
8739 arguments[j]=DestroyString(arguments[j]);
8740 arguments=(
char **) RelinquishMagickMemory(arguments);
8747 if (LocaleCompare(
"reverse",option+1) == 0)
8749 ReverseImageList(images);
8750 InheritException(exception,&(*images)->exception);
8757 if (LocaleCompare(
"smush",option+1) == 0)
8765 (void) SyncImagesSettings(mogrify_info,*images);
8766 offset=(ssize_t) StringToLong(argv[i+1]);
8767 smush_image=SmushImages(*images,*option ==
'-' ? MagickTrue :
8768 MagickFalse,offset,exception);
8769 if (smush_image == (Image *) NULL)
8774 *images=DestroyImageList(*images);
8775 *images=smush_image;
8778 if (LocaleCompare(
"swap",option+1) == 0)
8800 flags=ParseGeometry(argv[i+1],&geometry_info);
8801 index=(ssize_t) geometry_info.rho;
8802 if ((flags & SigmaValue) != 0)
8803 swap_index=(ssize_t) geometry_info.sigma;
8805 p=GetImageFromList(*images,index);
8806 q=GetImageFromList(*images,swap_index);
8807 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8809 (void) ThrowMagickException(exception,GetMagickModule(),
8810 OptionError,
"NoSuchImage",
"`%s'",(*images)->filename);
8816 u=CloneImage(p,0,0,MagickTrue,exception);
8817 if (u == (Image *) NULL)
8819 v=CloneImage(q,0,0,MagickTrue,exception);
8820 if (v == (Image *) NULL)
8825 ReplaceImageInList(&p,v);
8826 ReplaceImageInList(&q,u);
8827 *images=GetFirstImageInList(q);
8834 if (LocaleCompare(
"write",option+1) == 0)
8845 (void) SyncImagesSettings(mogrify_info,*images);
8846 (void) FormatLocaleString(key,MaxTextExtent,
"cache:%s",argv[i+1]);
8847 (void) DeleteImageRegistry(key);
8848 write_images=CloneImageList(*images,exception);
8849 write_info=CloneImageInfo(mogrify_info);
8850 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8851 write_info=DestroyImageInfo(write_info);
8852 write_images=DestroyImageList(write_images);
8862 quantize_info=DestroyQuantizeInfo(quantize_info);
8863 mogrify_info=DestroyImageInfo(mogrify_info);
8864 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8865 return(status != 0 ? MagickTrue : MagickFalse);
8905 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8906 const MagickBooleanType post,
const int argc,
const char **argv,
8907 Image **images,ExceptionInfo *exception)
8909 #define MogrifyImageTag "Mogrify/Image"
8923 assert(image_info != (ImageInfo *) NULL);
8924 assert(image_info->signature == MagickCoreSignature);
8925 if (images == (Image **) NULL)
8926 return(MogrifyImage(image_info,argc,argv,images,exception));
8927 assert((*images)->previous == (Image *) NULL);
8928 assert((*images)->signature == MagickCoreSignature);
8929 if (IsEventLogging() != MagickFalse)
8930 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
8931 (*images)->filename);
8932 if ((argc <= 0) || (*argv == (
char *) NULL))
8934 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8938 (void) FormatLocaleFile(stderr,
"mogrify start %s %d (%s)\n",argv[0],argc,
8944 if (post == MagickFalse)
8945 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8950 n=GetImageListLength(*images);
8954 (void) FormatLocaleFile(stderr,
"mogrify %ld of %ld\n",(
long)
8955 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8957 status&=MogrifyImage(image_info,argc,argv,images,exception);
8958 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8959 if (proceed == MagickFalse)
8961 if ((*images)->next == (Image *) NULL)
8963 *images=(*images)->next;
8966 assert(*images != (Image *) NULL);
8968 (void) FormatLocaleFile(stderr,
"mogrify end %ld of %ld\n",(
long)
8969 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8974 *images=GetFirstImageInList(*images);
8975 if (post != MagickFalse)
8976 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8977 return(status != 0 ? MagickTrue : MagickFalse);