]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/property.c
(no commit message)
[imagemagick] / MagickCore / property.c
index c2b82d3c10bf045ddc5af140d7928f0baa0f508f..fd947edc8704985a83c8e6832960657308a8af49 100644 (file)
@@ -17,7 +17,7 @@
 %                                 March 2000                                  %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -138,14 +138,12 @@ MagickExport MagickBooleanType CloneImageProperties(Image *image,
   image->directory=(char *) NULL;
   (void) CloneString(&image->geometry,clone_image->geometry);
   image->offset=clone_image->offset;
-  image->x_resolution=clone_image->x_resolution;
-  image->y_resolution=clone_image->y_resolution;
+  image->resolution.x=clone_image->resolution.x;
+  image->resolution.y=clone_image->resolution.y;
   image->page=clone_image->page;
   image->tile_offset=clone_image->tile_offset;
   image->extract_info=clone_image->extract_info;
-  image->bias=clone_image->bias;
   image->filter=clone_image->filter;
-  image->blur=clone_image->blur;
   image->fuzz=clone_image->fuzz;
   image->interlace=clone_image->interlace;
   image->interpolate=clone_image->interpolate;
@@ -192,7 +190,7 @@ MagickExport MagickBooleanType CloneImageProperties(Image *image,
 %  The format of the DefineImageProperty method is:
 %
 %      MagickBooleanType DefineImageProperty(Image *image,
-%        const char *property)
+%        const char *property,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -200,9 +198,11 @@ MagickExport MagickBooleanType CloneImageProperties(Image *image,
 %
 %    o property: the image property.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickExport MagickBooleanType DefineImageProperty(Image *image,
-  const char *property)
+  const char *property,ExceptionInfo *exception)
 {
   char
     key[MaxTextExtent],
@@ -221,7 +221,7 @@ MagickExport MagickBooleanType DefineImageProperty(Image *image,
   if (*p == '=')
     (void) CopyMagickString(value,p+1,MaxTextExtent);
   *p='\0';
-  return(SetImageProperty(image,key,value));
+  return(SetImageProperty(image,key,value,exception));
 }
 \f
 /*
@@ -331,6 +331,12 @@ MagickExport MagickBooleanType FormatImageProperty(Image *image,
   char
     value[MaxTextExtent];
 
+  ExceptionInfo
+    *exception;
+
+  MagickBooleanType
+    status;
+
   ssize_t
     n;
 
@@ -341,7 +347,10 @@ MagickExport MagickBooleanType FormatImageProperty(Image *image,
   n=FormatLocaleStringList(value,MaxTextExtent,format,operands);
   (void) n;
   va_end(operands);
-  return(SetImageProperty(image,property,value));
+  exception=AcquireExceptionInfo();
+  status=SetImageProperty(image,property,value,exception);
+  exception=DestroyExceptionInfo(exception);
+  return(status);
 }
 \f
 /*
@@ -359,7 +368,8 @@ MagickExport MagickBooleanType FormatImageProperty(Image *image,
 %
 %  The format of the GetImageProperty method is:
 %
-%      const char *GetImageProperty(const Image *image,const char *key)
+%      const char *GetImageProperty(const Image *image,const char *key,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -367,6 +377,8 @@ MagickExport MagickBooleanType FormatImageProperty(Image *image,
 %
 %    o key: the key.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 
 static char
@@ -375,7 +387,8 @@ static char
   *TraceSVGClippath(const unsigned char *,size_t,const size_t,
     const size_t);
 
-static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
+static MagickBooleanType GetIPTCProperty(const Image *image,const char *key,
+  ExceptionInfo *exception)
 {
   char
     *attribute,
@@ -435,7 +448,8 @@ static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
       return(MagickFalse);
     }
   attribute[strlen(attribute)-1]='\0';
-  (void) SetImageProperty((Image *) image,key,(const char *) attribute);
+  (void) SetImageProperty((Image *) image,key,(const char *) attribute,
+    exception);
   attribute=DestroyString(attribute);
   return(MagickTrue);
 }
@@ -447,6 +461,13 @@ static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
   return(y);
 }
 
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
+{
+  if (x < y)
+    return(x);
+  return(y);
+}
+
 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
 {
   int
@@ -517,7 +538,8 @@ static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
   return((unsigned short) (value & 0xffff));
 }
 
-static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
+static MagickBooleanType Get8BIMProperty(const Image *image,const char *key,
+  ExceptionInfo *exception)
 {
   char
     *attribute,
@@ -581,7 +603,7 @@ static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
       continue;
     if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
       continue;
-    id=(ssize_t) ReadPropertyMSBShort(&info,&length);
+    id=(ssize_t) ((int) ReadPropertyMSBShort(&info,&length));
     if (id < (ssize_t) start)
       continue;
     if (id > (ssize_t) stop)
@@ -612,7 +634,7 @@ static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
             No name match, scroll forward and try next.
           */
           info+=count;
-          length-=count;
+          length-=MagickMin(count,(ssize_t) length);
           continue;
         }
     if ((*name == '#') && (sub_number != 1))
@@ -622,7 +644,7 @@ static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
         */
         sub_number--;
         info+=count;
-        length-=count;
+        length-=MagickMin(count,(ssize_t) length);
         continue;
       }
     /*
@@ -637,10 +659,10 @@ static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
         (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
         attribute[count]='\0';
         info+=count;
-        length-=count;
+        length-=MagickMin(count,(ssize_t) length);
         if ((id <= 1999) || (id >= 2999))
           (void) SetImageProperty((Image *) image,key,(const char *)
-            attribute);
+            attribute,exception);
         else
           {
             char
@@ -652,7 +674,8 @@ static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
             else
               path=TracePSClippath((unsigned char *) attribute,(size_t) count,
                 image->columns,image->rows);
-            (void) SetImageProperty((Image *) image,key,(const char *) path);
+            (void) SetImageProperty((Image *) image,key,(const char *) path,
+              exception);
             path=DestroyString(path);
           }
         attribute=DestroyString(attribute);
@@ -698,7 +721,7 @@ static inline size_t ReadPropertyLong(const EndianType endian,
 }
 
 static MagickBooleanType GetEXIFProperty(const Image *image,
-  const char *property)
+  const char *property,ExceptionInfo *exception)
 {
 #define MaxDirectoryStack  16
 #define EXIF_DELIMITER  "\n"
@@ -719,7 +742,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
 #define TAG_GPS_OFFSET  0x8825
 #define TAG_INTEROP_OFFSET  0xa005
 
-#define EXIFMultipleValues(size, format, arg) \
+#define EXIFMultipleValues(size,format,arg) \
 { \
    ssize_t \
      component; \
@@ -745,7 +768,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
    value=AcquireString(buffer); \
 }
 
-#define EXIFMultipleFractions(size, format, arg1, arg2) \
+#define EXIFMultipleFractions(size,format,arg1,arg2) \
 { \
    ssize_t \
      component; \
@@ -761,7 +784,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
    for (component=0; component < components; component++) \
    { \
      length+=FormatLocaleString(buffer+length,MaxTextExtent-length, \
-       format", ",arg1, arg2); \
+       format", ",(arg1),(arg2)); \
      if (length >= (MaxTextExtent-1)) \
        length=MaxTextExtent-1; \
      p1+=size; \
@@ -777,7 +800,9 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
       *directory;
 
     size_t
-      entry,
+      entry;
+
+    ssize_t
       offset;
   } DirectoryInfo;
 
@@ -1089,14 +1114,17 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
     entry,
     length,
     number_entries,
-    tag_offset,
     tag;
 
+  SplayTreeInfo
+    *exif_resources;
+
   ssize_t
     all,
     id,
     level,
     offset,
+    tag_offset,
     tag_value;
 
   static int
@@ -1212,7 +1240,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
   }
   if (length < 16)
     return(MagickFalse);
-  id=(ssize_t) ReadPropertyShort(LSBEndian,exif);
+  id=(ssize_t) ((int) ReadPropertyShort(LSBEndian,exif));
   endian=LSBEndian;
   if (id == 0x4949)
     endian=LSBEndian;
@@ -1227,7 +1255,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
     This the offset to the first IFD.
   */
   offset=(ssize_t) ((int) ReadPropertyLong(endian,exif+4));
-  if ((size_t) offset >= length)
+  if ((offset < 0) || (size_t) offset >= length)
     return(MagickFalse);
   /*
     Set the pointer to the first IFD and follow it were it leads.
@@ -1237,6 +1265,8 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
   level=0;
   entry=0;
   tag_offset=0;
+  exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL,
+    (void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
   do
   {
     /*
@@ -1252,7 +1282,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
     /*
       Determine how many entries there are in the current IFD.
     */
-    number_entries=ReadPropertyShort(endian,directory);
+    number_entries=(size_t) ((int) ReadPropertyShort(endian,directory));
     for ( ; entry < number_entries; entry++)
     {
       register unsigned char
@@ -1266,13 +1296,18 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
       ssize_t
         components;
 
-      q=(unsigned char *) (directory+2+(12*entry));
-      tag_value=(ssize_t) (ReadPropertyShort(endian,q)+tag_offset);
-      format=(size_t) ReadPropertyShort(endian,q+2);
+      q=(unsigned char *) (directory+(12*entry)+2);
+      if (GetValueFromSplayTree(exif_resources,q) == q)
+        break;
+      (void) AddValueToSplayTree(exif_resources,q,q);
+      tag_value=(ssize_t) ((int) ReadPropertyShort(endian,q)+tag_offset);
+      format=(size_t) ((int) ReadPropertyShort(endian,q+2));
       if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
         break;
       components=(ssize_t) ((int) ReadPropertyLong(endian,q+4));
       number_bytes=(size_t) components*tag_bytes[format];
+      if (number_bytes < components)
+        break;  /* prevent overflow */
       if (number_bytes <= 4)
         p=q+8;
       else
@@ -1286,6 +1321,8 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
           offset=(ssize_t) ((int) ReadPropertyLong(endian,q+8));
           if ((size_t) (offset+number_bytes) > length)
             continue;
+          if (~length < number_bytes)
+            continue;  /* prevent overflow */
           p=(unsigned char *) (exif+offset);
         }
       if ((all != 0) || (tag == (size_t) tag_value))
@@ -1294,6 +1331,8 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
             buffer[MaxTextExtent],
             *value;
 
+          value=(char *) NULL;
+          *buffer='\0';
           switch (format)
           {
             case EXIF_FMT_BYTE:
@@ -1320,27 +1359,27 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
             case EXIF_FMT_ULONG:
             {
               EXIFMultipleValues(4,"%.20g",(double)
-                ReadPropertyLong(endian,p1));
+                ((int) ReadPropertyLong(endian,p1)));
               break;
             }
             case EXIF_FMT_SLONG:
             {
               EXIFMultipleValues(4,"%.20g",(double)
-                ReadPropertyLong(endian,p1));
+                ((int) ReadPropertyLong(endian,p1)));
               break;
             }
             case EXIF_FMT_URATIONAL:
             {
               EXIFMultipleFractions(8,"%.20g/%.20g",(double)
-                ReadPropertyLong(endian,p1),(double)
-                ReadPropertyLong(endian,p1+4));
+                ((int) ReadPropertyLong(endian,p1)),(double)
+                ((int) ReadPropertyLong(endian,p1+4)));
               break;
             }
             case EXIF_FMT_SRATIONAL:
             {
               EXIFMultipleFractions(8,"%.20g/%.20g",(double)
-                ReadPropertyLong(endian,p1),(double)
-                ReadPropertyLong(endian,p1+4));
+                ((int) ReadPropertyLong(endian,p1)),(double)
+                ((int) ReadPropertyLong(endian,p1+4)));
               break;
             }
             case EXIF_FMT_SINGLE:
