From 1afdc7ad27c38cee6623faefd0a64a0e0c185feb Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 5 Oct 2011 11:54:28 +0000 Subject: [PATCH] Move "authenticate" string from image_info to Options splay-tree --- MagickCore/image.c | 10 +-- MagickCore/image.h | 4 +- MagickWand/magick-property.c | 2 +- MagickWand/mogrify.c | 12 ++- MagickWand/operation.c | 137 ++++++++++++++++------------------- coders/pcl.c | 8 +- coders/pdf.c | 5 +- coders/xps.c | 8 +- 8 files changed, 90 insertions(+), 96 deletions(-) diff --git a/MagickCore/image.c b/MagickCore/image.c index b82e00955..8b559d7a6 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -972,9 +972,6 @@ MagickExport ImageInfo *CloneImageInfo(const ImageInfo *image_info) clone_info->verbose=image_info->verbose; if (image_info->view != (char *) NULL) (void) CloneString(&clone_info->view,image_info->view); - if (image_info->authenticate != (char *) NULL) - (void) CloneString(&clone_info->authenticate,image_info->authenticate); - (void) CloneImageOptions(clone_info,image_info); clone_info->progress_monitor=image_info->progress_monitor; clone_info->client_data=image_info->client_data; clone_info->cache=image_info->cache; @@ -993,6 +990,8 @@ MagickExport ImageInfo *CloneImageInfo(const ImageInfo *image_info) (void) CopyMagickString(clone_info->filename,image_info->filename, MaxTextExtent); clone_info->channel=image_info->channel; + + (void) CloneImageOptions(clone_info,image_info); clone_info->debug=IsEventLogging(); clone_info->signature=image_info->signature; return(clone_info); @@ -1289,15 +1288,12 @@ MagickExport ImageInfo *DestroyImageInfo(ImageInfo *image_info) image_info->density=DestroyString(image_info->density); if (image_info->view != (char *) NULL) image_info->view=DestroyString(image_info->view); - if (image_info->authenticate != (char *) NULL) - image_info->authenticate=DestroyString( - image_info->authenticate); - DestroyImageOptions(image_info); if (image_info->cache != (void *) NULL) image_info->cache=DestroyPixelCache(image_info->cache); if (image_info->profile != (StringInfo *) NULL) image_info->profile=(void *) DestroyStringInfo((StringInfo *) image_info->profile); + DestroyImageOptions(image_info); image_info->signature=(~MagickSignature); image_info=(ImageInfo *) RelinquishMagickMemory(image_info); return(image_info); diff --git a/MagickCore/image.h b/MagickCore/image.h index 6f18b1d8a..44074841b 100644 --- a/MagickCore/image.h +++ b/MagickCore/image.h @@ -426,8 +426,8 @@ struct _ImageInfo verbose; /* verbose output enable/disable */ char - *view, - *authenticate; + *view; + /* authenticate -- moved to ImageOptions() ChannelType channel; diff --git a/MagickWand/magick-property.c b/MagickWand/magick-property.c index ec38a55b0..e24b5e26c 100644 --- a/MagickWand/magick-property.c +++ b/MagickWand/magick-property.c @@ -2594,7 +2594,7 @@ WandExport MagickBooleanType MagickSetPassphrase(MagickWand *wand, assert(wand->signature == WandSignature); if (wand->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); - (void) CloneString(&wand->image_info->authenticate,passphrase); + (void) SetImageOption(wand->image_info,"authenticate",passphrase); return(MagickTrue); } diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index 13ab61352..2a13ce5fc 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -6162,19 +6162,17 @@ WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, if (LocaleCompare("attenuate",option+1) == 0) { if (*option == '+') - { - (void) DeleteImageOption(image_info,option+1); - break; - } - (void) SetImageOption(image_info,option+1,argv[i+1]); + (void) DeleteImageOption(image_info,option+1); + else + (void) SetImageOption(image_info,option+1,argv[i+1]); break; } if (LocaleCompare("authenticate",option+1) == 0) { if (*option == '+') - (void) CloneString(&image_info->authenticate,(char *) NULL); + (void) DeleteImageOption(image_info,option+1); else - (void) CloneString(&image_info->authenticate,argv[i+1]); + (void) SetImageOption(image_info,option+1,argv[i+1]); break; } break; diff --git a/MagickWand/operation.c b/MagickWand/operation.c index 6717a67bb..b09b4e4b0 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -43,7 +43,7 @@ % % Anthony Thyssen, Sept 2011 */ -#if 0 +#if 1 /* Include declarations. @@ -291,7 +291,7 @@ static Image *SparseColorOption(const Image *image, if ( token[0] == '\0' ) break; if ( isalpha((int) token[0]) || token[0] == '#' ) { /* Color string given */ - (void) QueryMagickColorCompliance(token,AllComplience,&color, + (void) QueryMagickColorCompliance(token,AllCompliance,&color, exception); if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) sparse_arguments[x++] = QuantumScale*color.red; @@ -375,23 +375,26 @@ static Image *SparseColorOption(const Image *image, % % % % % % -+ S e t t i n g s O p t i o n I n f o % ++ A p p l y S e t t i n g O p t i o n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% SettingsOptionInfo() saves the given single settings argv[0] into a -% ImageInfo structure for later use by various image processing operations. +% ApplySettingOption() saves the given single settings option into a CLI wand +% holding the image_info, draw_info, quantize_info structures that is later +% used for reading, processing, and writing images. +% +% No image in the wand is actually modified (setting options only) % -% The format of the SettingsOptionInfo method is: +% The format of the ApplySettingOption method is: % -% MagickBooleanType SettingsOptionInfo(ImageInfo *image_info, +% MagickBooleanType ApplySettingOption(MagickWand *wand, % const int argc, const char **argv,ExceptionInfo *exception) % % A description of each parameter follows: % -% o image_info: the image info.. +% o wand: structure holding settings to be applied % % o argc: Specifies a pointer to an integer describing the number of % elements in the argument vector. @@ -408,19 +411,24 @@ WandExport MagickBooleanType SettingsOptionInfo(ImageInfo *image_info, GeometryInfo geometry_info; - /* - Initialize method variables. - */ - assert(image_info != (ImageInfo *) NULL); - assert(image_info->signature == MagickSignature); - if (image_info->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", - image_info->filename); + ImageInfo + *image_info; + + DrawInfo + *draw_info + + assert(wand != (MagickWand *) NULL); + assert(wand->signature == WandSignature); + assert(wand->draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */ + assert(wand->quantize_info == (QuantizeInfo *) NULL); + if (wand->debug != MagickFalse) + (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); if (argc < 0) return(MagickTrue); - /* - Set the image settings for one image. - */ + + image_info=wand->image_info; + draw_info=wand->_info; + switch (*(argv[0]+1)) { case 'a': @@ -430,27 +438,37 @@ WandExport MagickBooleanType SettingsOptionInfo(ImageInfo *image_info, image_info->adjoin=(*argv[0] == '-') ? MagickTrue : MagickFalse; break; } + if (LocaleCompare("affine",argv[0]+1) == 0) + { + if (*argv[0] == '+') + GetAffineMatrix(draw_info->affine); + else + (void) ParseAffineGeometry(argv[1],draw_info->affine, + exception); + break; + } if (LocaleCompare("antialias",argv[0]+1) == 0) { - image_info->antialias=(*argv[0] == '-') ? MagickTrue : MagickFalse; + image_info->antialias = + draw_info->stroke_antialias = + draw_info->text_antialias = + (*argv[0] == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("attenuate",argv[0]+1) == 0) { if (*argv[0] == '+') - { - (void) DeleteImageOption(image_info,argv[0]+1); - break; - } - (void) SetImageOption(image_info,argv[0]+1,argv[1]); + (void) DeleteImageOption(image_info,argv[0]+1); + else + (void) SetImageOption(image_info,argv[0]+1,argv[1]); break; } if (LocaleCompare("authenticate",argv[0]+1) == 0) { if (*argv[0] == '+') - (void) CloneString(&image_info->authenticate,(char *) NULL); + (void) DeleteImageOption(image_info,argv[0]+1); else - (void) CloneString(&image_info->authenticate,argv[1]); + (void) SetImageOption(image_info,argv[0]+1,argv[1]); break; } break; @@ -462,12 +480,12 @@ WandExport MagickBooleanType SettingsOptionInfo(ImageInfo *image_info, if (*argv[0] == '+') { (void) DeleteImageOption(image_info,argv[0]+1); - (void) QueryColorCompliance(BackgroundColor,AllComplience, + (void) QueryColorCompliance(BackgroundColor,AllCompliance, &image_info->background_color,exception); break; } (void) SetImageOption(image_info,argv[0]+1,argv[1]); - (void) QueryColorCompliance(argv[1],AllComplience, + (void) QueryColorCompliance(argv[1],AllCompliance, &image_info->background_color,exception); break; } @@ -506,7 +524,7 @@ WandExport MagickBooleanType SettingsOptionInfo(ImageInfo *image_info, if (*argv[0] == '+') { (void) DeleteImageOption(image_info,argv[0]+1); - (void) QueryColorCompliance(BorderColor,AllComplience, + (void) QueryColorCompliance(BorderColor,AllCompliance, &image_info->border_color,exception); break; } @@ -1077,12 +1095,12 @@ WandExport MagickBooleanType SettingsOptionInfo(ImageInfo *image_info, if (*argv[0] == '+') { (void) SetImageOption(image_info,argv[0]+1,argv[1]); - (void) QueryColorCompliance(MatteColor,AllComplience, + (void) QueryColorCompliance(MatteColor,AllCompliance, &image_info->matte_color,exception); break; } (void) SetImageOption(image_info,argv[0]+1,argv[1]); - (void) QueryColorCompliance(argv[1],AllComplience,&image_info->matte_color, + (void) QueryColorCompliance(argv[1],AllCompliance,&image_info->matte_color, exception); break; } @@ -1379,12 +1397,12 @@ WandExport MagickBooleanType SettingsOptionInfo(ImageInfo *image_info, { if (*argv[0] == '+') { - (void) QueryColorCompliance("none",AllComplience, + (void) QueryColorCompliance("none",AllCompliance, &image_info->transparent_color,exception); (void) SetImageOption(image_info,argv[0]+1,"none"); break; } - (void) QueryColorCompliance("none",AllComplience, + (void) QueryColorCompliance("none",AllCompliance, &image_info->transparent_color,exception); exception); (void) SetImageOption(image_info,argv[0]+1,argv[1]); @@ -1595,9 +1613,6 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, { if (LocaleCompare("adaptive-blur",argv[0]+1) == 0) { - /* - Adaptive blur image. - */ (void) SyncImageSettings(image_info,*image); flags=ParseGeometry(argv[1],&geometry_info); if ((flags & SigmaValue) == 0) @@ -1610,8 +1625,8 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, } if (LocaleCompare("adaptive-resize",argv[0]+1) == 0) { - /* - Adaptive resize image. + /* FUTURE: this is really a "interpolate-resize" operator + "adaptive-resize" uses a fixed "Mesh" interpolation */ (void) SyncImageSettings(image_info,*image); (void) ParseRegionGeometry(*image,argv[1],&geometry,exception); @@ -1634,19 +1649,6 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, geometry_info.sigma,geometry_info.xi,exception); break; } - if (LocaleCompare("affine",argv[0]+1) == 0) - { - /* - Affine matrix. - */ - if (*argv[0] == '+') - { - GetAffineMatrix(&draw_info->affine); - break; - } - (void) ParseAffineGeometry(argv[1],&draw_info->affine,exception); - break; - } if (LocaleCompare("alpha",argv[0]+1) == 0) { AlphaChannelType @@ -1664,9 +1666,6 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, *text, geometry[MaxTextExtent]; - /* - Annotate image. - */ (void) SyncImageSettings(image_info,*image); SetGeometryInfo(&geometry_info); flags=ParseGeometry(argv[1],&geometry_info); @@ -1692,14 +1691,6 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, (void) AnnotateImage(*image,draw_info,exception); break; } - if (LocaleCompare("antialias",argv[0]+1) == 0) - { - draw_info->stroke_antialias=(*argv[0] == '-') ? MagickTrue : - MagickFalse; - draw_info->text_antialias=(*argv[0] == '-') ? MagickTrue : - MagickFalse; - break; - } if (LocaleCompare("auto-gamma",argv[0]+1) == 0) { /* @@ -1822,17 +1813,17 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, { if (*argv[0] == '+') { - (void) QueryColorCompliance(BorderColor,AllComplience, + (void) QueryColorCompliance(BorderColor,AllCompliance, &draw_info->border_color,exception); break; } - (void) QueryColorCompliance(argv[1],AllComplience,&draw_info->border_color, + (void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->border_color, exception); break; } if (LocaleCompare("box",argv[0]+1) == 0) { - (void) QueryColorCompliance(argv[1],AllComplience,&draw_info->undercolor, + (void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->undercolor, exception); break; } @@ -2438,7 +2429,7 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, { (void) QueryMagickColorCompliance("none",AllCompliance,&fill, exception); - (void) QueryColorCompliance("none",AllComplience,&draw_info->fill, + (void) QueryColorCompliance("none",AllCompliance,&draw_info->fill, exception); if (draw_info->fill_pattern != (Image *) NULL) draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); @@ -2446,7 +2437,7 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, } sans=AcquireExceptionInfo(); (void) QueryMagickColorCompliance(argv[1],AllCompliance,&fill,sans); - status=QueryColorCompliance(argv[1],AllComplience,&draw_info->fill,sans); + status=QueryColorCompliance(argv[1],AllCompliance,&draw_info->fill,sans); sans=DestroyExceptionInfo(sans); if (status == MagickFalse) draw_info->fill_pattern=GetImageCache(image_info,argv[1], @@ -3117,11 +3108,11 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, { if (*argv[0] == '+') { - (void) QueryColorCompliance("none",AllComplience,&draw_info->fill, + (void) QueryColorCompliance("none",AllCompliance,&draw_info->fill, exception); break; } - (void) QueryColorCompliance(argv[1],AllComplience,&draw_info->fill, + (void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->fill, exception); break; } @@ -3718,7 +3709,7 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, if (*argv[0] == '+') { - (void) QueryColorCompliance("none",AllComplience,&draw_info->stroke, + (void) QueryColorCompliance("none",AllCompliance,&draw_info->stroke, exception); if (draw_info->stroke_pattern != (Image *) NULL) draw_info->stroke_pattern=DestroyImage( @@ -3726,7 +3717,7 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, break; } sans=AcquireExceptionInfo(); - status=QueryColorCompliance(argv[1],AllComplience,&draw_info->stroke,sans); + status=QueryColorCompliance(argv[1],AllCompliance,&draw_info->stroke,sans); sans=DestroyExceptionInfo(sans); if (status == MagickFalse) draw_info->stroke_pattern=GetImageCache(image_info,argv[1], @@ -3890,7 +3881,7 @@ MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info, { if (LocaleCompare("undercolor",argv[0]+1) == 0) { - (void) QueryColorCompliance(argv[1],AllComplience,&draw_info->undercolor, + (void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->undercolor, exception); break; } diff --git a/coders/pcl.c b/coders/pcl.c index 50d64a3a7..7f9c60711 100644 --- a/coders/pcl.c +++ b/coders/pcl.c @@ -157,6 +157,9 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception) options[MaxTextExtent], input_filename[MaxTextExtent]; + const char + *option; + const DelegateInfo *delegate_info; @@ -347,9 +350,10 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception) if (read_info->scenes != (char *) NULL) *read_info->scenes='\0'; } - if (read_info->authenticate != (char *) NULL) + option=GetImageOption(read_info,"authenticate"); + if (option != (const char *) NULL) (void) FormatLocaleString(options+strlen(options),MaxTextExtent, - " -sPCLPassword=%s",read_info->authenticate); + " -sPCLPassword=%s",option); (void) CopyMagickString(filename,read_info->filename,MaxTextExtent); (void) AcquireUniqueFilename(read_info->filename); (void) FormatLocaleString(command,MaxTextExtent, diff --git a/coders/pdf.c b/coders/pdf.c index 410495d46..514181f17 100644 --- a/coders/pdf.c +++ b/coders/pdf.c @@ -622,9 +622,10 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception) if (read_info->scenes != (char *) NULL) *read_info->scenes='\0'; } - if (read_info->authenticate != (char *) NULL) + option=GetImageOption(read_info,"authenticate"); + if (option != (const char *) NULL) (void) FormatLocaleString(options+strlen(options),MaxTextExtent, - " -sPDFPassword=%s",read_info->authenticate); + " -sPCLPassword=%s",option); (void) CopyMagickString(filename,read_info->filename,MaxTextExtent); (void) AcquireUniqueFilename(filename); (void) ConcatenateMagickString(filename,"-%08d",MaxTextExtent); diff --git a/coders/xps.c b/coders/xps.c index 274b2785a..0d6d4803f 100644 --- a/coders/xps.c +++ b/coders/xps.c @@ -110,6 +110,9 @@ static Image *ReadXPSImage(const ImageInfo *image_info,ExceptionInfo *exception) options[MaxTextExtent], input_filename[MaxTextExtent]; + const char + option; + const DelegateInfo *delegate_info; @@ -300,9 +303,10 @@ static Image *ReadXPSImage(const ImageInfo *image_info,ExceptionInfo *exception) if (read_info->scenes != (char *) NULL) *read_info->scenes='\0'; } - if (read_info->authenticate != (char *) NULL) + option=GetImageOption(read_info,"authenticate"); + if (option != (const char *) NULL) (void) FormatLocaleString(options+strlen(options),MaxTextExtent, - " -sXPSPassword=%s",read_info->authenticate); + " -sPCLPassword=%s",option); (void) CopyMagickString(filename,read_info->filename,MaxTextExtent); (void) AcquireUniqueFilename(read_info->filename); (void) FormatLocaleString(command,MaxTextExtent, -- 2.50.1