rturner Posted August 28, 2012 Share Posted August 28, 2012 (edited) Months ago, I did *something* to change my images, thumbnails, etc. to a grey background instead of white. After upgrading to PS 1.4.9, everything looked fine until I added a new image. It had the white background. I tried regenerating all thumbnails to make everything grey again. After that, every single image had the white background, or it had disappeared. Now, it seems that a third of my images are missing. To complicate things further, I have been using Cloudcache to serve images, css, etc. I tried clearing all of their cache, which didn't change anything. For now, I disabled their module, hoping that wherever my images are, the cloud cache won't be a factor in finding them. If there is any good news to a third of my site having broken images, I have a complete backup from yesterday, before I upgraded to 1.4.9. The problem is, the img directory in prestashop has so many subfolders of subfolders that I really have no idea what to replace via ftp. If anyone has any ideas, I'm all ears. Once I find my missing pics again, I still have to convert the white background to grey. Thx. Edited August 29, 2012 by rturner (see edit history) Link to comment Share on other sites More sharing options...
SuperCharlie Posted August 28, 2012 Share Posted August 28, 2012 Just throwing out a shot in the dark here.. I had an unrelated image issue with a jpg containing an alpha channel in my order pdf creation. I didnt even know jpg had an alpha channel, I thought that was a png thing. I use fireworks and had gotten the image from my [spam-filter] who used photoshop where I *think* the alpha came from. In any event I tried like hell to get rid of it and ended up having to do a screenshot and then crop that before I could use the image. Like I said.. long-shot.. but maybe your editor is leaving alpha laying around and PS is freaking on it. In any event.. sorry to hear your probs and may the force be with your swift repairs man. SC Link to comment Share on other sites More sharing options...
rturner Posted August 28, 2012 Author Share Posted August 28, 2012 Thanks, SuperCharlie. I have all my images back after I uploaded the entire img directory from backup. I don't think it's an alpha channel, as they are all the same kind of photoshop images. I could try redoing the new image, but I think the code I had in there to make the backgrounds grey was written over by the upgrade. Now when I put new images in, they all have the white background. I haven't yet figured out how I turned them grey before. At least the site works now :-) Link to comment Share on other sites More sharing options...
SuperCharlie Posted August 28, 2012 Share Posted August 28, 2012 Yay for working site.. It would seem that a global image background thing would require the images to have transparency and show the background.. I would think that modifying the product listing and product detail background area to the appropriate gray color would do what you are looking for as long as the images have the transparency. The only other thing I can think of is an on-the-fly color replacement by a server-side php image module but that would be some tricky stuff that might not have the intended consequences all the time. Link to comment Share on other sites More sharing options...
Wynn Posted August 28, 2012 Share Posted August 28, 2012 You can change the color of the image background in / images.inc.php. look for the instances where $white is defined and place in your own rgb values. there's also a $transparent that may need altering. Then regenerate thumbnails. 2 Link to comment Share on other sites More sharing options...
benjamin utterback Posted August 28, 2012 Share Posted August 28, 2012 Hello All, Thank you Wynn for the offered solution. rturner, has Wynn's recommendation solved your image issue? Thank you for the information, it will certainly help other merchants with similar problems. Thank you very much for choosing PrestaShop! -Benjamin Link to comment Share on other sites More sharing options...
rturner Posted August 28, 2012 Author Share Posted August 28, 2012 Hey Wynn, I'll try that this evening when I can work on the site. I had tried replacing the $white definition earlier, but didn't do anything with a $transparent code. Also, there may be cache/compile or media server issues (as in turning it off before I change images) I need to go over step-by-step. I'll post back if it works. Thanks! Link to comment Share on other sites More sharing options...
rturner Posted August 29, 2012 Author Share Posted August 29, 2012 (edited) Okay, Wynn had the solution. All is working now. Thanks, guys. To summarize, when you want a different background color for your images and thumbnails: 1- Edit /your_prestashop_directory/images.inc.php 2- Find every instance of 255 which defines the white background and replace it with your color. In my case the color was grey and the RBG values in photoshop are 153,153,153 3- So, example: Replace this: $transparent = imagecolorallocatealpha($destImage, 255, 255, 255, 127); With this: $transparent = imagecolorallocatealpha($destImage, 153, 153, 153, 127); There are about 5 sections like that you will have to change from Line 250 or so down. 4-It works! And in my case (am I maybe just a teensy gunshy?) I didn't have to regenerate thumbnails to get it to work. Edited August 29, 2012 by rturner (see edit history) 1 Link to comment Share on other sites More sharing options...
swiatmar Posted November 11, 2013 Share Posted November 11, 2013 okay in version 1.5.6 it doesn't work any more in images.inc.php any one knows how to set the thumbnail color of images? Link to comment Share on other sites More sharing options...
JosephdeSouzagoa Posted January 12, 2014 Share Posted January 12, 2014 For Prestashop 1.5. you have to edit the file classes/ImageManager.php For example to change to grey background change 255,255,255 to 228,228, 228 as shown below: $dest_image = imagecreatetruecolor($dst_width, $dst_height); // If image is a PNG and the output is PNG, fill with transparency. Else fill with white background. if ($file_type == 'png' && $type == IMAGETYPE_PNG) { imagealphablending($dest_image, false); imagesavealpha($dest_image, true); $transparent = imagecolorallocatealpha($dest_image, 228, 228, 228, 127); imagefilledrectangle($dest_image, 0, 0, $dst_width, $dst_height, $transparent); } else { $white = imagecolorallocate($dest_image, 228, 228, 228); imagefilledrectangle ($dest_image, 0, 0, $dst_width, $dst_height, $white); } 1 Link to comment Share on other sites More sharing options...
Rick4F Posted January 20, 2014 Share Posted January 20, 2014 For Prestashop 1.5. you have to edit the file classes/ImageManager.php For example to change to grey background change 255,255,255 to 228,228, 228 as shown below: $dest_image = imagecreatetruecolor($dst_width, $dst_height); // If image is a PNG and the output is PNG, fill with transparency. Else fill with white background. if ($file_type == 'png' && $type == IMAGETYPE_PNG) { imagealphablending($dest_image, false); imagesavealpha($dest_image, true); $transparent = imagecolorallocatealpha($dest_image, 228, 228, 228, 127); imagefilledrectangle($dest_image, 0, 0, $dst_width, $dst_height, $transparent); } else { $white = imagecolorallocate($dest_image, 228, 228, 228); imagefilledrectangle ($dest_image, 0, 0, $dst_width, $dst_height, $white); } Thank you for finding out how to change the background color of product images and thumbnails in prestashop! This, which has a mayor impact on your skin, should be more easily to be modified in the back office. Would love to see that happen in a new version of prestashop. Link to comment Share on other sites More sharing options...
Rick4F Posted January 20, 2014 Share Posted January 20, 2014 Ok, you need to change another file in the classes folder too, or new product thumbs still have a white background. In webservice -> WebserviceSpecificManagementImages.php around line 833: // Build the image if ( !($destImage = imagecreatetruecolor($destWidth, $destHeight)) || !($white = imagecolorallocate($destImage, 255, 255, 255)) || Change the 255's into whatever rgb value you need. 1 Link to comment Share on other sites More sharing options...
sightless Posted April 30, 2014 Share Posted April 30, 2014 (edited) EDIT: Nevermind got the above to work correctly sorry! Edited May 1, 2014 by sightless (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts