Version 1 - Replace in modules/gd/classes/GdToolkit.class:
case 'thumbnail':
case 'scale':
/* $parameters[0]: target width, [1]: optional target height */
$targetHeight = empty($parameters[1]) ? $parameters[0] : $parameters[1];
/* Don't enlarge images for a thumbnail */
if ($operationName == 'thumbnail'
&& $width <= $parameters[0] && $height <= $targetHeight) {
break;
}
with:
case 'thumbnail':
$aspect = $height / $width;
$targetWidth = $parameters[0];
$height = round($targetWidth * $aspect);
$width = $parameters[0];
list ($ret, $destRes) = $this->_resizeImageResource(
$sourceRes, $width, $height, $hasTransparency);
$this->_free($sourceRes);
break;
case 'scale':
/* $parameters[0]: target width, [1]: optional target height */
$targetHeight = empty($parameters[1]) ? $parameters[0] : $parameters[1];
Version 2 - replace in modules/gd/classes/GdToolkit.class:
case 'thumbnail':
case 'scale':
/* $parameters[0]: target width, [1]: optional target height */
$targetHeight = empty($parameters[1]) ? $parameters[0] : $parameters[1];
/* Don't enlarge images for a thumbnail */
if ($operationName == 'thumbnail'
&& $width <= $parameters[0] && $height <= $targetHeight) {
break;
}
with:
case 'thumbnail':
list ($width, $height) = GalleryUtilities::scaleThumbnailToFit(
$width, $height, $parameters[0]);
list ($ret, $destRes) = $this->_resizeImageResource(
$sourceRes, $width, $height, $hasTransparency);
$this->_free($sourceRes);
break;
case 'scale':
/* $parameters[0]: target width, [1]: optional target height */
$targetHeight = empty($parameters[1]) ? $parameters[0] : $parameters[1];
and add to modules/core/classes/GalleryUtilities.class:
function scaleThumbnailToFit($width, $height, $targetWidth, $targetHeight=null) {
$aspect = $height / $width;
$width = $targetWidth;
$height = round($targetWidth * $aspect);
return array($width, $height);
}