]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/property.c
(no commit message)
[imagemagick] / MagickCore / property.c
index fe9e6dc4b799f58ea013743373dfd25320a06f8c..507806d5d68cbcc2b0c2c30d95e258129f5320ca 100644 (file)
@@ -45,6 +45,8 @@
 #include "MagickCore/attribute.h"
 #include "MagickCore/cache.h"
 #include "MagickCore/color.h"
+#include "MagickCore/color-private.h"
+#include "MagickCore/colorspace-private.h"
 #include "MagickCore/compare.h"
 #include "MagickCore/constitute.h"
 #include "MagickCore/draw.h"
@@ -57,7 +59,6 @@
 #include "MagickCore/geometry.h"
 #include "MagickCore/histogram.h"
 #include "MagickCore/image.h"
-#include "MagickCore/image.h"
 #include "MagickCore/layer.h"
 #include "MagickCore/locale-private.h"
 #include "MagickCore/list.h"
@@ -94,7 +95,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  CloneImageProperties() clones one or more image properties.
+%  CloneImageProperties() clones all the image properties to another image.
 %
 %  The format of the CloneImageProperties method is:
 %
@@ -186,7 +187,9 @@ MagickExport MagickBooleanType CloneImageProperties(Image *image,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DefineImageProperty() associates a key/value pair with an image property.
+%  DefineImageProperty() associates an assignment string of the form
+%  "key=value" with per-image artifact. It is equivelent to
+%  SetImageProperity().
 %
 %  The format of the DefineImageProperty method is:
 %
@@ -273,8 +276,8 @@ MagickExport MagickBooleanType DeleteImageProperty(Image *image,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DestroyImageProperties() releases memory associated with image property
-%  values.
+%  DestroyImageProperties() destroys all properities and associated memory
+%  attached to the given image.
 %
 %  The format of the DestroyDefines method is:
 %
@@ -367,6 +370,9 @@ MagickExport MagickBooleanType FormatImageProperty(Image *image,
 %
 %  GetImageProperty() gets a value associated with an image property.
 %
+%  The returned string is a constant string in the tree and should NOT be
+%  freed by the caller.
+%
 %  The format of the GetImageProperty method is:
 %
 %      const char *GetImageProperty(const Image *image,const char *key,
@@ -615,7 +621,7 @@ static MagickBooleanType Get8BIMProperty(const Image *image,const char *key,
     if ((count != 0) && ((size_t) count <= length))
       {
         resource=(char *) NULL;
-        if (~(1UL*count) >= (MaxTextExtent-1))
+        if (~((size_t) count) >= (MaxTextExtent-1))
           resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
             sizeof(*resource));
         if (resource != (char *) NULL)
@@ -652,7 +658,7 @@ static MagickBooleanType Get8BIMProperty(const Image *image,const char *key,
       We have the resource of interest.
     */
     attribute=(char *) NULL;
-    if (~(1UL*count) >= (MaxTextExtent-1))
+    if (~((size_t) count) >= (MaxTextExtent-1))
       attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
         sizeof(*attribute));
     if (attribute != (char *) NULL)
@@ -1089,7 +1095,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
       { 0x1001c, "exif:GPSAreaInformation" },
       { 0x1001d, "exif:GPSDateStamp" },
       { 0x1001e, "exif:GPSDifferential" },
-      {  0x0000, NULL}
+      { 0x00000, (const char *) NULL }
     };
 
   const StringInfo
@@ -1397,7 +1403,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
             case EXIF_FMT_STRING:
             {
               value=(char *) NULL;
-              if (~(1UL*number_bytes) >= 1)
+              if (~((size_t) number_bytes) >= 1)
                 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
                   sizeof(*value));
               if (value != (char *) NULL)
@@ -1419,12 +1425,14 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
           if (value != (char *) NULL)
             {
               char
-                key[MaxTextExtent];
+                *key;
 
               register const char
                 *p;
 
-              (void) CopyMagickString(key,property,MaxTextExtent);
+              key=AcquireString(property);
+              if (level == 2)
+                (void) SubstituteString(&key,"exif:","exif:thumbnail:");
               switch (all)
               {
                 case 1:
@@ -1470,6 +1478,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
               if (p == (const char *) NULL)
                 (void) SetImageProperty((Image *) image,key,value,exception);
               value=DestroyString(value);
+              key=DestroyString(key);
               status=MagickTrue;
             }
         }
@@ -1980,7 +1989,7 @@ MagickExport const char *GetImageProperty(const Image *image,
   FxInfo
     *fx_info;
 
-  MagickRealType
+  double
     alpha;
 
   MagickStatusType
@@ -2003,7 +2012,7 @@ MagickExport const char *GetImageProperty(const Image *image,
             image->properties);
           return(p);
         }
-      if (LocaleNCompare("fx:",property,3) != 0) /* NOT fx: !!!! */
+      if (LocaleNCompare("fx:",property,3) != 0) /* NOT %[fx:..] !!!! */
         {
           p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
             image->properties,property);
@@ -2099,22 +2108,22 @@ MagickExport const char *GetImageProperty(const Image *image,
           fx_info=AcquireFxInfo(image,property+6,exception);
           status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
             &alpha,exception);
-          pixel.red=(MagickRealType) QuantumRange*alpha;
+          pixel.red=(double) QuantumRange*alpha;
           status|=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
             &alpha,exception);
-          pixel.green=(MagickRealType) QuantumRange*alpha;
+          pixel.green=(double) QuantumRange*alpha;
           status|=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
             &alpha,exception);
-          pixel.blue=(MagickRealType) QuantumRange*alpha;
+          pixel.blue=(double) QuantumRange*alpha;
           if (image->colorspace == CMYKColorspace)
             {
               status|=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
                 &alpha,exception);
-              pixel.black=(MagickRealType) QuantumRange*alpha;
+              pixel.black=(double) QuantumRange*alpha;
             }
           status|=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
             &alpha,exception);
