tags:

views:

31

answers:

1

Hi,

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);
A: 

$dst = imagecreate($bg_size, $bg_size );

I guess that's the problem. You should use imagecreatetruecolor as above.

Christopher Fox