Community Forums

[MOD] Support Transparent Backgrounds (1.4.4 - 1.4.8b only)

Template support & advice for OpenCart v1.x

[MOD] Support Transparent Backgrounds (1.4.4 - 1.4.8b only)

Postby Qphoria » Fri Jul 09, 2010 3:10 pm

karinchan wrote:how to make the image product transparent?


Try this for transparent background ...

1. EDIT: /system/library/image.php

2. FIND:
Code: Select all
$background = imagecolorallocate($this->image, 255, 255, 255);


3. AFTER, ADD:
Code: Select all
if ($this->info['mime'] != 'image/jpg') {
         imagecolortransparent($this->image, $background);
      }


4. EDIT: catalog/model/tool/image.php

5. FIND:
Code: Select all
$new_image = 'cache/' . substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.jpg'; 


6. REPLACE WITH:
Code: Select all
$info = pathinfo($filename);
$extension = $info['extension'];
$new_image = 'cache/' . substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension; 


7. Delete all cached images in image/data/cache and image/cache

8. Ctrl+F5 on your browser.

Only png & gif files will support transparent background. jpg images will have no change.

DEMO:
Image

Image
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18200
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] Support Transparent Backgrounds (1.4.4 - 1.4.8b on

Postby jzeltman » Thu Sep 02, 2010 4:03 pm

I've tried everything listed here and in other places. I'm quite exhausted from searching and finding solutions that aren't working. Please help.

I've upgraded to 1.4.9 and still have no luck with transparency on my product images. I've followed all of the steps listed here and elsewhere, and no luck. I've tried using 1.4.8 & 1.4.9 as is and don't have any luck, and modded 1.4.9 code with the code supplied above and no luck.

I have circular images an a gradient background and need for them to no have a white background.
jzeltman
 
Posts: 9
Joined: Tue Aug 31, 2010 5:34 pm

Re: [MOD] Support Transparent Backgrounds (1.4.4 - 1.4.8b on

Postby Qphoria » Thu Sep 02, 2010 4:06 pm

You are the second person to mention this... perhaps it is a server setting that is missing on some webhosts.

Ive tested this with a fresh 1.4.9 as well and I get a transparent image:
Image
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18200
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] Support Transparent Backgrounds (1.4.4 - 1.4.8b on

Postby jzeltman » Thu Sep 02, 2010 4:12 pm

Thanks for the speedy response.

I'm still in development mode and working on MAMP locally. I'll create a dummy install online and see if I still have the problem.
jzeltman
 
Posts: 9
Joined: Tue Aug 31, 2010 5:34 pm

Re: [MOD] Support Transparent Backgrounds (1.4.4 - 1.4.8b on

Postby jzeltman » Thu Sep 02, 2010 8:41 pm

So I've created a live version (http://joshuazeltman.com/oc/index.php?route=product/product&product_id=49)of my site and still have white background 'png's'. I looked through the images in Cache > Data and found that the smaller versions are in jpg format while the larger versions and the icon version are in png format.

Thoughts?
jzeltman
 
Posts: 9
Joined: Tue Aug 31, 2010 5:34 pm

Re: [MOD] Support Transparent Backgrounds (1.4.4 - 1.4.8b on

Postby popular » Mon Sep 06, 2010 3:18 pm

I also tried the code listed above using 1.4.8 and I tried replacing the two files listed above with the versions from 1.4.9 and still no luck! Anyone have ideas as to what server setting might be causing the difference in results?
popular
 
Posts: 31
Joined: Sun Jul 25, 2010 2:50 pm

Re: [MOD] Support Transparent Backgrounds (1.4.4 - 1.4.8b on

Postby jzeltman » Fri Sep 10, 2010 3:05 pm

So I finally cracked the case.

I had to physically rename the files in question the exact name of the resized images.
jzeltman
 
Posts: 9
Joined: Tue Aug 31, 2010 5:34 pm


Return to Template Support

Who is online

Users browsing this forum: gocreative and 14 guests

Hosted by Arvixe Web Hosting