@@ -1406,8 +1445,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
                         break;
                       }
                   }
-                  (void) FormatLocaleString(key,MaxTextExtent,"%s",
-                    description);
+                  (void) FormatLocaleString(key,MaxTextExtent,"%s",description);
                   break;
                 }
                 case 2:
@@ -1429,25 +1467,25 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
                 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
                   image->properties,key);
               if (p == (const char *) NULL)
-                (void) SetImageProperty((Image *) image,key,value);
+                (void) SetImageProperty((Image *) image,key,value,exception);
               value=DestroyString(value);
               status=MagickTrue;
             }
         }
         if ((tag_value == TAG_EXIF_OFFSET) ||
-            (tag_value == TAG_INTEROP_OFFSET) ||
-            (tag_value == TAG_GPS_OFFSET))
+            (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
           {
-            size_t
+            ssize_t
               offset;
 
-            offset=(size_t) ReadPropertyLong(endian,p);
-            if ((offset < length) && (level < (MaxDirectoryStack-2)))
+            offset=(ssize_t) ((int) ReadPropertyLong(endian,p));
+            if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))
               {
-                size_t
+                ssize_t
                   tag_offset1;
 
-                tag_offset1=(tag_value == TAG_GPS_OFFSET) ? 0x10000UL : 0UL;
+                tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
+                  0);
                 directory_stack[level].directory=directory;
                 entry++;
                 directory_stack[level].entry=entry;
