My simple goal was to compress PNG files with the following code:
$image = imagecreatefrompng("test.png");
imagepng($image, "result.png", 9, PNG_ALL_FILTERS);
I've also tried with zero and default compression, with the same results.
Original file is like this:
But the result on some (not all) images was like this:
The only way, I can produce good results is with this additional code:
imagealphablending($image, false);
imagesavealpha($image, true);
Why does this simple image manipulation produce this kind of artefacts? And by saving full alpha information, do I get into troubles with some browsers or unneeded filesize?
Is there any other foolproof solution, which would losslessly compress png files?