实验后,似乎用imagecreatetruecolor建立真彩图片,导致透明背景的gif和png图片,背景变成黑色于是用了原始的imagecreate 和 imagecolorallocate可是这样对gif支持了,可是png有些支持挺好的,有些缩略后效果很差我的代码是if( $ftype == "gif" || $ftype == "png" ){
$tmp = imagecreate( $newwidth , $newheight );
imagecolorallocate($tmp, 255, 255, 255);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
}else{
$tmp = imagecreatetruecolor( $newwidth , $newheight );
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
}请教高手,求完全支持gif和png和jpeg的制作缩略图的代码
$tmp = imagecreate( $newwidth , $newheight );
imagecolorallocate($tmp, 255, 255, 255);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
}else{
$tmp = imagecreatetruecolor( $newwidth , $newheight );
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
}请教高手,求完全支持gif和png和jpeg的制作缩略图的代码
对啊,在gif和png的时候,是用了imagecolorallocate这个函数可是对于png图片效果不佳用imagecreatetruecolor 函数建立的真彩图像又不能用imagecolorallocate函数
如果真要改变背景色。就只好使用imagecreate了。还是那句话: 四个函数按以下搭配使用:
imagecreatetruecolor 和 imagecopyresampledImageCreate和 ImageCopyResized
不需要改变背景色啊,只是png和gif图片用 imagecreatetruecolor 和 imagecopyresampled 的话背景就变成黑色的了