PHP把PNG图片转化为JPG时透明背景变黑色
$type = exif_imagetype($srcimg); switch($type) { case 1: $simg = imagecreatefromgif($srcimg); break; case 3: $tmp = imagecreatefrompng($srcimg); $w = imagesx($tmp); $y = imagesy($tmp); $simg = imagecreatetruecolor($w, $y); $bg =imagecolorallocate($simg, 255, 255, 255); imagefill($simg, 0, 0, $bg); imagecopyresized($simg, $tmp, 0, 0, 0, 0,$w, $y, $w, $y); break; }