]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authoranthony <anthony@git.imagemagick.org>
Sun, 29 Apr 2012 11:45:40 +0000 (11:45 +0000)
committeranthony <anthony@git.imagemagick.org>
Sun, 29 Apr 2012 11:45:40 +0000 (11:45 +0000)
MagickCore/image.c
MagickCore/property.c
MagickCore/string.c
MagickWand/magick-cli.c

index 5e51c26c68d3ff6c31906b05c80b6dc288f36443..b4602d9bec79683a6f4a5f6789a0f61f9ab89bf5 100644 (file)
@@ -1536,15 +1536,25 @@ MagickExport size_t InterpretImageFilename(const ImageInfo *image_info,
         if (LocaleNCompare(pattern,"filename:",9) != 0)
           break;
         value=(const char *) NULL;
+#if 0
+        // FUTURE: remove this code. -- Anthony  29 Arpil 2012
+        // Removed as GetMagickProperty() will now return a 'cloned' string
+        // that must also be freed. It will never match a "filename:" string
+        // in any case as this is not a specificaally 'known' image properity.
+        //
         if ((image_info != (const ImageInfo *) NULL) &&
             (image != (const Image *) NULL))
           value=GetMagickProperty(image_info,image,pattern,exception);
         else
-          if (image != (Image *) NULL)
-            value=GetImageProperty(image,pattern,exception);
-          else
-            if (image_info != (ImageInfo *) NULL)
-              value=GetImageOption(image_info,pattern);
+#endif
+        if (image != (Image *) NULL)
+          value=GetImageProperty(image,pattern,exception);
+        if ((value == (const char *) NULL) &&
+            (image != (Image *) NULL))
+          value=GetImageArtifact(image,pattern);
+        if ((value == (const char *) NULL) &&
+            (image_info != (ImageInfo *) NULL))
+          value=GetImageOption(image_info,pattern);
         if (value == (const char *) NULL)
           break;
         q--;
index ef706c4fcddd9c36713372a6957ce883764f7d8f..a7fa1d54a2d0f70fcf3697f0d866fbd8fd0a1865 100644 (file)
@@ -2160,12 +2160,19 @@ MagickExport const char *GetImageProperty(const Image *image,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetMagickProperty() gets a value associated with an image property.
+%  GetMagickProperty() gets attributes or calculated values that is associated
+%  with a fixed known property name.
+%
+%  This does not return single character properity names, special profile or
+%  calculated properity substitutions. Nor does it return free-form properity
+%  strings, unless such a name is also associated with a specific attribute.
+%
+%  The returned string should be freed using DestoryString() when finished.
 %
 %  The format of the GetMagickProperty method is:
 %
 %      const char *GetMagickProperty(const ImageInfo *image_info,Image *image,
-%        const char *key,ExceptionInfo *exception)
+%        const char *properity,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2190,7 +2197,8 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
   {
     case 'b':
     {
-      if (LocaleNCompare("base",property,4) == 0)
+      if ((LocaleNCompare("base",property,4) == 0) ||
+          (LocaleNCompare("basename",property,8) == 0) )
         {
           GetPathComponent(image->magick_filename,BasePath,filename);
           (void) CopyMagickString(value,filename,MaxTextExtent);
@@ -2524,15 +2532,9 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
       break;
     }
   }
-  if (*value != '\0')
-   {
-     if (image->properties == (void *) NULL)
-       image->properties=NewSplayTree(CompareSplayTreeString,
-         RelinquishMagickMemory,RelinquishMagickMemory);
-     (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
-       ConstantString(property),ConstantString(value));
-   }
-  return(GetImageProperty(image,property,exception));
+  if (*value == '\0')
+    return(NULL);
+  return(ConstantString(value));
 }
 \f
 /*
@@ -2546,7 +2548,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetNextImageProperty() gets the next image property value.
+%  GetNextImageProperty() gets the next free-form string properity name.
 %
 %  The format of the GetNextImageProperty method is:
 %
@@ -2581,8 +2583,23 @@ MagickExport char *GetNextImageProperty(const Image *image)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  InterpretImageProperties() replaces any embedded formatting characters with
-%  the appropriate image property and returns the interpreted text.  Free with
-%  DestoryString() or RelinquishMagickMemory().
+%  the appropriate image property and returns the interpreted text.
+%
+%  This searches for and replaces
+%     %x           where 'x' is a single letter, case sensitive).
+%     %[type:...]  where 'type' is specifically known prefix.
+%     %[name]      where 'name' is a specifically known attribute, calculated
+%                  value, or free-form properity string name, or a free-form
+%                  global option string setting.
+%     \n \r        replaced by newline, return
+%     &lt; &lt;    replaced by '<', '>' resp.
+%
+%  If 'name' is a 'glob-expresion' (containing '*' or '?' characters) it is used
+%  as a search pattern to print "name=value\n" pairs of free-form string
+%  properities. Some 'type' properities may also allow 'glob-expressions'.
+%
+%  The returned string must be freeds using DestoryString() or
+%  RelinquishMagickMemory().
 %
 %  The format of the InterpretImageProperties method is:
 %
@@ -2775,6 +2792,7 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
               }
             (void) CopyMagickString(q,value,extent);
             q+=length;
+            value=DestroyString((char *)value); /* must be destoryed */
             break;
           }
         if (image_info == (ImageInfo *) NULL)
index 3ace2252586d8c1dec1172e06fe268c1b6f4f281..5d18b889b463aad83619ff325b9f5c5f3caf0f05 100644 (file)
@@ -247,6 +247,8 @@ MagickExport StringInfo *BlobToStringInfo(const void *blob,const size_t length)
 %
 %  A pointer to the copy of the source string, or NULL is returned.
 %
+%  Free the string using DestoryString().
+%
 %  The format of the CloneString method is:
 %
 %      char *CloneString(char **destination,const char *source)
@@ -671,6 +673,8 @@ MagickExport StringInfo *ConfigureFileToStringInfo(const char *filename)
 %  to that memory location (and returns it).  Use it for strings that you do
 %  do not expect to change over its lifetime.
 %
+%  When finished free the string using DestoryString().
+%
 %  The format of the ConstantString method is:
 %
 %      char *ConstantString(const char *source)
@@ -714,10 +718,12 @@ MagickExport char *ConstantString(const char *source)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  CopyMagickString() copies the source string to the destination string.  The
-%  destination buffer is always null-terminated even if the string must be
-%  truncated.  The return value is the minimum of the source string length
-%  or the length parameter.
+%  CopyMagickString() copies the source string to the destination string, with
+%  out exceeding the given pre-declared length.
+%
+%  The destination buffer is always null-terminated even if the string must be
+%  truncated.  The return value is the minimum of the source string length or
+%  the length parameter.
 %
 %  The format of the CopyMagickString method is:
 %
@@ -1594,16 +1600,18 @@ MagickExport void LocaleLower(char *string)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  LocaleNCompare() performs a case-insensitive comparison of two
-%  strings byte-by-byte, according to the ordering of the current locale
-%  encoding. LocaleNCompare returns an integer greater than, equal to, or
-%  less than 0, if the string pointed to by p is greater than, equal to, or
-%  less than the string pointed to by q respectively.  The sign of a non-zero
-%  return value is determined by the sign of the difference between the
-%  values of the first pair of bytes that differ in the strings being
-%  compared.  The LocaleNCompare method makes the same comparison as
-%  LocaleCompare but looks at a maximum of n bytes.  Bytes following a
-%  null byte are not compared.
+%  LocaleNCompare() performs a case-insensitive comparison of two strings
+%  byte-by-byte, according to the ordering of the current locale encoding.
+%
+%  LocaleNCompare returns an integer greater than, equal to, or less than 0,
+%  if the string pointed to by p is greater than, equal to, or less than the
+%  string pointed to by q respectively.  The sign of a non-zero return value
+%  is determined by the sign of the difference between the values of the first
+%  pair of bytes that differ in the strings being compared.
+%
+%  The LocaleNCompare method makes the same comparison as LocaleCompare but
+%  looks at a maximum of n bytes.  Bytes following a null byte are not
+%  compared.
 %
 %  The format of the LocaleNCompare method is:
 %
index 63ba98bc8f3c16eb055d8a339003a4bb2da3e014..95e08ab183dc8acda567a963e636c0166ea5d415 100644 (file)
@@ -775,18 +775,18 @@ WandExport MagickBooleanType MagickImageCommand(ImageInfo *image_info,
     goto Magick_Command_Exit;
   }
 
-  /* List Information and Abort */
-  if (LocaleCompare("-list",argv[1]) == 0) {
-    CLIOption(cli_wand, argv[1], argv[2]);
-    goto Magick_Command_Exit;
-  }
-
   /* Special "concatenate option (hidden) for delegate usage */
   if (LocaleCompare("-concatenate",argv[1]) == 0) {
     ConcatenateImages(argc,argv,exception);
     goto Magick_Command_Exit;
   }
 
+  /* List Information and Abort */
+  if (argc == 3 && LocaleCompare("-list",argv[1]) == 0) {
+    CLIOption(cli_wand, argv[1], argv[2]);
+    goto Magick_Command_Exit;
+  }
+
   /* ------------- */
   /* The Main Call */