-          pixel.alpha=(MagickRealType) QuantumRange*(1.0-alpha);
+          pixel.alpha=(double) QuantumRange*(1.0-alpha);
           fx_info=DestroyFxInfo(fx_info);
           if( IfMagickTrue(status) )
             {
@@ -2162,11 +2171,11 @@ MagickExport const char *GetImageProperty(const Image *image,
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  GetMagickProperty() gets attributes or calculated values that is associated
-%  with a fixed known property name, or single letter properity.
+%  with a fixed known property name, or single letter property.
 %
-%  This does not return, special profile or properity expressions. Nor does it
-%  return free-form properity strings, unless referenced by a single letter
-%  properity name.
+%  This does not return, special profile or property expressions. Nor does it
+%  return free-form property strings, unless referenced by a single letter
+%  property name.
 %
 %  The returned string is stored as the image artifact 'get-property' (not as
 %  another property), and as such should not be freed. Later calls however
@@ -2176,7 +2185,7 @@ MagickExport const char *GetImageProperty(const Image *image,
 %  The format of the GetMagickProperty method is:
 %
 %      const char *GetMagickProperty(const ImageInfo *image_info,Image *image,
-%        const char *properity,ExceptionInfo *exception)
+%        const char *property,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2199,14 +2208,11 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     *string;
 
   if (image != (Image *) NULL && IfMagickTrue(image->debug))
-      (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      image->filename);
-
-  *value='\0';          /* formated string */
-  string=(char *)NULL;  /* constant string reference */
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  *value='\0';  /* formatted string */
+  string=(char *) NULL;  /* constant string reference */
   switch (letter)
   {
-
     case 'b':  /* image size read in - in bytes */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
@@ -2219,7 +2225,7 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     case 'c':  /* image comment property - empty string by default */
     {
       string=GetImageProperty(image,"comment",exception);
-      if ( string == (const char *)NULL)
+      if (string == (const char *) NULL)
         string="";
       break;
     }
@@ -2241,14 +2247,14 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     case 'g': /* Image geometry, canvas and offset  %Wx%H+%X+%Y */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
-           (double) image->page.width,(double) image->page.height,
-           (double) image->page.x,(double) image->page.y);
+        (double) image->page.width,(double) image->page.height,
+        (double) image->page.x,(double) image->page.y);
       break;
     }
     case 'h': /* Image height (current) */
     {
-      (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
-           (double) (image->rows != 0 ? image->rows : image->magick_rows));
+      (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
+        (image->rows != 0 ? image->rows : image->magick_rows));
       break;
     }
     case 'i': /* Filename last used for image (read or write) */
@@ -2258,12 +2264,14 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     }
     case 'k': /* Number of unique colors  */
     {
-      /* FUTURE: ensure this does not generate the formated comment! */
+      /*
+        FUTURE: ensure this does not generate the formatted comment!
+      */
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-            GetNumberColors(image,(FILE *) NULL,exception));
+        GetNumberColors(image,(FILE *) NULL,exception));
       break;
     }
