php gd,使用两个图像,质量差
我改变图像尺寸并换上其他图像,但图像质量很差,为什么? (当我保存图像时,我设置了100质量)
$src = imagecreatetruecolor($new_width, $new_height);
$src2 = imagecreatefromjpeg($img_url);
imagecopyresampled($src, $src2, 0, 0, 0, 0, $new_width, $new_height, $new_img_size['org_w'], $new_img_size['org_h']);
$bg_size = 600;
$img_center_w = ($bg_size / 2) - ($new_width / 2);
$img_center_h = ($bg_size / 2) - ($new_height / 2);
$dst = imagecreate($bg_size, $bg_size );
$bg = imagecolorallocate($dst, 225, 255, 255);
imagecopy($dst, $src, $img_center_w, $img_center_h, 0, 0, $new_width, $new_height);
imagejpeg($dst, 'test_img.jpg', 100);
i change image size and put on others, but image quality very poor, why?
(When i save image I set 100 quality)
$src = imagecreatetruecolor($new_width, $new_height);
$src2 = imagecreatefromjpeg($img_url);
imagecopyresampled($src, $src2, 0, 0, 0, 0, $new_width, $new_height, $new_img_size['org_w'], $new_img_size['org_h']);
$bg_size = 600;
$img_center_w = ($bg_size / 2) - ($new_width / 2);
$img_center_h = ($bg_size / 2) - ($new_height / 2);
$dst = imagecreate($bg_size, $bg_size );
$bg = imagecolorallocate($dst, 225, 255, 255);
imagecopy($dst, $src, $img_center_w, $img_center_h, 0, 0, $new_width, $new_height);
imagejpeg($dst, 'test_img.jpg', 100);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想这就是问题所在。您应该使用上面的
imagecreatetruecolor
。I guess that's the problem. You should use
imagecreatetruecolor
as above.