--- Image_original.php	2007-03-03 03:27:22.000000000 +0100
+++ Image.php	2007-11-29 16:19:29.076995200 +0100
@@ -123,31 +123,38 @@
         }
 
         // stephane@metacites.net -- 25/07/2004
-        // try to guess width and height
-        if (! isset($options['attr']['width']) &&
-            ! isset($options['attr']['height'])) {
-
-            // does the source refer to a local file or a URL?
-            if (strpos($src,'://')) {
-                // is a URL link
-                $imageFile = $src;
-            } elseif ($src[0] == '.') {
-            	// reg at dav-muz dot net -- 2005-03-07
-				// is a local file on relative path.
-				$imageFile = $src; # ...don't do anything because it's perfect!
-			} else {
-                // is a local file on absolute path.
-                $imageFile = $_SERVER['DOCUMENT_ROOT'] . $src;
+              
+        if (!isset($options['attr']['height'])) {
+              // does the source refer to a local file or a URL?
+              if (strpos($src,'://')) {
+                  // is a URL link
+                  $imageFile = $src;
+              } elseif ($src[0] == '.') {
+              	// reg at dav-muz dot net -- 2005-03-07
+  				// is a local file on relative path.
+  				$imageFile = $src; # ...don't do anything because it's perfect!
+  	      } else {
+                  // is a local file on absolute path.
+                  $imageFile = $_SERVER['DOCUMENT_ROOT'] . $src;
+              }
+              // attempt to get the image size
+              $imageSize = @getimagesize($imageFile);                   
+            if (isset($options['attr']['width'])) {
+            // try to guess only the height        
+                if (is_array($imageSize)) {
+                    $newImageWidth = $options['attr']['width'];
+                    $originalImageWidth = $imageSize[0];
+                    $originalImageHeight = $imageSize[1];
+                    // Calculate the new height from ratio of image file times the new width
+                    $options['attr']['height'] = ($originalImageHeight / $originalImageWidth) * $newImageWidth;
+                }           
+            } else {
+            // try to guess both width and height
+                if (is_array($imageSize)) {
+                    $options['attr']['width'] = $imageSize[0];
+                    $options['attr']['height'] = $imageSize[1];
+                }
             }
-
-            // attempt to get the image size
-            $imageSize = @getimagesize($imageFile);
-
-            if (is_array($imageSize)) {
-                $options['attr']['width'] = $imageSize[0];
-                $options['attr']['height'] = $imageSize[1];
-            }
-
         }
 
         // start the HTML output
