To convert a PNG file to a JPEG file in Python, we can use the Pillow library. Here is an example code:
main.py205 chars8 lines
In the code above, we first open the PNG file using the Image class from the Pillow library. Then, we save the image in JPEG format with the save() method, specifying the file name and format ('JPEG'), as well as the desired quality (80 in this case).
Note that the Pillow library needs to be installed before running the code. You can install it using pip:
main.py19 chars2 lines
gistlibby LogSnag