PHP imagecreatetruecolor修复了反ailas问题


PHP imagecreatetruecolor fix antiailas issues

我有重叠图像的问题。我遇到的问题是,代码会损坏带有黑色像素化边框的设备的边缘。下面是我的代码。我能对我的代码做些什么来提高质量吗?

$src1 = imagecreatefromstring( file_get_contents( $_FILES['image']['tmp_name'] ) );
$size1 = getimagesize( $_FILES['image']['tmp_name'] );
$dst1 = imagecreatetruecolor( 696, 400 );
imagecopyresampled( $dst1, $src1, 0, 0, 0, 0, 696, 399, $size1[0], $size1[1] );
imagedestroy( $src1 );
$width = 1200;
$height = 687;
$image = imagecreatetruecolor($width, $height);
imagecopyresampled($image, imagecreatefrompng('images/main.png'),0,0,0,0,$width,$height,$width,$height);
imagecopy($image, $dst1, 333, 103, 0, 0, 696, 399);
$transparency = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagesavealpha($image, true);
imagefill($image, 0, 0, $transparency);
imagedestroy( $dst1 );
imagedestroy( $dst2 );
imagedestroy( $dst3 );
imagedestroy( $dst4 );
ob_start();
imagepng($image, NULL, 0);
$size = ob_get_length();
header("Content-Length: " . $size);
header("Cache-Control: private");
header("Content-Type: image/png");
header("Content-Disposition: attachment; filename=test.png");

移动这个…

$transparency = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagesavealpha($image, true);
imagefill($image, 0, 0, $transparency);

到右下方…

$image = imagecreatetruecolor($width, $height);