-    case 'l': /* Image label properity - empty string by default */
+    case 'l': /* Image label property - empty string by default */
     {
       string=GetImageProperty(image,"label",exception);
       if ( string == (const char *)NULL)
@@ -2278,7 +2286,7 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     case 'n': /* Number of images in the list.  */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-              GetImageListLength(image));
+        GetImageListLength(image));
       break;
     }
     case 'o': /* Output Filename - for delegate use only */
@@ -2289,7 +2297,7 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     case 'p': /* Image index in current image list -- As 'n' OBSOLETE */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-             GetImageIndexInList(image));
+        GetImageIndexInList(image));
       break;
     }
     case 'q': /* Quantum depth of image in memory */
@@ -2307,19 +2315,19 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
       if (IfMagickTrue(IsImageGray(image,exception)))
         colorspace=GRAYColorspace;
       (void) FormatLocaleString(value,MaxTextExtent,"%s %s %s",
-        CommandOptionToMnemonic(MagickClassOptions,(ssize_t)image->storage_class),
+        CommandOptionToMnemonic(MagickClassOptions,(ssize_t) image->storage_class),
         CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
-        IfMagickTrue(image->matte)?"Matte":"");
+        image->alpha_trait == BlendPixelTrait ? "Matte" : "");
       break;
     }
     case 's': /* Image scene number */
     {
       if (image_info->number_scenes != 0)
         (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-             image_info->scene);
+          image_info->scene);
       else
         (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-             image->scene);
+          image->scene);
       break;
     }
     case 't': /* Base filename without directory or extention */
@@ -2335,34 +2343,33 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     case 'w': /* Image width (current) */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-         (image->columns != 0 ? image->columns : image->magick_columns));
+        (image->columns != 0 ? image->columns : image->magick_columns));
       break;
     }
     case 'x': /* Image horizontal resolution (with units) */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%g %s",
-           image->resolution.x,CommandOptionToMnemonic(
-           MagickResolutionOptions,(ssize_t)image->units));
+        image->resolution.x,CommandOptionToMnemonic(
+        MagickResolutionOptions,(ssize_t)image->units));
       break;
     }
     case 'y': /* Image vertical resolution (with units) */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%g %s",
-           image->resolution.y,CommandOptionToMnemonic(
-           MagickResolutionOptions,(ssize_t)image->units));
+        image->resolution.y,CommandOptionToMnemonic(MagickResolutionOptions,
+        (ssize_t) image->units));
       break;
     }
     case 'z': /* Image depth as read in */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-           image->depth);
+        image->depth);
       break;
     }
     case 'A': /* Image alpha channel  */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%s",
-         CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
-           image->matte));
+        CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t) image->alpha_trait));
       break;
     }
     case 'C': /* Image compression method.  */
@@ -2375,20 +2382,19 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     case 'D': /* Image dispose method.  */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%s",
-        CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
-          image->dispose));
+        CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t) image->dispose));
       break;
     }
     case 'G': /* Image size as geometry = "%wx%h" */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20gx%.20g",
-           (double)image->magick_columns,(double) image->magick_rows);
+        (double)image->magick_columns,(double) image->magick_rows);
       break;
     }
     case 'H': /* layer canvas height */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-           image->page.height);
