raise OSError(f"cannot write mode {mode} as PNG") from e OSError: cannot write mode F as PNG code example
Example: raise IOError("cannot write mode as PNG" mode
You need to convert the image to RGB mode.
Image.open('old.jpeg').convert('RGB').save('new.jpeg')