PHP Classes

Adding transparent PNG image

Recommend this page to a friend!

      Image Processor (CSS)  >  All threads  >  Adding transparent PNG image  >  (Un) Subscribe thread alerts  
Subject:Adding transparent PNG image
Summary:Transparent sectors are black
Messages:5
Author:Andre Dörscheln
Date:2010-05-27 13:37:45
Update:2010-05-29 14:04:11
 

 


  1. Adding transparent PNG image   Reply   Report abuse  
Picture of Andre Dörscheln Andre Dörscheln - 2010-05-27 13:37:45
Hello,

First I have to say, that this is one of the best classes, I've found during the last 2 years. It's easy, fast and has a nice code.

My problem is, that I want to add a transparent PNG image to another. When I try, the transparent sectors are black...

wfg, André

  2. Re: Adding transparent PNG image   Reply   Report abuse  
Picture of Tufan Baris YILDIRIM Tufan Baris YILDIRIM - 2010-05-28 05:44:51 - In reply to message 1 from Andre Dörscheln
Hello Andre,
First thanks. can u show your code ?

  3. Re: Adding transparent PNG image   Reply   Report abuse  
Picture of Andre Dörscheln Andre Dörscheln - 2010-05-28 10:45:26 - In reply to message 2 from Tufan Baris YILDIRIM
Hello Tufan,

These two lines are responsible for the adding of the second image:

$im = new D3Image("file:./images/twittus_bg1.png;");
$im->add(new D3Image("file:".$img), "left: 15px; top: 16px;");

Andre

  4. Re: Adding transparent PNG image   Reply   Report abuse  
Picture of Tufan Baris YILDIRIM Tufan Baris YILDIRIM - 2010-05-28 11:15:53 - In reply to message 3 from Andre Dörscheln
Hello Andre,
Thanks for your tests. add this function for resolve this problem.

/**
* use only for PNG images.
*/
public function TurnOffBlending(){
imagealphablending($this->image, false);
imagesavealpha($this->image, true);
return $this;
return $this->forEditores();

}



and use as:

$image=new D3Image('file:logo.png;');
$image->TurnOffBlending();


if you use resizing while using Add( transparency will not work.
For Example :

$im->add(new D3Image("file:".$img), "left: 15px; top: 16px;"); // this will work.

$im->add(new D3Image("file:".$img), "left: 15px; top: 16px;width:10px;height:20px"); // this will not.



i will add this func on new version with some bug fixes.

Regards.

  5. Re: Adding transparent PNG image   Reply   Report abuse  
Picture of Andre Dörscheln Andre Dörscheln - 2010-05-29 14:04:11 - In reply to message 4 from Tufan Baris YILDIRIM
Thank you for your quick reply.
I'm very pleasant about seeing it work and your good support =)

Andre