GDライブラリを使用してPHPでマップジェネレータを構築する予定です。私はlibを使用していくつかの画像を生成しましたが、それらは良い品質を持っていません。私は、画像の品質を改善する方法があることを知りたいだけです。PHP GD生成画像の品質を改善する
生成された画像である。
iがなさコードである:
<?php
$canvas = imagecreate(800, 350);
imagecolorallocate($canvas, 255, 255, 255);
$pink = imagecolorallocate($canvas, 255, 105, 180);
$white = imagecolorallocate($canvas, 255, 255, 255);
$green = imagecolorallocate($canvas, 132, 135, 28);
imagestring($canvas, 20, 290, 25, "Quality is not the best :(", $green);
function drawlinebox($x1, $y1, $x2, $y2, $height, $color){
global $canvas;
imagesetthickness ($canvas, 1);
for ($i=1; $i < $height; $i++){
imageline($canvas, $x1, $y1, $x2, $y2, $color);
$y1++; $y2++;
}
}
drawlinebox(20, 20, 780, 300, 30, $green);
drawlinebox(20, 300, 780, 20, 30, $pink);
header('Content-Type: image/jpeg');
imagejpeg($canvas);
imagedestroy($canvas);
?>
「imagejpeg」ではなく「imagepng」を使用してください。 PNG( 'header( 'Content-Type:image/png');')はより良いフォーマットかもしれません。 –
アンチエイリアス機能を試しましたか? – kaiser