Prestashop has a setting that doen't make sense, at least for me, that is adding white spaces (or transparency) in images to complete the dimensions. Fortunately there is a simple way to solve it:
Here's a quick fix for this if anyone runs into this issue. Open ImageManager.php in the classes folder, go to line 265 and delete all of this:
then replace with
This stops prestacart adding white (or transparent) padding to your images, it makes the dimensions you enter into image backend work as CONSTRAINTS, not dimensions to add padding to. Not an edit that should have ever needed to be made..... It also works just fine with the classic theme, with the included CSS keeping everything aligned just fine. So it is still BEYOND me why the images are edited and padding added in the first place.
VERSION 1.7.6.5
Here's a quick fix for this if anyone runs into this issue. Open ImageManager.php in the classes folder, go to line 265 and delete all of this:
Code:
$destImage = imagecreatetruecolor($destinationWidth, $destinationHeight);
// If image is a PNG and the output is PNG, fill with transparency. Else fill with white background.
if ($fileType == 'png' && $type == IMAGETYPE_PNG) {
imagealphablending($destImage, false);
imagesavealpha($destImage, true);
$transparent = imagecolorallocatealpha($destImage, 255, 255, 255, 127);
imagefilledrectangle($destImage, 0, 0, $destinationWidth, $destinationHeight, $transparent);
} else {
$white = imagecolorallocate($destImage, 255, 255, 255);
imagefilledrectangle($destImage, 0, 0, $destinationWidth, $destinationHeight, $white);
}
$srcImage = ImageManager::create($type, $sourceFile);
if ($rotate) {
$srcImage = imagerotate($srcImage, $rotate, 0);
}
if ($destinationWidth >= $sourceWidth && $destinationHeight >= $sourceHeight) {
imagecopyresized($destImage, $srcImage, (int) (($destinationWidth - $nextWidth) / 2), (int) (($destinationHeight - $nextHeight) / 2), 0, 0, $nextWidth, $nextHeight, $sourceWidth, $sourceHeight);
} else {
ImageManager::imagecopyresampled($destImage, $srcImage, (int) (($destinationWidth - $nextWidth) / 2), (int) (($destinationHeight - $nextHeight) / 2), 0, 0, $nextWidth, $nextHeight, $sourceWidth, $sourceHeight, $quality);
}
Code:
$dest_w = round(($sourceWidth / $sourceHeight) * $targetHeight);
if ($dest_w > $targetWidth) {
$dest_w = $targetWidth;
$dest_h = round(($sourceHeight / $sourceWidth) * $targetHeight);
} else {
$dest_h = $targetHeight;
}
$destImage = imagecreatetruecolor($dest_w, $dest_h);
$srcImage = ImageManager::create($type, $sourceFile);
if ($rotate) {
$srcImage = imagerotate($srcImage, $rotate, 0);
}
imagecopyresampled($destImage, $srcImage, 0, 0, 0, 0, $dest_w, $dest_h, $sourceWidth, $sourceHeight);
VERSION 1.7.6.5