]> granicus.if.org Git - imagemagick/commitdiff
Move "authenticate" string from image_info to Options splay-tree
authoranthony <anthony@git.imagemagick.org>
Wed, 5 Oct 2011 11:54:28 +0000 (11:54 +0000)
committeranthony <anthony@git.imagemagick.org>
Wed, 5 Oct 2011 11:54:28 +0000 (11:54 +0000)
MagickCore/image.c
MagickCore/image.h
MagickWand/magick-property.c
MagickWand/mogrify.c
MagickWand/operation.c
coders/pcl.c
coders/pdf.c
coders/xps.c

index b82e009551d4656ed64146d51ad86b7862bb170e..8b559d7a6b3126f4b8568d777a73b13b3e5271f9 100644 (file)
@@ -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);
index 6f18b1d8a8ed2225ea8da2d6ba1f5b51eb311d9c..44074841b4ed6c04be8cba4d1b4f20fbc3e33940 100644 (file)
@@ -426,8 +426,8 @@ struct _ImageInfo
     verbose;                 /* verbose output enable/disable */
 
   char
-    *view,
-    *authenticate;
+    *view;
+    /* authenticate -- moved to ImageOptions()
 
   ChannelType
     channel;
index ec38a55b0cc02c1e566550494ab5c5233c8cb589..e24b5e26cc184154cbadc906948c97c47561adc4 100644 (file)
@@ -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);
 }
 \f
index 13ab61352b6fe0eed0da742b8357a3dece95b597..2a13ce5fcf246c139cc1bde117b36990456d08e9 100644 (file)
@@ -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;
index 6717a67bb0557e2b3c2b6db0e60f75cd9bd84956..b09b4e4b068e8a576f0727d01308d4761541bc73 100644 (file)
@@ -43,7 +43,7 @@
 %
 % Anthony Thyssen, Sept 2011
 */
-#if 0
+#if 1
 \f
 /*
   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;
         }
index 50d64a3a7b5d0ed0addb2729352fff837115b4b8..7f9c6071176de97435ae08e0ebe3581df392f7a7 100644 (file)
@@ -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,
index 410495d46538f65df2c61202606077d465a10e55..514181f17a5b308a38e4c564224f4170491524ce 100644 (file)
@@ -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);
index 274b2785a655f54ab209c3e587f90b1c2551b37e..0d6d4803f5b9fe9484037c286991c12e2d133b42 100644 (file)
@@ -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,