@@ -1459,9 +1497,9 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
                 level++;
                 if ((directory+2+(12*number_entries)) > (exif+length))
                   break;
-                offset=(size_t) ReadPropertyLong(endian,directory+2+(12*
-                  number_entries));
-                if ((offset != 0) && (offset < length) &&
+                offset=(ssize_t) ((int) ReadPropertyLong(endian,directory+2+(12*
+                  number_entries)));
+                if ((offset != 0) && ((size_t) offset < length) &&
                     (level < (MaxDirectoryStack-2)))
                   {
                     directory_stack[level].directory=exif+offset;
@@ -1474,6 +1512,7 @@ static MagickBooleanType GetEXIFProperty(const Image *image,
           }
     }
   } while (level > 0);
+  exif_resources=DestroySplayTree(exif_resources);
   return(status);
 }
 
@@ -1554,8 +1593,7 @@ static MagickBooleanType GetXMPProperty(const Image *image,const char *property)
 }
 
 static char *TracePSClippath(const unsigned char *blob,size_t length,
-  const size_t magick_unused(columns),
-  const size_t magick_unused(rows))
+  const size_t magick_unused(columns),const size_t magick_unused(rows))
 {
   char
     *path,
@@ -1614,7 +1652,7 @@ static char *TracePSClippath(const unsigned char *blob,size_t length,
   in_subpath=MagickFalse;
   while (length > 0)
   {
-    selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
+    selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
     switch (selector)
     {
       case 0:
@@ -1623,15 +1661,15 @@ static char *TracePSClippath(const unsigned char *blob,size_t length,
         if (knot_count != 0)
           {
             blob+=24;
-            length-=24;
+            length-=MagickMin(24,(ssize_t) length);
             break;
           }
         /*
           Expected subpath length record.
         */
-        knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
+        knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
         blob+=22;
-        length-=22;
+        length-=MagickMin(22,(ssize_t) length);
         break;
       }
       case 1:
@@ -1645,7 +1683,7 @@ static char *TracePSClippath(const unsigned char *blob,size_t length,
               Unexpected subpath knot
             */
             blob+=24;
-            length-=24;
+            length-=MagickMin(24,(ssize_t) length);
             break;
           }
         /*
@@ -1657,8 +1695,8 @@ static char *TracePSClippath(const unsigned char *blob,size_t length,
             xx,
             yy;
 
-          yy=ReadPropertyMSBLong(&blob,&length);
-          xx=ReadPropertyMSBLong(&blob,&length);
+          yy=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
+          xx=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
           x=(ssize_t) xx;
           if (xx > 2147483647)
             x=(ssize_t) xx-4294967295U-1;
@@ -1746,7 +1784,7 @@ static char *TracePSClippath(const unsigned char *blob,size_t length,
       default:
       {
         blob+=24;
-        length-=24;
+        length-=MagickMin(24,(ssize_t) length);
         break;
       }
     }
@@ -1811,7 +1849,7 @@ static char *TraceSVGClippath(const unsigned char *blob,size_t length,
   in_subpath=MagickFalse;
   while (length != 0)
   {
-    selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
+    selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
     switch (selector)
     {
       case 0:
@@ -1820,15 +1858,15 @@ static char *TraceSVGClippath(const unsigned char *blob,size_t length,
         if (knot_count != 0)
           {
             blob+=24;
-            length-=24;
+            length-=MagickMin(24,(ssize_t) length);
             break;
           }
         /*
           Expected subpath length record.
         */
-        knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
+        knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
         blob+=22;
-        length-=22;
+        length-=MagickMin(22,(ssize_t) length);
         break;
       }
       case 1:
@@ -1842,7 +1880,7 @@ static char *TraceSVGClippath(const unsigned char *blob,size_t length,
               Unexpected subpath knot.
             */
             blob+=24;
-            length-=24;
+            length-=MagickMin(24,(ssize_t) length);
             break;
           }
         /*
@@ -1854,8 +1892,8 @@ static char *TraceSVGClippath(const unsigned char *blob,size_t length,
             xx,
             yy;
 
-          yy=ReadPropertyMSBLong(&blob,&length);
-          xx=ReadPropertyMSBLong(&blob,&length);
+          yy=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
+          xx=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
           x=(ssize_t) xx;
           if (xx > 2147483647)
             x=(ssize_t) xx-4294967295U-1;
@@ -1917,7 +1955,7 @@ static char *TraceSVGClippath(const unsigned char *blob,size_t length,
       default:
       {
         blob+=24;
-        length-=24;
+        length-=MagickMin(24,(ssize_t) length);
         break;
       }
     }
@@ -1936,11 +1974,8 @@ static char *TraceSVGClippath(const unsigned char *blob,size_t length,
 }
 
 MagickExport const char *GetImageProperty(const Image *image,
-  const char *property)
+  const char *property,ExceptionInfo *exception)
 {
-  ExceptionInfo
-    *exception;
-
   FxInfo
     *fx_info;
 
@@ -1978,14 +2013,13 @@ MagickExport const char *GetImageProperty(const Image *image,
   if ((property == (const char *) NULL) ||
       (strchr(property,':') == (char *) NULL))
     return(p);
-  exception=(&((Image *) image)->exception);
   switch (*property)
   {
     case '8':
     {
       if (LocaleNCompare("8bim:",property,5) == 0)
         {
-          if ((Get8BIMProperty(image,property) != MagickFalse) &&
+          if ((Get8BIMProperty(image,property,exception) != MagickFalse) &&
               (image->properties != (void *) NULL))
             {
               p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
@@ -2000,7 +2034,7 @@ MagickExport const char *GetImageProperty(const Image *image,
     {
       if (LocaleNCompare("exif:",property,5) == 0)
         {
-          if ((GetEXIFProperty(image,property) != MagickFalse) &&
+          if ((GetEXIFProperty(image,property,exception) != MagickFalse) &&
               (image->properties != (void *) NULL))
             {
               p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
@@ -2026,7 +2060,7 @@ MagickExport const char *GetImageProperty(const Image *image,
 
               (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
                 GetMagickPrecision(),(double) alpha);
-              (void) SetImageProperty((Image *) image,property,value);
+              (void) SetImageProperty((Image *) image,property,value,exception);
             }
           if (image->properties != (void *) NULL)
             {
@@ -2042,7 +2076,7 @@ MagickExport const char *GetImageProperty(const Image *image,
     {
       if (LocaleNCompare("iptc:",property,5) == 0)
         {
-          if ((GetIPTCProperty(image,property) != MagickFalse) &&
+          if ((GetIPTCProperty(image,property,exception) != MagickFalse) &&
               (image->properties != (void *) NULL))
             {
               p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
@@ -2086,10 +2120,10 @@ MagickExport const char *GetImageProperty(const Image *image,
               char
                 name[MaxTextExtent];
 
-              (void) QueryMagickColorname(image,&pixel,SVGCompliance,name,
+              (void) QueryColorname(image,&pixel,SVGCompliance,name,
                 exception);
-              (void) SetImageProperty((Image *) image,property,name);
-              return(GetImageProperty(image,property));
+              (void) SetImageProperty((Image *) image,property,name,exception);
+              return(GetImageProperty(image,property,exception));
             }
         }
       break;
@@ -2131,7 +2165,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 *key)
+%        const char *key,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2141,9 +2175,11 @@ MagickExport const char *GetImageProperty(const Image *image,
 %
 %    o key: the key.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
-  Image *image,const char *property)
+  Image *image,const char *property,ExceptionInfo *exception)
 {
   char
     value[MaxTextExtent],
@@ -2186,7 +2222,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             Image storage class and colorspace.
           */
           colorspace=image->colorspace;
-          if (IsImageGray(image,&image->exception) != MagickFalse)
+          if (IsImageGray(image,exception) != MagickFalse)
             colorspace=GRAYColorspace;
           (void) FormatLocaleString(value,MaxTextExtent,"%s",
             CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
@@ -2263,7 +2299,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             kurtosis,
             skewness;
 
-          (void) GetImageKurtosis(image,&kurtosis,&skewness,&image->exception);
+          (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
           (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
             GetMagickPrecision(),kurtosis);
           break;
@@ -2283,7 +2319,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             maximum,
             minimum;
 
-          (void) GetImageRange(image,&minimum,&maximum,&image->exception);
+          (void) GetImageRange(image,&minimum,&maximum,exception);
           (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
             GetMagickPrecision(),maximum);
           break;
@@ -2295,7 +2331,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             standard_deviation;
 
           (void) GetImageMean(image,&mean,&standard_deviation,
-             &image->exception);
+             exception);
           (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
             GetMagickPrecision(),mean);
           break;
@@ -2306,7 +2342,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             maximum,
             minimum;
 
-          (void) GetImageRange(image,&minimum,&maximum,&image->exception);
+          (void) GetImageRange(image,&minimum,&maximum,exception);
           (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
             GetMagickPrecision(),minimum);
           break;
@@ -2329,11 +2365,18 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
           MagickBooleanType
             opaque;
 
-          opaque=IsImageOpaque(image,&image->exception);
+          opaque=IsImageOpaque(image,exception);
           (void) CopyMagickString(value,opaque == MagickFalse ? "false" :
             "true",MaxTextExtent);
           break;
         }
+      if (LocaleNCompare("orientation",property,11) == 0)
+        {
+          (void) FormatLocaleString(value,MaxTextExtent,"%s", 
+            CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t) 
+            image->orientation));
+          break;
+        }
       if (LocaleNCompare("output",property,6) == 0)
         {
           (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
@@ -2351,6 +2394,22 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
         }
       break;
     }
+    case 'r':
+    {
+      if (LocaleNCompare("resolution.x",property,11) == 0)
+        {
+          (void) FormatLocaleString(value,MaxTextExtent,"%g",
+            image->resolution.x);
+          break;
+        }
+      if (LocaleNCompare("resolution.y",property,11) == 0)
+        {
+          (void) FormatLocaleString(value,MaxTextExtent,"%g",
+            image->resolution.y);
+          break;
+        }
+      break;
+    }
     case 's':
     {
       if (LocaleNCompare("size",property,4) == 0)
@@ -2370,6 +2429,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
         }
       if (LocaleNCompare("scene",property,5) == 0)
         {
+          /* FUTURE: I am not certain this property return makes sense! */
           (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
             image->scene);
           if (image_info->number_scenes != 0)
@@ -2383,7 +2443,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             kurtosis,
             skewness;
 
-          (void) GetImageKurtosis(image,&kurtosis,&skewness,&image->exception);
+          (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
           (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
             GetMagickPrecision(),skewness);
           break;
@@ -2395,7 +2455,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
             standard_deviation;
 
           (void) GetImageMean(image,&mean,&standard_deviation,
-            &image->exception);
+            exception);
           (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
             GetMagickPrecision(),standard_deviation);
           break;
@@ -2432,26 +2492,6 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
         }
       break;
     }
