PNG Banner Transparency
Posted: Wed Dec 07, 2011 9:37 am
We're using the banner module to have large PNG banners on our Opencart homepage (OpenCart 1.5.1.3).
The banners are transparent PNGs with rounded edges, but Opencart is losing the transparency before saving them to the cache folder.
It works perfectly if the banners are resized/shrunk (the 100x100 thumbnail has transparency), but it doesn't work when they're displayed in their original dimensions. We've tracked it down to line 64 of system/library/image.php, inside the resize() function:
Because it's the original dimensions, it's skipping over the next part of the function which saves the PNG to the cache folder with the transparency intact.
We solved it for our site like this:
This is only a quick fix though. It makes no sense for the save() function to output the image using imagepng() when the output image has the same dimensions as the original. Ideally it should detect that the dimensions aren't being changed, and it should simply copy the source image into the destination cache folder (rather than putting unnecessary load on the GD library, however miniscule the amount is).
Hope to see this pushed through to the next release so I don't have to hack or vQmod all our stores
The banners are transparent PNGs with rounded edges, but Opencart is losing the transparency before saving them to the cache folder.
It works perfectly if the banners are resized/shrunk (the 100x100 thumbnail has transparency), but it doesn't work when they're displayed in their original dimensions. We've tracked it down to line 64 of system/library/image.php, inside the resize() function:
Code: Select all
if ($scale == 1) {
return;
}
We solved it for our site like this:
Code: Select all
if ($scale == 1 && $this->info['mime'] != 'image/png') {
return;
}
Hope to see this pushed through to the next release so I don't have to hack or vQmod all our stores