+        image->page.height);
       break;
     }
     case 'M': /* Magick filename - filename given incl. coder & read mods */
@@ -2398,20 +2404,20 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
     }
     case 'O': /* layer canvas offset with sign = "+%X+%Y" */
     {
-      (void) FormatLocaleString(value,MaxTextExtent,"%+ld%+ld",
-          (long) image->page.x,(long) image->page.y);
+      (void) FormatLocaleString(value,MaxTextExtent,"%+ld%+ld",(long)
+        image->page.x,(long) image->page.y);
       break;
     }
     case 'P': /* layer canvas page size = "%Wx%H" */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20gx%.20g",
-           (double) image->page.width,(double) image->page.height);
+        (double) image->page.width,(double) image->page.height);
       break;
     }
     case 'Q': /* image compression quality */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-          image->quality);
+        image->quality);
       break;
     }
     case 'S': /* Image scenes  ???? */
@@ -2420,31 +2426,31 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
         string="2147483647";
       else
         (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-            image_info->scene+image_info->number_scenes);
+          image_info->scene+image_info->number_scenes);
       break;
     }
     case 'T': /* image time delay for animations */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-          image->delay);
+        image->delay);
       break;
     }
     case 'W': /* layer canvas width */
     {
       (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-           image->page.width);
+        image->page.width);
       break;
     }
     case 'X': /* layer canvas X offset */
     {
-      (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-           image->page.x);
+      (void) FormatLocaleString(value,MaxTextExtent,"%+.20g",(double)
+        image->page.x);
       break;
     }
     case 'Y': /* layer canvas Y offset */
     {
-      (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-           image->page.y);
+      (void) FormatLocaleString(value,MaxTextExtent,"%+.20g",(double)
+        image->page.y);
       break;
     }
     case 'Z': /* Zero filename ??? */
@@ -2459,8 +2465,8 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
 
       page=GetImageBoundingBox(image,exception);
       (void) FormatLocaleString(value,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
-           (double) page.width,(double) page.height,
-           (double) page.x,(double) page.y);
+        (double) page.width,(double) page.height,(double) page.x,(double)
+        page.y);
       break;
     }
     case '#': /* Image signature */
@@ -2477,10 +2483,11 @@ static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
   }
   if (*value != '\0')
     string=value;
-  if (string != (char *)NULL) {
-    (void) SetImageArtifact(image, "get-properity", string);
-    return(GetImageArtifact(image, "get-properity"));
-  }
+  if (string != (char *) NULL)
+    {
+      (void) SetImageArtifact(image,"get-property",string);
+      return(GetImageArtifact(image,"get-property"));
+    }
   return((char *)NULL);
 }
 
@@ -2494,15 +2501,12 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
     *string;
 
   assert(property[0] != '\0');
-  if ( property[1] == '\0')  /* single letter properity request */
-    return( GetMagickPropertyLetter(image_info,image,*property,exception) );
-
-  if (image != (Image *) NULL && IfMagickTrue(image->debug))
-      (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      image->filename);
-
-  *value='\0';          /* formated string */
-  string=(char *)NULL;  /* constant string reference */
+  if (property[1] == '\0')  /* single letter property request */
+    return(GetMagickPropertyLetter(image_info,image,*property,exception));
+  if ((image != (Image *) NULL) && IfMagickTrue(image->debug))
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  *value='\0';  /* formated string */
+  string=(char *) NULL;  /* constant string reference */
   switch (*property)
   {
     case 'b':
@@ -2524,7 +2528,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
             image->colorspace));
           LocaleLower(value);
-          if( IfMagickTrue(image->matte) )
+          if( image->alpha_trait == BlendPixelTrait )
             (void) ConcatenateMagickString(value,"a",MaxTextExtent);
           break;
         }
