Current implementation of image_scale_and_crop does not round target width and height when calling image_gd_resize. This results in the same problem described in http://drupal.org/node/271303. The proposed implementation is a port of the patch described in http://drupal.org/node/271303 to Drupal 6
Old:
function image_scale_and_crop($source, $destination, $width, $height) {
$info = image_get_info($source);
$scale = max($width / $info['width'], $height / $info['height']);
$x = round(($info['width'] * $scale - $width) / 2);
$y = round(($info['height'] * $scale - $height) / 2);
if (image_toolkit_invoke('resize', array($source, $destination, $info['width'] * $scale, $info['height'] * $scale))) {
return image_toolkit_invoke('crop', array($destination, $destination, $x, $y, $width, $height));
}
return FALSE;
}
New:
function image_scale_and_crop($source, $destination, $width, $height) {
$info = image_get_info($source);
$scale = max($width / $info['width'], $height / $info['height']);
$x = round(($info['width'] * $scale - $width) / 2);
$y = round(($info['height'] * $scale - $height) / 2);
$scaled_w = round($info['width'] * $scale);
$scaled_h = round($info['height'] * $scale);
if (image_toolkit_invoke('resize', array($source, $destination, $scaled_w, $scaled_h ))) {
return image_toolkit_invoke('crop', array($destination, $destination, $x, $y, $width, $height));
}
return FALSE;
}
Patch file to be submitted when I have access to my development machine
Comments
Comment #1
martianunlimited commented