Reputation: 1631
I'm trying to resize an image with GD and am seeing a color loss on the resized image. Here is my code:
$src = imagecreatefromstring(file_get_contents($source));
ImageCopyResized($dst, $src, 0, 0, 0, 0, $t_width, $t_height, ImageSX($src), ImageSY($src));
Imagejpeg($dst, $dest, 90);
Upvotes: 0
Views: 1618
Reputation: 1631
The right way to do this is:
$dst = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($dst, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
Upvotes: 0