Post by bbcentral » 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:

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 :)

OpenCart enthusiast
PHP/MySQL/jQuery Developer


User avatar
Newbie

Posts

Joined
Wed Dec 07, 2011 9:26 am

Post by next-gen » Wed Dec 07, 2011 4:36 pm

Thank you for sharing, this will solve one of a small problems with OC;)

User avatar
Newbie

Posts

Joined
Wed Nov 09, 2011 12:53 pm

Post by aaron1988 » Sat May 12, 2012 9:37 pm

Cheers for that, it has fixed an issue with my clients site :)

Aaron

Active Member

Posts

Joined
Thu Jan 27, 2011 10:03 am

Post by Daniel » Sat May 12, 2012 11:37 pm

added it to the next release.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by aaron1988 » Sun May 13, 2012 12:15 am

Cool daniel :)

Active Member

Posts

Joined
Thu Jan 27, 2011 10:03 am

Post by aurevilly » Wed Oct 10, 2012 12:50 am

Thanks. Currently running an older version and needed this quick fix!

Cheers.

User avatar
New member

Posts

Joined
Thu Sep 29, 2011 4:32 am
Location - Sherbrooke, Canada

Post by hobbymc.com » Sun Oct 14, 2012 4:40 am

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.

Newbie

Posts

Joined
Sat Sep 22, 2012 2:18 pm
Who is online

Users browsing this forum: No registered users and 20 guests