This post can help you convert a PNG to a JPG and GIF.
Step 1
Create a file image_converter.php.
This code shows all three parameters of the convert_image() function:
$convert_type => accepts string either png,jpg or gif.
$target_dir => it is the source as well as the target directory
$image_name => give the actual image name such as image1.jpg.
$image_quality => can be adjusted if you don’t want 100% quality.
Step 2
Create index.php to Upload the image.
Step 3
Create convert.php to convert the image. And make a folder in your directory name as uploads. Because when the image is uploaded or convert, the image will save on this folder.
Step 4
Create a download.php to downloads the converted image forcefully.
Step 5
Then, Run the index.php and see the view.

After uploading the image.

After converting the image.

Then, you can download or convert another image.