@@ -2583,8 +2587,8 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
       if ( (image_info != (ImageInfo *) NULL) &&
            (LocaleCompare("group",property) == 0) )
         {
-          (void) FormatLocaleString(value,MaxTextExtent,"0x%lx",
-            (unsigned long) image_info->group);
+          (void) FormatLocaleString(value,MaxTextExtent,"0x%lx",(unsigned long)
+            image_info->group);
           break;
         }
       break;
@@ -2647,8 +2651,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             mean,
             standard_deviation;
 
-          (void) GetImageMean(image,&mean,&standard_deviation,
-             exception);
+          (void) GetImageMean(image,&mean,&standard_deviation,exception);
           (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
             GetMagickPrecision(),mean);
           break;
@@ -2674,8 +2677,8 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             opaque;
 
           opaque=IsImageOpaque(image,exception);
-          (void) CopyMagickString(value,IfMagickTrue(opaque)?"true":"false",
-               MaxTextExtent);
+          (void) CopyMagickString(value,IfMagickTrue(opaque) ? "true" : "false",
+            MaxTextExtent);
           break;
         }
       if (LocaleCompare("orientation",property) == 0)
@@ -2684,8 +2687,8 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             image->orientation);
           break;
         }
-      if ( (image_info != (ImageInfo *) NULL) &&
-           (LocaleCompare("output",property) == 0) )
+      if ((image_info != (ImageInfo *) NULL) &&
+          (LocaleCompare("output",property) == 0))
         {
           (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
           break;
@@ -2704,14 +2707,14 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
     }
     case 'r':
     {
-      /* FUTURE: Obsolete */
+      /* This matches %[fx:resolution.x] */
       if (LocaleCompare("resolution.x",property) == 0)
         {
           (void) FormatLocaleString(value,MaxTextExtent,"%g",
             image->resolution.x);
           break;
         }
-      /* FUTURE: Obsolete */
+      /* This matches %[fx:resolution.y] */
       if (LocaleCompare("resolution.y",property) == 0)
         {
           (void) FormatLocaleString(value,MaxTextExtent,"%g",
@@ -2724,13 +2727,13 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
     {
       if (LocaleCompare("scene",property) == 0)
         {
-          if ( (image_info != (ImageInfo *) NULL) &&
-               (image_info->number_scenes != 0) )
+          if ((image_info != (ImageInfo *) NULL) &&
+              (image_info->number_scenes != 0))
             (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-                image_info->scene);
+              image_info->scene);
           else
             (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
-                image->scene);
+              image->scene);
           break;
         }
       if (LocaleCompare("scenes",property) == 0)
@@ -2765,18 +2768,27 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             mean,
             standard_deviation;
 
-          (void) GetImageMean(image,&mean,&standard_deviation,
-            exception);
+          (void) GetImageMean(image,&mean,&standard_deviation,exception);
           (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
             GetMagickPrecision(),standard_deviation);
           break;
         }
        break;
     }
+    case 't':
+    {
+      if (LocaleCompare("type",property) == 0)
+        {
+          string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
+            GetImageType(image,exception));
+          break;
+        }
+       break;
+    }
     case 'u':
     {
-      if ( (image_info != (ImageInfo *) NULL) &&
-           (LocaleCompare("unique",property) == 0) )
+      if ((image_info != (ImageInfo *) NULL) &&
+          (LocaleCompare("unique",property) == 0))
         {
           string=image_info->unique;
           break;
@@ -2802,32 +2814,32 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
         }
       break;
     }
-    case 'x': /* ( X resolution, (with units) */
+    case 'x': /* FUTURE: Obsolete X resolution */
     {
       if ((LocaleCompare("xresolution",property) == 0) ||
           (LocaleCompare("x-resolution",property) == 0) )
         {
           (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
-               image->resolution.x);
+            image->resolution.x);
           break;
         }
       break;
     }
