Based on what kind of image it is you could select the correct function to open the file. Then, you just need imagepng() to convert.
Example:
$ori_ext = strtolower("Your upload file extension"); if( $ori_ext != 'png' ) { switch( $ori_ext ) { case 'jpg': case 'jpeg': $new_img = imagecreatefromjpeg("Your image file path"); break; case 'gif': $new_img = imagecreatefromgif("Your image file path"); break; } //set the new file name and path $final_file = $new_path . "/new_file.png"; imagepng($new_img, $final_file); }
What do you think?