You can convert a JPG image to JPEG 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.jpg” is the name of the image. Change it according to your image location and name.
image = cv2.imread("C:\\AiHints\\cat.jpg") #imread is use to read an image from a location
This code will convert the above jpg image into a jpeg 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.