You just need imagepng()
then. In fact it almost becomes a one-liner:
imagepng(imagecreatefromstring(file_get_contents($filename)), "output.png");
You would use $_FILES["id"]["tmp_name"]
for the filename, and a different output filename obviously. But the image format probing itself would become redundant.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…