簡體   English   中英

PHP imagecreatetruecolor 修復 antiailas 問題

[英]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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM