$width) { $rapport = $size[0] / $width; $height = $size[1] / $rapport; } else { $width = $size[0]; $height = $size[1]; } $img_src = imagecreatefrompng($src); $img_dst = imagecreatetruecolor($width, $height); // Preserve alpha transparency : thank crash imagecolortransparent($img_dst, imagecolorallocate($img_dst, 0, 0, 0)); imagealphablending($img_dst, false); imagesavealpha($img_dst, true); $res = imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); if (!$res) { return false; } $res = imagepng($img_dst, $dest); if (!$res) { return false; } return true; }