Contrary to imagecache's helper text under Add New Action:Scale:

Scale: Resize an image maintaining the original aspect-ratio (only one value necessary).

resize fails when only the width dimension is entered. It works when only Height is specified but fails for Height="". I am using gd.

This is because the value of $height=0 eventually gets passed into function image_scale in includes/image.inc:124-132

  $aspect = $info['height'] / $info['width'];
  if ($aspect < $height / $width) {
    $width = (int)min($width, $info['width']);
    $height = (int)round($width * $aspect);
  }
  else {
    $height = (int)min($height, $info['height']);
    $width = (int)round($height / $aspect);
  }

$height = (int)min($height, $info['height']);, $height will equal 0. This doesn't work for the resize function called next.

I think either both dimensions need to be required, or a default should be stated (and enforced) that "if only one dimension is entered, it will be used for both width and height" or something. Either way, another watchdog should be added to detect this and let the implementor know why his images aren't rescaling.

Comments

dopry’s picture

Status: Active » Fixed

It been modified so if you use a single value for scale the other value will be set impossible large... So you should in effect be able to scale on one dimension now.

Anonymous’s picture

Status: Fixed » Closed (fixed)