Welcome Guest, Not a member yet? Register   Sign In
Image lib black background on crop
#1

[eluser]zbrox[/eluser]
Hi there,

I'm trying to resize an image to a smaller one with different proportions. The resulting image comes out with an area of black where's the extra space. However I need it to be either transparent, or white, but not black Smile
I edited the Image library so that it would resize PNG's without losing the transparency. I added this:
Code:
if ($this->image_type == 3 || $this->image_type == 1) {
             //Using alpha channel
             imagealphablending($dst_img, false);
             imagesavealpha($dst_img,true);
             //Allocating transparent color
             $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
             //full image filled with transparent color
             imagefilledrectangle($dst_img, 0, 0, $this->width,  $this->height, $transparent);
           }

Judging by it imagefilledrectangle gets $transparent as a background color, I tried changing it to the $white variable used above in the code, but still the result is a black background.
Any ideas why this is happening?
#2

[eluser]matt2012[/eluser]
Have you set your library to GD2?
#3

[eluser]zbrox[/eluser]
Yes, I'm using GD2, not GD.
#4

[eluser]zbrox[/eluser]
I forgot to mention I'm using Codeigniter 1.7.2.
#5

[eluser]elvix[/eluser]
i'm not sure you need that last line imagefilledrectangle. try deleting it?




Theme © iAndrew 2016 - Forum software by © MyBB