php - Black background when turning a PNG into a GIF -


i have png image trying open , output gif image. however, transparency lost when , background turns black. if output image png, works, need open image png , output gif.

this have far:

 <?php  header("content-type: image/gif");   $new_img = imagecreatefrompng($image);  imagealphablending($new_img, false);   imagesavealpha($new_img, true);   imagegif($new_img);  ?> 

however, imagepng($new_img) saves background transparency not output gif.

try code:

<?php header("content-type: image/gif");  $new_img = imagecreatefrompng($image); $trans_color = imagecolortransparent($new_img); $trans_index = imagecolorallocate($new_img, $trans_color['red'], $trans_color['green'], $trans_color['blue']); imagecolortransparent($new_img, $trans_index); imagegif($new_img); ?> 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -