0

I'm trying to draw some images with GDlib, but the transparency doesn't work. I tried already the simple example from php.net:

$im1 = imagecreatetruecolor(200, 200);
$background = imagecolorallocate($im1, 255, 255, 255);
imagecolortransparent($im1, $background);
imagealphablending($im1, false);
imagesavealpha($im1, true);

header('Content-type: image/png');
imagepng($im1);
imagedestroy($im1);

but it also doesn't work. The transparent background is black. I don't resize anything, don't merge multiple images, I just want to create a transparent image. I'm working with PHP 5.5.28 on OS X Yosemite installed with Homebrew.

I would be very appreciated for any help.

iMx
  • 846
  • 1
  • 9
  • 23
  • Possible duplicate of http://stackoverflow.com/questions/6109832/php-gd-create-a-transparent-png-image – undefined_variable Dec 23 '15 at 09:53
  • @Undefined_variable no. I already tried all this solutions, the example in my question is just a simple version of them. I guess, it has nothing to do with the code, but with the GD itself. – iMx Dec 23 '15 at 09:59
  • 1
    http://php.net/manual/en/function.imagecolortransparent.php says 0,0,0 for background – undefined_variable Dec 23 '15 at 10:04
  • @Undefined_variable I already tried this example. It didn't work. Now It works, but in my case only without imagesavealpha(). However, I can accept it as correct answer. Thanks. – iMx Dec 23 '15 at 10:23
  • http://php.net/manual/en/function.imagesavealpha.php please refer this doc it may help. The example is available in there – undefined_variable Dec 23 '15 at 10:29

0 Answers0