Reduce the image from 24-bit rgb to 8-bit rgb, but the result will not be as beautiful as tinypng.com

I use imagetruecolortopallete to reduce the image from 24-bit rgb to 8-bit rgb, but the result is not beautiful just like tinypng.com, how can I do this?

source image 24 bit rgb

convert 8 bit rgb image to my code

24bit

8bit bad

image 8 bit rgb convert by tinypng.com

8bit ok

[Spectrum]: sorry for not the whole image, but I lost my patience, the source link is too slow / unstable (it took ~ 20 minutes after the 3rd attempt to download it ...)

<?php
$im = imagecreatetruecolor(1024, 768);
imagetruecolortopalette($im, true, 255);
imagepng($im, 'cat.png');
imagedestroy($im);
?>
+4
source share

No one has answered this question yet.

Source: https://habr.com/ru/post/1619591/


All Articles