]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/geometry.c
(no commit message)
[imagemagick] / MagickCore / geometry.c
index 2484311d2b57d36a5984f5c63e12ac62dce0dd2a..dccce5cccfc79c152ec610e4c4b60ed08e652913 100644 (file)
@@ -286,18 +286,15 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
             *y=(-*y);
         }
     }
-  if ((flags & SeparatorValue) == 0)
+  if ((flags & PercentValue) != 0)
     {
-      if (((flags & PercentValue) != 0) && ((flags & WidthValue) == 0))
-        {
-          *width=(*height);
-          flags|=WidthValue;
-        }
-      if (((flags & PercentValue) != 0) && ((flags & HeightValue) == 0))
+      if (((flags & SeparatorValue) == 0) && ((flags & HeightValue) == 0))
         {
           *height=(*width);
           flags|=HeightValue;
         }
+      if (((flags & SeparatorValue) != 0) && ((flags & WidthValue) == 0))
+        *width=(*height);
     }
 #if 0
   /* Debugging Geometry */
@@ -1072,18 +1069,12 @@ MagickExport MagickStatusType ParseGeometry(const char *geometry,
       flags|=SigmaValue;
       flags&=(~XiValue);
     }
-  if ((flags & SeparatorValue) == 0)
+  if ((flags & PercentValue) != 0)
     {
-      if (((flags & PercentValue) != 0) && ((flags & RhoValue) == 0))
-        {
-          geometry_info->rho=geometry_info->sigma;
-          flags|=RhoValue;
-        }
-      if (((flags & PercentValue) != 0) && ((flags & SigmaValue) == 0))
-        {
-          geometry_info->sigma=geometry_info->rho;
-          flags|=SigmaValue;
-        }
+      if (((flags & SeparatorValue) == 0) && ((flags & SigmaValue) == 0))
+        geometry_info->sigma=geometry_info->rho;
+      if (((flags & SeparatorValue) != 0) && ((flags & RhoValue) == 0))
+        geometry_info->rho=geometry_info->sigma;
     }
 #if 0
   /* Debugging Geometry */
@@ -1300,11 +1291,7 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
       if ((flags & SigmaValue) == 0)
         scale.y=scale.x;
       *width=(size_t) floor(scale.x*former_width/100.0+0.5);
-      if (*width == 0)
-        *width=1;
       *height=(size_t) floor(scale.y*former_height/100.0+0.5);
-      if (*height == 0)
-        *height=1;
       former_width=(*width);
       former_height=(*height);
     }
@@ -1457,6 +1444,14 @@ MagickExport MagickStatusType ParsePageGeometry(const Image *image,
     }
   flags=ParseMetaGeometry(geometry,&region_info->x,&region_info->y,
     &region_info->width,&region_info->height);
+  if ((((flags & WidthValue) != 0) || ((flags & HeightValue) != 0)) &&
+      (((flags & PercentValue) != 0) || ((flags & SeparatorValue) == 0)))
+    {
+      if ((flags & WidthValue) == 0)
+        region_info->width=region_info->height;
+      if ((flags & HeightValue) == 0)
+        region_info->height=region_info->width;
+    }
   return(flags);
 }
 \f