You can convert a png image to jpg in Python using OpenCV by following the given steps. I highly recommend you get the “Computer Vision: Models, Learning, and Inference Book” to learn Computer Vision.
Import the OpenCV library. If OpenCV is not installed in your system, then install it using This Method.
Now read the image from the location. In my case “C:\\AiHints” is the location and “cat.png” is the name of the image. Change it according to your image location and name.
image = cv2.imread("C:\\AiHints\\cat.png") #imread is use to read an image from a location
This code will convert the above png image into jpg and will save it at the location “C:\\AiHints”.
waitKey() open the image for a specific time in milliseconds until you press any key. “destroyAllWindows()” will destroy all the windows that we created.