image_lib - resizing transparent png24 |
[eluser]mandelkern[/eluser]
Hi, I tried to resize a png-24 file with the codeigniter-image_lib, using GD2. The result looses its transparency and shows a black background. I couldn't find any solutions, fixing this within the image_lib. Can someone help me with this problem? Thanks.
[eluser]Référencement Google[/eluser]
Look at: http://ellislab.com/forums/viewthread/62955/#311374 Is this helping?
[eluser]mandelkern[/eluser]
Thanks, elite but I already tried this. It helps fine with gif and png-8 but my problem seems to be special with GD2 and png-24.
[eluser]Référencement Google[/eluser]
I posted the issue some time ago: http://ellislab.com/forums/viewthread/71962/ It is a CI bug and it looks like nobody has found a solution yet. You'll have to dive into the CI Image lib code and rework the GD part that make the transparency working. Sorry I can't help much more.
[eluser]Référencement Google[/eluser]
If you find a solution please post it.
[eluser]BorisK[/eluser]
I had this same problem solved in PHP a while ago. Can you send me a link to a sample image that fails to work. If it keeps transparency in my code I'll port the hack to CI library.
[eluser]mandelkern[/eluser]
I found a solution at http://www.webdeveloper.com/forum/showthread.php?t=178210. Nearly at line 514 - $dst_img = $create($this->width, $this->height); I changed the code this way: //$dst_img = $create($this->width, $this->height); /* TRANSPARENT PNG */ $dst_img = imagecreatetruecolor($this->width, $this->height); $transparent = imagecolorallocatealpha($dst_img,0,255,0,127); imagefill($dst_img,0,0,$transparent); $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height); imageAlphaBlending($dst_img, false); imageSaveAlpha($dst_img, true); ..and now it works.
[eluser]Référencement Google[/eluser]
Hey that's really cool, please report that + solution to the bug tracker of CI or to the forums bugs category
[eluser]BorisK[/eluser]
That's pretty similar to my PHP code, except that I refactored the ImageSetAlpha function: Code: function ResizeImage($newWidth, $newHeight) |
Welcome Guest, Not a member yet? Register Sign In |