Jump to content

png transparency issues, need image.inc.php


chancecorbeil

Recommended Posts

I am experiencing what appears to be a reoccurring issue with many people. I upload a product image as a png with a transparent background. Prestashop then displays these images with a solid white background after it converts them to a jpeg. Looking through previous posts, someone will solve the problem, an upgrade comes along, and the edited file becomes worthless.

 

Does anyone have an updated image.inc.php? Or maybe some other solution where I can display my products with a transparent background?

 

What I need is the image.inc.php file for prestashop 1.4.3

I am willing to upgrade if you have a different versions php.

 

Thank you.

Link to comment
Share on other sites

If you upload a PNG image, then although the created images will have JPG extension, the images themselves are still PNG and you can confirm this with a hex editor. Because browsers are forgiving of mislabelled extensions, even if the image is served with content type image/jpeg by the server, it will be treated as png by the browser with the end result of preservation of transparency. Here is an example:

 

The original PNG image (all non-black areas are transparent)

pngbt.png

 

After upload, this image is renamed and its extension is changed to jpg by prestashop. The next capture shows the original and the renamed/mis-extensioned image used in an HTML document. The background is given a color to show the transparency of both images.

 

comparisong.jpg

 

 

So if you prepare your images as PNGs transparency will work. If you're thinking this is a bad way to handle images, I am with you 100%, I know of no other software which handles images in this way. I suspect this because jpg is hardcoded throughout and reckon will be corrected sooner or later. Meanwhile, just upload pngs.

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 4 months later...
  • 4 months later...

If you have a solid colour that your images will be on you can use jpeg's and change the background colour that is added when they are generated in the imagemanager.php class

 

eg imagecolorallocate($dest_image, 249, 250, 250)

usually imagecolorallocate($dest_image, 255, 255, 255)

Link to comment
Share on other sites

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...