-    case 'x':
-    {
-      if (LocaleNCompare("xresolution",property,11) == 0)
-        {
-          (void) FormatLocaleString(value,MaxTextExtent,"%g",
-            image->x_resolution);
-          break;
-        }
-      break;
-    }
-    case 'y':
-    {
-      if (LocaleNCompare("yresolution",property,11) == 0)
-        {
-          (void) FormatLocaleString(value,MaxTextExtent,"%g",
-            image->y_resolution);
-          break;
-        }
-      break;
-    }
     case 'z':
     {
       if (LocaleNCompare("zero",property,4) == 0)
@@ -2471,7 +2511,7 @@ MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
      (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
        ConstantString(property),ConstantString(value));
    }
-  return(GetImageProperty(image,property));
+  return(GetImageProperty(image,property,exception));
 }
 \f
 /*
@@ -2520,7 +2560,8 @@ MagickExport char *GetNextImageProperty(const Image *image)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  InterpretImageProperties() replaces any embedded formatting characters with
-%  the appropriate image property and returns the interpreted text.
+%  the appropriate image property and returns the interpreted text.  Free with
+%  DestoryString() or RelinquishMagickMemory().
 %
 %  The format of the InterpretImageProperties method is:
 %
@@ -2572,7 +2613,7 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
   text=(char *) embed_text;
   if ((*text == '@') && ((*(text+1) == '-') ||
       (IsPathAccessible(text+1) != MagickFalse)))
-    return(FileToString(embed_text+1,~0,&image->exception));
+    return(FileToString(embed_text+1,~0,exception));
   /*
     Translate any embedded format characters.
   */
