I’m using the resize function in OpenCart , but it’s resizing the image whit white spaces in it’s top and bottom. I’m not sure, but it looks like, that the resize function is watching only the width, and then mesuring the height.
if (!empty($product_info) && $product_info['image'] && file_exists(DIR_IMAGE . $product_info['image'])) {
$this->data['thumb'] = $this->model_tool_image->resize($product_info['image'], 100, 100);
} else {
$this->data['thumb'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);
}
This is the code i’m using, nothing much . The width of the image is how I’m setting it, in my case 100px. The width is being setted 100px – to, but it’s showing like 20px on top and 20px on bottom , white space.
What is the original image size ratio (ratio of width to height)? If it is 1 (let’s say original image is 500px wide and high), then there should be no white space. If the ratio is bigger then 1, then the width is bigger than height (let’s say 700px*500px) and after resizing the image is filled with white spaces in the top and bottom of the image. Of course if the ratio is less than 1 then the width is smaller than height (let’s say 500px*700px) and You will see the white spaces on the left and right of the image. I have no OpenCart sources here at work but search for crop parameter (or crop ability) when resizing – if it is present then use it – it will preserve the resulting image to have no white space and resizing the smaller dimension to your setting while the bigger one is cropped…