Welcome Guest, Not a member yet? Register   Sign In
Transparent Gif BG Color
#1

[eluser]dmorin[/eluser]
When processing images using the image library, is there a way to set the background color of transparent gifs/pngs? By default, we save everything as jpgs so transparent gifs get rendered with a black background. I'd like to make it white. Thanks
#2

[eluser]dmorin[/eluser]
Well, it's a hack of a solution, but adding the middle two lines below at line 520 in the image library works (CI 1.6.3):

Code:
$dst_img = $create($this->width, $this->height);
$bg_color = imagecolorallocatealpha($dst_img, 255, 255, 255, 0);
imagefill($dst_img, 0, 0, $bg_color);
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);

I use GD2 so if you use something else, this won't work. Of course, extending the library would be a better option, but this is a quick fix.




Theme © iAndrew 2016 - Forum software by © MyBB