@@ -2620,14 +2661,128 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
     p++;
     switch (*p)
     {
-      case 'b':
+      case '[':  /* multi-character substitution */
       {
         char
-          format[MaxTextExtent];
+          pattern[MaxTextExtent];
+
+        const char
+          *key,
+          *value;
+
+        ssize_t
+          depth;
 
         /*
-          File size.
+          Image value.
         */
+        if (strchr(p,']') == (char *) NULL)
+          break;
+        depth=1;
+        p++;
+        for (i=0; (i < (MaxTextExtent-1L)) && (*p != '\0'); i++)
+        {
+          if (*p == '[')
+            depth++;
+          if (*p == ']')
+            depth--;
+          if (depth <= 0)
+            break;
+          pattern[i]=(*p++);
+        }
+        pattern[i]='\0';
+        value=GetImageProperty(image,pattern,exception);
+        if (value != (const char *) NULL)
+          {
+            length=strlen(value);
+            if ((size_t) (q-interpret_text+length+1) >= extent)
+              {
+                extent+=length;
+                interpret_text=(char *) ResizeQuantumMemory(interpret_text,
+                  extent+MaxTextExtent,sizeof(*interpret_text));
+                if (interpret_text == (char *) NULL)
+                  break;
+                q=interpret_text+strlen(interpret_text);
+              }
+            (void) CopyMagickString(q,value,extent);
+            q+=length;
+            break;
+          }
+        else
+          if (IsGlob(pattern) != MagickFalse)
+            {
+              /*
+                Iterate over image properties.
+              */
+              ResetImagePropertyIterator(image);
+              key=GetNextImageProperty(image);
+              while (key != (const char *) NULL)
+              {
+                if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
+                  {
+                    value=GetImageProperty(image,key,exception);
+                    if (value != (const char *) NULL)
+                      {
+                        length=strlen(key)+strlen(value)+2;
+                        if ((size_t) (q-interpret_text+length+1) >= extent)
+                          {
+                            extent+=length;
+                            interpret_text=(char *) ResizeQuantumMemory(
+                              interpret_text,extent+MaxTextExtent,
+                              sizeof(*interpret_text));
+                            if (interpret_text == (char *) NULL)
+                              break;
+                            q=interpret_text+strlen(interpret_text);
+                          }
+                        q+=FormatLocaleString(q,extent,"%s=%s\n",key,value);
+                      }
+                  }
+                key=GetNextImageProperty(image);
+              }
+            }
+        value=GetMagickProperty(image_info,image,pattern,exception);
+        if (value != (const char *) NULL)
+          {
+            length=strlen(value);
+            if ((size_t) (q-interpret_text+length+1) >= extent)
+              {
+                extent+=length;
+                interpret_text=(char *) ResizeQuantumMemory(interpret_text,
+                  extent+MaxTextExtent,sizeof(*interpret_text));
+                if (interpret_text == (char *) NULL)
+                  break;
+                q=interpret_text+strlen(interpret_text);
+              }
+            (void) CopyMagickString(q,value,extent);
+            q+=length;
+            break;
+          }
+        if (image_info == (ImageInfo *) NULL)
+          break;
+        value=GetImageOption(image_info,pattern);
+        if (value != (char *) NULL)
+          {
+            length=strlen(value);
+            if ((size_t) (q-interpret_text+length+1) >= extent)
+              {
+                extent+=length;
+                interpret_text=(char *) ResizeQuantumMemory(interpret_text,
+                  extent+MaxTextExtent,sizeof(*interpret_text));
+                if (interpret_text == (char *) NULL)
+                  break;
+                q=interpret_text+strlen(interpret_text);
+              }
+            (void) CopyMagickString(q,value,extent);
+            q+=length;
+            break;
+          }
+        break;
+      }
+      case 'b':  /* image size as read in */
+      {
+        char
+          format[MaxTextExtent];
+
         (void) FormatLocaleString(format,MaxTextExtent,"%.20g",(double)
           ((MagickOffsetType) image->extent));
         if (image->extent != (MagickSizeType) ((size_t) image->extent))
@@ -2636,12 +2791,9 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
         q+=ConcatenateMagickString(q,"B",extent);
         break;
       }
-      case 'c':
+      case 'c':  /* image comment properity */
       {
-        /*
-          Image comment.
-        */
-        value=GetImageProperty(image,"comment");
+        value=GetImageProperty(image,"comment",exception);
         if (value == (const char *) NULL)
           break;
         length=strlen(value);
@@ -2658,99 +2810,57 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
         q+=length;
         break;
       }
-      case 'd':
-      case 'e':
-      case 'f':
-      case 't':
+      case 'd':  /* Directory component of filename */
       {
-        /*
-          Label segment is the base of the filename.
-        */
-        if (*image->magick_filename == '\0')
-          break;
-        switch (*p)
-        {
-          case 'd':
-          {
-            /*
-              Directory.
-            */
-            GetPathComponent(image->magick_filename,HeadPath,filename);
-            q+=CopyMagickString(q,filename,extent);
-            break;
-          }
-          case 'e':
-          {
-            /*
-              Filename extension.
-            */
-            GetPathComponent(image->magick_filename,ExtensionPath,filename);
-            q+=CopyMagickString(q,filename,extent);
-            break;
-          }
-          case 'f':
-          {
-            /*
-              Filename.
-            */
-            GetPathComponent(image->magick_filename,TailPath,filename);
-            q+=CopyMagickString(q,filename,extent);
-            break;
-          }
-          case 't':
-          {
-            /*
-              Base filename.
-            */
-            GetPathComponent(image->magick_filename,BasePath,filename);
-            q+=CopyMagickString(q,filename,extent);
-            break;
-          }
-        }
+        GetPathComponent(image->magick_filename,HeadPath,filename);
+        q+=CopyMagickString(q,filename,extent);
         break;
       }
-      case 'g':
+      case 'e': /* Filename extension (suffix) of image file */
+      {
+        GetPathComponent(image->magick_filename,ExtensionPath,filename);
+        q+=CopyMagickString(q,filename,extent);
+        break;
+      }
+      case 'f': /* Filename without directory component */
+      {
+        GetPathComponent(image->magick_filename,TailPath,filename);
+        q+=CopyMagickString(q,filename,extent);
+        break;
+      }
+      case 't': /* Base filename without directory or extention */
+      {
+        GetPathComponent(image->magick_filename,BasePath,filename);
+        q+=CopyMagickString(q,filename,extent);
+        break;
+      }
+      case 'g': /* Image geometry,  canvas and offset */
       {
-        /*
-          Image geometry.
-        */
         q+=FormatLocaleString(q,extent,"%.20gx%.20g%+.20g%+.20g",(double)
           image->page.width,(double) image->page.height,(double) image->page.x,
           (double) image->page.y);
         break;
       }
-      case 'h':
+      case 'h': /* Image height */
       {
-        /*
-          Image height.
-        */
         q+=FormatLocaleString(q,extent,"%.20g",(double) (image->rows != 0 ?
           image->rows : image->magick_rows));
         break;
       }
-      case 'i':
+      case 'i': /* Images filename - (output filename with "info:" ) */
       {
-        /*
-          Image filename.
-        */
         q+=CopyMagickString(q,image->filename,extent);
         break;
       }
-      case 'k':
+      case 'k': /* Number of unique colors  */
       {
-        /*
-          Number of unique colors.
-        */
         q+=FormatLocaleString(q,extent,"%.20g",(double) GetNumberColors(image,
-          (FILE *) NULL,&image->exception));
+          (FILE *) NULL,exception));
         break;
       }
-      case 'l':
+      case 'l': /* Image label  */
       {
-        /*
-          Image label.
-        */
-        value=GetImageProperty(image,"label");
+        value=GetImageProperty(image,"label",exception);
         if (value == (const char *) NULL)
           break;
         length=strlen(value);
@@ -2766,67 +2876,46 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
         q+=CopyMagickString(q,value,extent);
         break;
       }
-      case 'm':
+      case 'm': /* Image format (file magick) */
       {
-        /*
-          Image format.
-        */
         q+=CopyMagickString(q,image->magick,extent);
         break;
       }
-      case 'M':
+      case 'M': /* Magick filename - exactly as given incl. read mods */
       {
-        /*
-          Image magick filename.
-        */
         q+=CopyMagickString(q,image->magick_filename,extent);
         break;
       }
-      case 'n':
+      case 'n': /* Number of images in the list.  */
       {
-        /*
-          Number of images in the list.
-        */
         q+=FormatLocaleString(q,extent,"%.20g",(double)
           GetImageListLength(image));
         break;
       }
-      case 'o':
+      case 'o': /* Image output filename */
       {
-        /*
-          Image output filename.
-        */
         q+=CopyMagickString(q,image_info->filename,extent);
         break;
       }
-      case 'p':
+      case 'p': /* Image index in current image list  */
       {
-        /*
-          Image index in list.
-        */
         q+=FormatLocaleString(q,extent,"%.20g",(double)
-            GetImageIndexInList(image));
+          GetImageIndexInList(image));
         break;
       }
-      case 'q':
+      case 'q': /* Quantum depth of image in memory */
       {
-        /*
-          Image depth.
-        */
         q+=FormatLocaleString(q,extent,"%.20g",(double)
           MAGICKCORE_QUANTUM_DEPTH);
         break;
       }
-      case 'r':
+      case 'r': /* Image storage class and colorspace.  */
       {
         ColorspaceType
           colorspace;
 
-        /*
-          Image storage class and colorspace.
-        */
         colorspace=image->colorspace;
-        if (IsImageGray(image,&image->exception) != MagickFalse)
+        if (IsImageGray(image,exception) != MagickFalse)
           colorspace=GRAYColorspace;
         q+=FormatLocaleString(q,extent,"%s%s%s",CommandOptionToMnemonic(
           MagickClassOptions,(ssize_t) image->storage_class),
@@ -2834,123 +2923,93 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
           image->matte != MagickFalse ? "Matte" : "");
         break;
       }