-    case 'y': /* ( Y resolution, (with units) */
+    case 'y': /* FUTURE: Obsolete Y resolution */
     {
       if ((LocaleCompare("yresolution",property) == 0) ||
           (LocaleCompare("y-resolution",property) == 0) )
         {
           (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
-               image->resolution.y);
+            image->resolution.y);
           break;
         }
       break;
     }
     case 'z':
     {
-      if ( (image_info != (ImageInfo *) NULL) &&
-           (LocaleCompare("zero",property) == 0) )
+      if ((image_info != (ImageInfo *) NULL) &&
+          (LocaleCompare("zero",property) == 0))
         {
           string=image_info->zero;
           break;
@@ -2837,10 +2849,11 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
   }
   if (*value != '\0')
     string=value;
-  if (string != (char *)NULL) {
-    (void) SetImageArtifact(image, "get-properity", string);
-    return(GetImageArtifact(image, "get-properity"));
-  }
+  if (string != (char *)NULL)
+    {
+      (void) SetImageArtifact(image,"get-property", string);
+      return(GetImageArtifact(image,"get-property"));
+    }
   return((char *)NULL);
 }
 \f
@@ -2855,7 +2868,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetNextImageProperty() gets the next free-form string properity name.
+%  GetNextImageProperty() gets the next free-form string property name.
 %
 %  The format of the GetNextImageProperty method is:
 %
@@ -2897,22 +2910,23 @@ MagickExport char *GetNextImageProperty(const Image *image)
 %     &lt; &gt; &amp;   replaced by '<', '>', '&' resp.
 %     %%                replaced by percent
 %
-%     %x            where 'x' is a single letter, case sensitive).
-%     %[type:name]  where 'type' is specifically known prefix.
+%     %x %[x]       where 'x' is a single letter properity, case sensitive).
+%     %[type:name]  where 'type' a is special and known prefix.
 %     %[name]       where 'name' is a specifically known attribute, calculated
-%                   value, or a per-image properity string name, or a per-image
-%                   'artifact' (as generated from a global option)
+%                   value, or a per-image property string name, or a per-image
+%                   'artifact' (as generated from a global option).
+%                   It may contain ':' as long as the prefix is not special.
 %
-%  Single letter % substitutions will only happen if the preceeding character
-%  is NOT a number. But braced substitutions will always be performed. This
-%  prevents typical usage of percent in 'geometry arguments' from being
-%  substituted unexpectedly.
+%  Single letter % substitutions will only happen if the character before the
+%  percent is NOT a number. But braced substitutions will always be performed.
+%  This prevents the typical usage of percent in a interpreted geometry
+%  argument from being substituted when the percent is a geometry flag.
 %
 %  If 'glob-expresions' ('*' or '?' characters) is used for 'name' it may be
 %  used as a search pattern to print multiple lines of "name=value\n" pairs of
 %  the associacted set of properities.
 %
-%  The returned string must be freed using DestoryString().
+%  The returned string must be freed using DestoryString() by the caller.
 %
 %  The format of the InterpretImageProperties method is:
 %
@@ -2955,10 +2969,13 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
   if( IfMagickTrue(image->debug) )
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
 
-  if ((embed_text == (const char *) NULL) || (*embed_text == '\0'))
+  if ((embed_text == (const char *) NULL))
     return((char *) NULL);
   p=embed_text;
 
