2016-09-29 6 views
1

イメージにオーバーレイする問題があります。問題は、黒いピクセル化された境界線が乏しいデバイスのエッジにコードが損害を与えることです。以下は私のコードです。品質を向上させるためにコードに行うことができることはありますか?右下までPHP imagecreatetruecolorは問題を修正しました

$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"); 

答えて

1

移動この...

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

...

$image = imagecreatetruecolor($width, $height); 
関連する問題