Jump to content

[Solved] Configure image background colour


Recommended Posts

It's looking really good.

 

I have one question though (so far).

 

When I generate images it converts them all to nice squares - but the image background (where the original image was not square) is set to black.

 

Is there a way to control this to set it to white or transparrent?

Link to comment
Share on other sites

andrew,

 

See this series of posts:

 

http://www.prestashop.com/forum/index.php/topic,131.0.html

 

It appears that, for now, viewing the source code for the loaded pages in your browser and editing the corresponding classes in the css stylesheet may be the best we can do.  I've just done a first install and am facing the same sorts of issues.  If I come up with an answer to your specific question, I'll repost, but it looks as if most of these answers are going to be found in the "themes" section of the Forum.

Link to comment
Share on other sites

Thanks for the reply.

 

I am not quite sure it is contolled by the css (I can't see it if it is)

 

In Adminimages.php it regenerates the product images - and here it adds a black background to make the images square - I want them to be generated with a white or transparrent packground.

 

/* Regenerate products images */

$errors = false;

foreach ($productsImages AS $k => $image)

{

if (file_exists(_PS_PROD_IMG_DIR_.$image['id_product'].'-'.$image['id_image'].'.jpg'))

foreach ($productsTypes AS $k => $imageType)

{

$file['tmp_name'] = _PS_PROD_IMG_DIR_.$image['id_product'].'-'.$image['id_image'].'.jpg';

$file['type'] = 'image/jpg';

if (!imageResize($file, _PS_PROD_IMG_DIR_.$image['id_product'].'-'.$image['id_image'].'-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height'])))

$errors = true;

}

}

 

 

This is my first foray into php - so any help would be appreciated.

Link to comment
Share on other sites

Now I am getting further (I think)

 

There is a file called functions.php in the admin directory which includes code that resizes and generates all the images.

 

However - it looks to me like it should be generating the immages with a white background - but mine are coming out black.

 

Any ideas?

Link to comment
Share on other sites

Hi everyone

 

Sorry for the tardiness of this reply :-[

 

You can see around line 238 of /admin/functions.php (just where you are right now)

 

$white = imagecolorallocate($destImage, 255, 255, 255);

 

where the 255 values are the primary color components Red, Green, and Blue.

 

So, to replace white with black, just replace all the 255's with 0's.

 

It's true that the variable will be called "white" but will in fact be black ::) but if you really want to, you can do a replace all "$white" with "$black" in your favorite editor.

 

To simplify the life of everybody, we'll include this functionality directly on the Back Office on an upcoming release ;)

Link to comment
Share on other sites

  • 6 months later...

I'm having the same problem as was originally mentioned.
The code in my functions.php file shows 255, 255, 255 which should mean white but after re generating the images they are still coming out with the black background. I also tried using 255, 0, 0 which i assume should be red but again, the background comes out black. Its as if the imagecolorallocate function isn't working.

Does anyone else have this problem or could it be something to do with the gdimage library that im using?

Im using a new install of v 1.0.0.8.

Cheers

Link to comment
Share on other sites

  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...