Open and save
Image.open, convert, and save with an explicit format.
python -m pip install pillow
from PIL import Image
im = Image.open("input.jpg")
print(im.size, im.mode)
im.convert("RGB").save("output.png")Always convert to RGB before saving JPEG; RGBA will fail. size is width, height in pixels. Close files in long batch jobs or use a context manager so you do not leak handles on Windows.