]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Sat, 15 Apr 2017 22:27:42 +0000 (18:27 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 15 Apr 2017 22:27:42 +0000 (18:27 -0400)
coders/svg.c

index 4cf44a8cae899a6459689b7940705c744b0f3247..14a919919eef2368ce2b6c8d4326de2eadbf8187 100644 (file)
@@ -2973,7 +2973,8 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (svg_handle == (RsvgHandle *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         rsvg_handle_set_base_uri(svg_handle,image_info->filename);
-        if ((image->resolution.x > 0.0) && (image->resolution.y > 0.0))
+        if ((fabs(image->resolution.x) > MagickEpsilon) &&
+            (fabs(image->resolution.y) > MagickEpsilon))
           rsvg_handle_set_dpi_x_y(svg_handle,image->resolution.x,
             image->resolution.y);
         while ((n=ReadBlob(image,MagickPathExtent-1,message)) != 0)
@@ -2992,23 +2993,23 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
         apply_density=MagickTrue;
         rsvg_handle_get_dimensions(svg_handle,&dimension_info);
         if ((image->resolution.x > 0.0) && (image->resolution.y > 0.0))
-        {
-          RsvgDimensionData
-            dpi_dimension_info;
-
-          /*
-            We should not apply the density when the internal 'factor' is 'i'.
-            This can be checked by using the trick below.
-          */
-          rsvg_handle_set_dpi_x_y(svg_handle,image->resolution.x*256,
-            image->resolution.y*256);
-          rsvg_handle_get_dimensions(svg_handle,&dpi_dimension_info);
-          if ((dpi_dimension_info.width != dimension_info.width) ||
-              (dpi_dimension_info.height != dimension_info.height))
-            apply_density=MagickFalse;
-          rsvg_handle_set_dpi_x_y(svg_handle,image->resolution.x,
-            image->resolution.y);
-        }
+          {
+            RsvgDimensionData
+              dpi_dimension_info;
+
+            /*
+              We should not apply the density when the internal 'factor' is 'i'.
+              This can be checked by using the trick below.
+            */
+            rsvg_handle_set_dpi_x_y(svg_handle,image->resolution.x*256,
+              image->resolution.y*256);
+            rsvg_handle_get_dimensions(svg_handle,&dpi_dimension_info);
+            if ((dpi_dimension_info.width != dimension_info.width) ||
+                (dpi_dimension_info.height != dimension_info.height))
+              apply_density=MagickFalse;
+              rsvg_handle_set_dpi_x_y(svg_handle,image->resolution.x,
+                image->resolution.y);
+          }
         if (image_info->size != (char *) NULL)
           {
             (void) GetGeometry(image_info->size,(ssize_t *) NULL,
@@ -3017,13 +3018,14 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
               {
                 image->resolution.x=90.0*image->columns/dimension_info.width;
                 image->resolution.y=90.0*image->rows/dimension_info.height;
-                if (image->resolution.x == 0)
+                if (fabs(image->resolution.x) < MagickEpsilon)
                   image->resolution.x=image->resolution.y;
-                else if (image->resolution.y == 0)
-                  image->resolution.y=image->resolution.x;
                 else
-                  image->resolution.x=image->resolution.y=MagickMin(
-                    image->resolution.x,image->resolution.y);
+                  if (fabs(image->resolution.y) < MagickEpsilon)
+                    image->resolution.y=image->resolution.x;
+                  else
+                    image->resolution.x=image->resolution.y=MagickMin(
+                      image->resolution.x,image->resolution.y);
                 apply_density=MagickTrue;
               }
           }