diff --git a/core/includes/image.inc b/core/includes/image.inc
index 8dc36b9..88ea9ad 100644
--- a/core/includes/image.inc
+++ b/core/includes/image.inc
@@ -205,8 +205,14 @@ function image_dimensions_scale(array &$dimensions, $width = NULL, $height = NUL
 
   if ($upscale) {
     // Set width/height according to aspect ratio if either is empty.
-    $width = !empty($width) ? $width : $height / $aspect;
-    $height = !empty($height) ? $height : $width / $aspect;
+    if ($aspect < 1.0) {
+      $width = !empty($width) ? $width : $height / $aspect;
+      $height = !empty($height) ? $height : $width / $aspect;
+    }
+    else {
+      $width = !empty($width) ? $width : $height * $aspect;
+      $height = !empty($height) ? $height : $width * $aspect;
+    }
   }
   else {
     // Set impossibly large values if the width and height aren't set.
