OK, all of my product pictures are gifs with a transparent background. But when I add these products to Cs-Cart, the transparency is lost. All my thumbnails, products images, detailed product images, category images, etc. now have white backgrounds.
Did I miss a setting in Cs-cart to leave the background alone when uploading images? Or is this a BUG?
Also, now that cs-cart has messed up over 3,000 images. How do I go about getting them back to a transparent background?
David
I have the same issue, but I’m using transparent PNG instead. I’m getting a dark green background and although I found a way around it (a very time consuming), I hope someone can replace the CS-Cart’s image processing class with the one that supports alpha transparency.
For those who can’t wait, I suggest to upload the images first through ADMIN and then find their names and location in the images folder. You have to name your local original images to match with the ones that were created dynamically and then overwrite them by uploading the original ones on to the server. This process is not as bad if you have 2-3 products, but in my case, I had to replace over 50 product images in 3 different sizes.:sad: :sad:
Hi Bazzaretta, for a while now I had the same desire for transparent thumbnails and couldn’t put off finding an answer any longer.
I stayed up all last night reading everything I could find on the subject and eventually learned enough about our cart and php’s GDlib to craft a satisfactory workaround. As a result, I have transparent thumbs and tired eyes. (Poor man’s X-ray vision)
Caveats:
You will be changing one of the core files, thus the process while easy enough will need to be repeated each time you upgrade CS-Cart.
I don’t know if there will be any ‘side effects’ as I made these changes less than 12 hours ago and can only confirm they are working in my shared hosting environment. I have tested briefly in the latest FF, Opera, Chrome and safari on osx 10.6 and IE7 and 8 on Windows 7. Far from a complete and exhaustive check, but so far all of those browsers render the resulting png’s correctly.
I’m not by any means knowledgeable in this area, only knowing what I learned over the course of the last 24 hours.
All that being thing said, if you’re still with me, make a back up of fn.images.php found in the core directory.
Open that file and scroll down to line 729 where you should see the code and comments below:
```php
// Set transparent color to white
// Not sure that this is right, but it works
// FIXME!!!
// $c = imagecolortransparent($new);
list($r, $g, $b) = fn_parse_rgb($bg_color);
$c = imagecolorallocate($dst, $r, $g, $b);
//imagecolortransparent($dst, $c);
if ($make_box) {
imagefilledrectangle($dst, 0, 0, $dst_width, $dst_height, $c);
```
Replace with:
```php
// Set transparent color to white
// Not sure that this is right, but it works
// FIXME!!!
// $c = imagecolortransparent($new);
// list($r, $g, $b) = fn_parse_rgb($bg_color);
// $c = imagecolorallocate($dst, $r, $g, $b);
// imagecolortransparent($dst, $c);
// ANF- set black as alpha, (127 is the max amount of transparency)
$colourBlack = imagecolorallocatealpha($dst, 0, 0, 0, 127);
// ANF 06.01.2011- Turn off alpha blending and set alpha flag
//
imagealphablending($dst, false);
imagesavealpha($dst, true);
if ($make_box) {
imagefilledrectangle($dst, 0, 0, $dst_width, $dst_height, $colourBlack);
// ANF- added $colorBlack to replace the redrawn areas of our resampled thumbs with transparent pixels.
```
Save the file, then clear the thumbnails cache. (http://www.‘YOUR_DOMAIN’/admin.php?ct)
I also cleared the admin cache, mostly because I like clearing caches, though I’m not sure if that is necessary.
Lastly go to your sites Admin, Settings, Thumbnails page and change the Thumbnail background color value to black (000000)
Your thumbnails should have defaulted to a black background after commenting out the code earlier but I believe in ghosts and like to be sure.
Considering how few lines are changed, my new skin design looks infinitely better and was well worth the time invested.
I hope this works as well for you as it has for me.
Regards,
Fleety
In 2.1.1, you can set the background of thumbnails in the thumbnail settings (dispatch=settings.manage§ion_id=Thumbnails).
[quote name=‘tbirnseth’]In 2.1.1, you can set the background of thumbnails in the thumbnail settings (dispatch=settings.manage§ion_id=Thumbnails).[/QUOTE]
In using this setting how would you get them to be transparent though?
Don’t know. I’d guess maybe blank? I would expect this only to apply to areas outside the original source images aspect ratio. But to be honest, image handling has changed so much in the last few releases, I find it hard to keep up.
[quote name=‘tbirnseth’]Don’t know. I’d guess maybe blank? I would expect this only to apply to areas outside the original source images aspect ratio. But to be honest, image handling has changed so much in the last few releases, I find it hard to keep up.[/QUOTE]
I tried leaving it blank, it just blacks out the background…oh well…these are the things that should be documented, why make people guess.
[quote]
why make people guess.
[/quote]
It generates support revenue.
[quote name=‘tbirnseth’]It generates support revenue.[/QUOTE]
lol true, and alot of frustration and buyers remorse haha
[quote name=‘tbirnseth’]It generates support revenue.[/QUOTE]
[quote name=‘jhagg’]lol true, and alot of frustration and buyers remorse haha[/QUOTE]
How true, how true. Thanks guys, this gave me quite a laugh!
Despite improvements in other areas, sub par documentation is still par for the course.
jhagg, if you have already got your transparent product option thumbs well and good, if not, I realize that in my post above I omitted to state that the modifications I made were to the 2.1.2 version. Everything has been good with no issues so far.
I just downloaded the 2.1.4 community edition and compared the relevant parts of the fn.images.php file. Nothing has changed there, so the above modifications will in all likelihood still work.
Let me know if you have questions, problems or difficulties.
This worked perfectly.
[QUOTE] // Set transparent color to white
// Not sure that this is right, but it works
// FIXME!!![/QUOTE]
Hahaha… professionalism at it best ;}
I do know that leaving the Background color setting “blank” or transparent does not work.
The original GIF file with a white bg that has been set to alpha (transparent) shows up with a BLACK background !
This says it all !!
[QUOTE] // Set transparent color to white
// Not sure that this is right, but it works
// FIXME!!![/QUOTE]
Thanks for the Fleety work-around … I made the changes, but it has not worked for me.
I deleted cache, re-did the images, deleted the current images and selected them again.
The transparent sections are just Black on the new files.
[QUOTE] Lastly go to your sites Admin, Settings, Thumbnails page and change the Thumbnail background color value to black (000000) [/QUOTE]
you mean #000000 rather than 000000 right?
So for now the work-around is to go into /thumbnails/ and replace the images with correctly sized original files … tedious !
Just in case the CSCART team do wish to address this bug,
Whats needed is:
- The Transparent sections or the original image need to remain transparent.
- The Fill-in area after resizing by /core/fn.images.php needs also to be Transparent if >>Settings>>Thumbnails>>Thumbnail background color is set to “” or “transparent”
[url]http://forum.cs-cart.com/vbugs.php?do=view&vbug_id=2575[/url]
FYI-
Surprisingly the workaround I posted is still working fine after upgrading to 2.2.1
The epic;// Set transparent color to white
// Not sure that this is right, but it works
// FIXME!!
Hasn't seen any love this time around, so until an official rewrite takes place the hack is still good to go.
As seen working here
Good… Dont know why I couldnt get it to work for my site, I gave up trying, so am still doing the workaround by manually replacing the images. Only about 100 to go… should have it launched by june 2012.!
Thats a great skin yove made for the site… did you base it on electro skin also?