From 49f91780bcdd2cfc2ab5cfd8523ff737f1709573 Mon Sep 17 00:00:00 2001
From: rick <rick@sprout.localdomain>
Date: Fri, 11 Mar 2011 14:18:02 -0500
Subject: [PATCH] Ensure image_resize gives integral dimensions >= 1

Resizing an image's height or width to zero or to a fraction of a
pixel makes no sense.  Fixes [#979382].
---
 includes/image.inc |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/includes/image.inc b/includes/image.inc
index b04943b..c51b28c 100644
--- a/includes/image.inc
+++ b/includes/image.inc
@@ -226,6 +226,12 @@ function image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale =
     $width = $height / $aspect;
   }
 
+  // final dimensions should always be integers and at least 1
+  $height = floor($height);
+  $height = $height < 1 ? 1 : $height ;
+  $width = floor($width);
+  $width = $width < 1 ? 1 : $width ;
+
   return image_resize($image, $width, $height);
 }
 
-- 
1.7.2.3