-      case 's':
+      case 's': /* Image scene number  */
       {
-        /*
-          Image scene number.
-        */
         if (image_info->number_scenes == 0)
           q+=FormatLocaleString(q,extent,"%.20g",(double) image->scene);
         else
           q+=FormatLocaleString(q,extent,"%.20g",(double) image_info->scene);
         break;
       }
-      case 'u':
+      case 'u': /* Unique filename */
       {
-        /*
-          Unique filename.
-        */
         (void) CopyMagickString(filename,image_info->unique,extent);
         q+=CopyMagickString(q,filename,extent);
         break;
       }
-      case 'w':
+      case 'w': /* Image width  */
       {
-        /*
-          Image width.
-        */
         q+=FormatLocaleString(q,extent,"%.20g",(double) (image->columns != 0 ?
           image->columns : image->magick_columns));
         break;
       }
-      case 'x':
+      case 'x': /* Image horizontal resolution (density).  */
       {
-        /*
-          Image horizontal resolution.
-        */
-        q+=FormatLocaleString(q,extent,"%g %s",image->x_resolution,
+        q+=FormatLocaleString(q,extent,"%g %s",image->resolution.x,
           CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
             image->units));
         break;
       }
-      case 'y':
+      case 'y': /* Image vertical resolution (density)  */
       {
-        /*
-          Image vertical resolution.
-        */
-        q+=FormatLocaleString(q,extent,"%g %s",image->y_resolution,
+        q+=FormatLocaleString(q,extent,"%g %s",image->resolution.y,
           CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
           image->units));
         break;
       }
-      case 'z':
+      case 'z': /* Image depth as read in */
       {
-        /*
-          Image depth.
-        */
         q+=FormatLocaleString(q,extent,"%.20g",(double) image->depth);
         break;
       }
-      case 'A':
+      case 'A': /* Image alpha channel  */
       {
-        /*
-          Image alpha channel.
-        */
         q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
           MagickBooleanOptions,(ssize_t) image->matte));
         break;
       }
-      case 'C':
+      case 'C': /* Image compression method.  */
       {
-        /*
-          Image compression method.
-        */
         q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
           MagickCompressOptions,(ssize_t) image->compression));
         break;
       }
-      case 'D':
+      case 'D': /* Image dispose method.  */
       {
-        /*
-          Image dispose method.
-        */
         q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
           MagickDisposeOptions,(ssize_t) image->dispose));
         break;
       }
-      case 'G':
+      case 'G': /* Image size as geometry = "%wx%h" */
       {
         q+=FormatLocaleString(q,extent,"%.20gx%.20g",(double)
           image->magick_columns,(double) image->magick_rows);
         break;
       }
-      case 'H':
+      case 'H': /* layer canvas height */
       {
         q+=FormatLocaleString(q,extent,"%.20g",(double) image->page.height);
         break;
       }
-      case 'O':
+      case 'O': /* layer canvas offset with sign = "+%X+%Y" */
       {
         q+=FormatLocaleString(q,extent,"%+ld%+ld",(long) image->page.x,(long)
           image->page.y);
         break;
       }
-      case 'P':
+      case 'P': /* layer canvas page size = "%Wx%H" */
       {
         q+=FormatLocaleString(q,extent,"%.20gx%.20g",(double) image->page.width,
           (double) image->page.height);
         break;
       }
-      case 'Q':
+      case 'Q': /* image compression quality */
       {
         q+=FormatLocaleString(q,extent,"%.20g",(double) image->quality);
         break;
       }
-      case 'S':
+      case 'S': /* Image scenes  */
       {
-        /*
-          Image scenes.
-        */
         if (image_info->number_scenes == 0)
           q+=CopyMagickString(q,"2147483647",extent);
         else
@@ -2958,184 +3017,58 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
             image_info->number_scenes));
         break;
       }
-      case 'T':
+      case 'T': /* image time delay for animations */
       {
         q+=FormatLocaleString(q,extent,"%.20g",(double) image->delay);
         break;
       }
-      case 'W':
+      case 'W': /* layer canvas width */
       {
         q+=FormatLocaleString(q,extent,"%.20g",(double) image->page.width);
         break;
       }
-      case 'X':
+      case 'X': /* layer canvas X offset */
       {
         q+=FormatLocaleString(q,extent,"%+.20g",(double) image->page.x);
         break;
       }
-      case 'Y':
+      case 'Y': /* layer canvas Y offset */
       {
         q+=FormatLocaleString(q,extent,"%+.20g",(double) image->page.y);
         break;
       }
-      case 'Z':
+      case 'Z': /* Unique filename. */
       {
-        /*
-          Unique filename.
-        */
         (void) CopyMagickString(filename,image_info->zero,extent);
         q+=CopyMagickString(q,filename,extent);
         break;
       }
