• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image lib black background on crop

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:
if ($this->image_type == 3 || $this->image_type == 1) {
             //Using alpha channel
             imagealphablending($dst_img, false);
             //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?

Have you set your library to GD2?

Yes, I'm using GD2, not GD.

I forgot to mention I'm using Codeigniter 1.7.2.

i'm not sure you need that last line imagefilledrectangle. try deleting it?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.