+  if (*p == '\0')
+    return(ConstantString(""));
+
   /* handle a '@' replace string from file */
   if (*p == '@') {
      p++;
@@ -2989,7 +3006,7 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
         q=interpret_text+strlen(interpret_text);
       }
     /*
-      Look for percent escapes, (and handle other specials)
+      Look for the various escapes, (and handle other specials)
     */
     switch (*p) {
       case '\\':
@@ -3037,15 +3054,17 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
     p++; /* advance beyond the percent */
 
     /*
-      Doubled Percent
+      Doubled Percent - or percent at end of string
     */
+    if ( *p == '\0' )
+       p--;
     if ( *p == '%' ) {
-        *q++=(*p);
+        *q++='%';
         continue;
       }
 
     /*
-      Single letter escapes
+      Single letter escapes  %c
     */
     if ( *p != '[' ) {
       const char
@@ -3079,7 +3098,7 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
     }
 
     /*
-      Braced Percent Escape
+      Braced Percent Escape  %[...]
     */
     {
       char
@@ -3137,7 +3156,7 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
       /*
         Special Property Prefixes
         such as: %[exif:...] %[fx:...] %[pixel:...]
-        Otherwise a free-form properity string
+        Otherwise a free-form property string
       */
       value=GetImageProperty(image,pattern,exception);
       if (value != (const char *) NULL)
@@ -3157,7 +3176,7 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
           continue;
         }
       /*
-        Handle properity 'glob' patterns
+        Handle property 'glob' patterns
         Such as:  %[*]   %[user:array_??]  %[filename:e*]
       */
       if( IfMagickTrue(IsGlob(pattern)) )
@@ -3286,6 +3305,9 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
 %  RemoveImageProperty() removes a property from the image and returns its
 %  value.
 %
+%  In this case the ConstantString() value returned should be freed by the
+%  caller when finished.
+%
 %  The format of the RemoveImageProperty method is:
 %
 %      char *RemoveImageProperty(Image *image,const char *property)
@@ -3363,9 +3385,9 @@ MagickExport void ResetImagePropertyIterator(const Image *image)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  SetImageProperty() saves the given string value either to specific known
-%  attribute or to a freeform properity string.
+%  attribute or to a freeform property string.
 %
-%  Attempting to set a properity that is normally calculated will produce
+%  Attempting to set a property that is normally calculated will produce
 %  an exception.
 %
 %  The format of the SetImageProperty method is:
@@ -3403,7 +3425,7 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
     image->properties=NewSplayTree(CompareSplayTreeString,
       RelinquishMagickMemory,RelinquishMagickMemory);
 
-  /* Delete properity if NULL --  empty string values are valid! */
+  /* Delete property if NULL --  empty string values are valid! */
   if ((value == (const char *) NULL))
     return(DeleteImageProperty(image,property));
   status=MagickTrue;
@@ -3416,10 +3438,10 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
       return(MagickFalse);
     }
 
-  /* FUTURE: These should produce 'illegal settings'
-     + binary chars in p[roperty key
+  /* FUTURE: These should produce a 'illegal settings' error
+     + binary chars in property key
      + single letter property keys (read only)
-     + known special prefix (read only, they don't get saved!)
+     + known special prefixes (read only, they don't get saved!)
   */
 
   switch (*property)
@@ -3457,8 +3479,27 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
             value);
           if (colorspace < 0)
             break;
-          (void) SetImageColorspace(image,(ColorspaceType) colorspace,
-            exception);
+          image->colorspace=(ColorspaceType) colorspace;
+          image->rendering_intent=UndefinedIntent;
+          image->gamma=1.000f;
+          ResetMagickMemory(&image->chromaticity,0,sizeof(image->chromaticity));
+          if (IssRGBColorspace(image->colorspace) != MagickFalse)
+            {
+              image->rendering_intent=PerceptualIntent;
+              image->gamma=1.000f/2.200f;
+              image->chromaticity.red_primary.x=0.6400f;
+              image->chromaticity.red_primary.y=0.3300f;
+              image->chromaticity.red_primary.z=0.0300f;
+              image->chromaticity.green_primary.x=0.3000f;
+              image->chromaticity.green_primary.y=0.6000f;
+              image->chromaticity.green_primary.z=0.1000f;
+              image->chromaticity.blue_primary.x=0.1500f;
+              image->chromaticity.blue_primary.y=0.0600f;
+              image->chromaticity.blue_primary.z=0.7900f;
+              image->chromaticity.white_point.x=0.3127f;
+              image->chromaticity.white_point.y=0.3290f;
+              image->chromaticity.white_point.z=0.3583f;
+            }
           break;
         }
       if (LocaleCompare("compose",property) == 0)
@@ -3645,8 +3686,8 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
            (LocaleCompare("min",property) == 0) ||
            (LocaleCompare("min",property) == 0) )
         {
-          (void) ThrowMagickException(exception,GetMagickModule(),
-               OptionError,"SetReadOnlyProperty","'%s'",property);
+          (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+             "SetReadOnlyProperty","'%s'",property);
           status=MagickFalse;
           break;
         }