Post by timmyi23 » Mon Sep 15, 2014 8:05 pm

Hi

Can anyone let me know how I can alter the code so that the transparent background of my .png images are preserved...at the moment they all have a black background.

Many thanks

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by SXGuy » Mon Sep 15, 2014 8:23 pm

what version of opencart are you using? there was a few issues with past releases.

But the current one, should be fine for transparent backgrounds. Its more likely to be a stylesheet issue adding a black background to your image div. Rather than the png file.

One way to know, is check the cached png images, do they contain a black background?

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by Qphoria » Mon Sep 15, 2014 9:19 pm

Yea I added png transparency support back in 1.4.9... what version are you using?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by timmyi23 » Mon Sep 15, 2014 9:37 pm

Hi

Its new Version 1.5.6.4, default template. I have checked the image/cache/data folder and the png files all have a black background!

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by timmyi23 » Mon Sep 15, 2014 9:58 pm

SXGuy wrote:what version of opencart are you using? there was a few issues with past releases.

But the current one, should be fine for transparent backgrounds. Its more likely to be a stylesheet issue adding a black background to your image div. Rather than the png file.

One way to know, is check the cached png images, do they contain a black background?
Hi,

Sorry which line am I looking for in the css.stylesheet?

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by SXGuy » Tue Sep 16, 2014 5:08 am

If the cached images have a black background then it is rendering the images with a black background. Its not a stylesheet issue as I first thought.

look at system/library/image.php for this code, if its different, replace it with this

Code: Select all

if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') {		
			imagealphablending($this->image, false);
			imagesavealpha($this->image, true);
			$background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
			imagecolortransparent($this->image, $background);
		} else {
			$background = imagecolorallocate($this->image, 255, 255, 255);
		}

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by timmyi23 » Tue Sep 16, 2014 5:40 am

Hi,

My code is exactly the same as this at the moment!

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by SXGuy » Tue Sep 16, 2014 4:05 pm

Ok, only other thing I can think of, is your png images are not quite saved correctly. Are they saved as interlaced with a transparent background, before you have uploaded them?

If you can attach an original png image to this thread, ill take a look at it and see if that's the issue.

Apart from that, im out of ideas.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by timmyi23 » Tue Sep 16, 2014 5:48 pm

I do appreciate any help you can give me with this. This is an example of one of the png images I uploaded...I haven't got a better example as have been deleting them since the problem started.
Thanks

Tim

Attachments

250 e-100x100.png

250 e-100x100.png (9.62 KiB) Viewed 6326 times


New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by SXGuy » Tue Sep 16, 2014 9:30 pm

Ok, what I wanted was the Original PNG image, BEFORE you uploaded it. So I can test for png saved options, like interlacing.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by timmyi23 » Tue Sep 16, 2014 10:00 pm

Hi mate. I just created another uploaded it and is turned to a black background by OC. Checked the spec and it is Interlaced and is a 24 bit PNG image.

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by timmyi23 » Wed Sep 17, 2014 6:25 am

Anyone have an answer??????

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by SXGuy » Wed Sep 17, 2014 3:59 pm

can you attach an original image just so I can look please?

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by timmyi23 » Wed Sep 17, 2014 5:07 pm

Hi,

Have just found this one as an example.

Thanks

Attachments

1a.png

1a.png (8.07 KiB) Viewed 6277 times


New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by timmyi23 » Wed Sep 17, 2014 5:08 pm

When uploaded to OC the background is black.

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by SXGuy » Thu Sep 18, 2014 1:31 am

Try this, tell me if it didn't work.

Remember to rename it first before upload

Attachments

1a.png

1a.png (6.44 KiB) Viewed 6266 times


Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by timmyi23 » Thu Sep 18, 2014 1:37 am

Hi,

Didn't work...OC change the background to black again!! Is there not a piece of code to remedy this?

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm

Post by SXGuy » Thu Sep 18, 2014 1:54 am

Technically, the code I posted should fix it, but you said its the same, so im out of answers. Someone else may need to help, with fresh ideas.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by granddaddy » Thu Sep 18, 2014 4:17 am

I remember there was a problem with the transparency of png files in opencart, but the problem was in the "php resize" function, so it only happened with the automatic thumbnail creation... in other words when you add a category or product image. If you simply insert images into a description field it shoudn't happen.
You mentioned earlier that you had checked the image/cache/data folder. That folder only contains the thumbnail cache, embedded images always use the originals. This leads me to suspect you are only getting this problem during thumbnail creation - is that true? If you try inserting an image directly into a description field does it still have a black background?

Active Member

Posts

Joined
Sat Feb 18, 2012 5:48 pm

Post by timmyi23 » Thu Sep 18, 2014 7:04 am

Sorry I'm not sure I understand what you are saying regarding 'inserting an image directly into a description field'? I use the image uploader to load all my images and as soon as it uploads a png it turns the background black and it loses its transparency. How do I insert an image directly??

New member

Posts

Joined
Wed Nov 27, 2013 10:14 pm
Who is online

Users browsing this forum: No registered users and 65 guests