我有以下代码似乎正在生成损坏的图像。Photoshop 显示“PNG 文件因 ASCII 转换而损坏”
$path_pngquant = "pngquant";
$status_code = null;
$image = null;
$output = null;
$image_input_escaped = escapeshellarg('test.png');
$command = "$path_pngquant --strip -- - < $image_input_escaped";
// Execute the command
exec($command, $output, $status_code);
if($status_code == 0)
{
//0 means success
$image = implode('', $output);
file_put_contents('test_2.png', $image);
}