-      case '[':
-      {
-        char
-          pattern[MaxTextExtent];
-
-        const char
-          *key,
-          *value;
-
-        ssize_t
-          depth;
-
-        /*
-          Image value.
-        */
-        if (strchr(p,']') == (char *) NULL)
-          break;
-        depth=1;
-        p++;
-        for (i=0; (i < (MaxTextExtent-1L)) && (*p != '\0'); i++)
-        {
-          if (*p == '[')
-            depth++;
-          if (*p == ']')
-            depth--;
-          if (depth <= 0)
-            break;
-          pattern[i]=(*p++);
-        }
-        pattern[i]='\0';
-        value=GetImageProperty(image,pattern);
-        if (value != (const char *) NULL)
-          {
-            length=strlen(value);
-            if ((size_t) (q-interpret_text+length+1) >= extent)
-              {
-                extent+=length;
-                interpret_text=(char *) ResizeQuantumMemory(interpret_text,
-                  extent+MaxTextExtent,sizeof(*interpret_text));
-                if (interpret_text == (char *) NULL)
-                  break;
-                q=interpret_text+strlen(interpret_text);
-              }
-            (void) CopyMagickString(q,value,extent);
-            q+=length;
-            break;
-          }
-        else
-          if (IsGlob(pattern) != MagickFalse)
-            {
-              /*
-                Iterate over image properties.
-              */
-              ResetImagePropertyIterator(image);
-              key=GetNextImageProperty(image);
-              while (key != (const char *) NULL)
-              {
-                if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
-                  {
-                    value=GetImageProperty(image,key);
-                    if (value != (const char *) NULL)
-                      {
-                        length=strlen(key)+strlen(value)+2;
-                        if ((size_t) (q-interpret_text+length+1) >= extent)
-                          {
-                            extent+=length;
-                            interpret_text=(char *) ResizeQuantumMemory(
-                              interpret_text,extent+MaxTextExtent,
-                              sizeof(*interpret_text));
-                            if (interpret_text == (char *) NULL)
-                              break;
-                            q=interpret_text+strlen(interpret_text);
-                          }
-                        q+=FormatLocaleString(q,extent,"%s=%s\n",key,value);
-                      }
-                  }
-                key=GetNextImageProperty(image);
-              }
-            }
-        value=GetMagickProperty(image_info,image,pattern);
-        if (value != (const char *) NULL)
-          {
-            length=strlen(value);
-            if ((size_t) (q-interpret_text+length+1) >= extent)
-              {
-                extent+=length;
-                interpret_text=(char *) ResizeQuantumMemory(interpret_text,
-                  extent+MaxTextExtent,sizeof(*interpret_text));
-                if (interpret_text == (char *) NULL)
-                  break;
-                q=interpret_text+strlen(interpret_text);
-              }
-            (void) CopyMagickString(q,value,extent);
-            q+=length;
-            break;
-          }
-        if (image_info == (ImageInfo *) NULL)
-          break;
-        value=GetImageOption(image_info,pattern);
-        if (value != (char *) NULL)
-          {
-            length=strlen(value);
-            if ((size_t) (q-interpret_text+length+1) >= extent)
-              {
-                extent+=length;
-                interpret_text=(char *) ResizeQuantumMemory(interpret_text,
-                  extent+MaxTextExtent,sizeof(*interpret_text));
-                if (interpret_text == (char *) NULL)
-                  break;
-                q=interpret_text+strlen(interpret_text);
-              }
-            (void) CopyMagickString(q,value,extent);
-            q+=length;
-            break;
-          }
-        break;
-      }
-      case '@':
+      case '@': /* Image bounding box.  */
       {
         RectangleInfo
           page;
 
-        /*
-          Image bounding box.
-        */
         page=GetImageBoundingBox(image,exception);
         q+=FormatLocaleString(q,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
           (double) page.width,(double) page.height,(double) page.x,(double)
           page.y);
         break;
       }
-      case '#':
+      case '#': /* Image signature */
       {
-        /*
-          Image signature.
-        */
         (void) SignatureImage(image,exception);
-        value=GetImageProperty(image,"signature");
+        value=GetImageProperty(image,"signature",exception);
         if (value == (const char *) NULL)
           break;
         q+=CopyMagickString(q,value,extent);
         break;
       }
-      case '%':
+      case '%': /* percent escaped */
       {
         *q++=(*p);
         break;
       }
-      default:
+      default: /* percent not expanded */
       {
         *q++='%';
         *q++=(*p);
@@ -3246,7 +3179,7 @@ MagickExport void ResetImagePropertyIterator(const Image *image)
 %  The format of the SetImageProperty method is:
 %
 %      MagickBooleanType SetImageProperty(Image *image,const char *property,
-%        const char *value)
+%        const char *value,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -3256,13 +3189,12 @@ MagickExport void ResetImagePropertyIterator(const Image *image)
 %
 %    o values: the image property values.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickExport MagickBooleanType SetImageProperty(Image *image,
-  const char *property,const char *value)
+  const char *property,const char *value,ExceptionInfo *exception)
 {
-  ExceptionInfo
-    *exception;
-
   MagickBooleanType
     status;
 
@@ -3280,7 +3212,6 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
   if ((value == (const char *) NULL) || (*value == '\0'))
     return(DeleteImageProperty(image,property));
   status=MagickTrue;
-  exception=(&image->exception);
   switch (*property)
   {
     case 'B':
@@ -3288,12 +3219,8 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
     {
       if (LocaleCompare(property,"background") == 0)
         {
-          (void) QueryColorDatabase(value,&image->background_color,exception);
-          break;
-        }
-      if (LocaleCompare(property,"bias") == 0)
-        {
-          image->bias=SiPrefixToDouble(value,QuantumRange);
+          (void) QueryColorCompliance(value,AllCompliance,
+            &image->background_color,exception);
           break;
         }
       status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
@@ -3376,10 +3303,10 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
             geometry_info;
 
           flags=ParseGeometry(value,&geometry_info);
-          image->x_resolution=geometry_info.rho;
-          image->y_resolution=geometry_info.sigma;
+          image->resolution.x=geometry_info.rho;
+          image->resolution.y=geometry_info.sigma;
           if ((flags & SigmaValue) == 0)
-            image->y_resolution=image->x_resolution;
+            image->resolution.y=image->resolution.x;
         }
       if (LocaleCompare(property,"depth") == 0)
         {
@@ -3488,7 +3415,7 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
           (void) SetImageInfo(image_info,1,exception);
           profile=FileToStringInfo(image_info->filename,~0UL,exception);
           if (profile != (StringInfo *) NULL)
-            status=SetImageProfile(image,image_info->magick,profile);
+            status=SetImageProfile(image,image_info->magick,profile,exception);
           image_info=DestroyImageInfo(image_info);
           break;
         }