Possible Duplicate of
Convert jpg image to gif, png & bmp format using PHP
You just need
imagepng() then. In fact it almost becomes a one-liner:
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.