Page 1 of 1

PNG Banner Transparency

Posted: Wed Dec 07, 2011 9:37 am
by bbcentral
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:

Code: Select all

if ($scale == 1) {
	return;
}
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:

Code: Select all

if ($scale == 1 && $this->info['mime'] != 'image/png') {
	return;
}
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 :)

Re: PNG Banner Transparency

Posted: Wed Dec 07, 2011 4:36 pm
by next-gen
Thank you for sharing, this will solve one of a small problems with OC;)

Re: PNG Banner Transparency

Posted: Sat May 12, 2012 9:37 pm
by aaron1988
Cheers for that, it has fixed an issue with my clients site :)

Aaron

Re: PNG Banner Transparency

Posted: Sat May 12, 2012 11:37 pm
by Daniel
added it to the next release.

Re: PNG Banner Transparency

Posted: Sun May 13, 2012 12:15 am
by aaron1988
Cool daniel :)

Re: PNG Banner Transparency

Posted: Wed Oct 10, 2012 12:50 am
by aurevilly
Thanks. Currently running an older version and needed this quick fix!

Cheers.

Re: PNG Banner Transparency

Posted: Sun Oct 14, 2012 4:40 am
by hobbymc.com
I think that I may be having this same problem but don't quite understand how to fix it.

If you go to my site at : hobbymc.com you'll see that I've added the Right-Menu "Information" box and "Top 5" box. Well, the image/banner is too large and ends up hiding the right-side menu.

I've tried the following 2 fixes:

1) Shrink the image
2) Use a transparent image and shove all my stuff to the left

Both of them are currently loaded as the 2 banners but neither of them is fixing the problem. I've also tried looking for a way to adjust the dimension of the image in the admin section but that's not an option with the banner.

Any help would be appreciated.

Marc @ Hobby M.C.