Image Converter Error

I am running Python on the Pycharm Community Edition and I have attempted at writing an JPG converter for my own needs. However, doing so resulted in this one recurring error:

  File "C:\Users\Anonymous\PycharmProjects\IMG_converter_gui\", line 7, in <module>
    import_img =
  File "C:\Users\Anonymous\PycharmProjects\IMG_converter_gui\venv\Lib\site-packages\PIL\", line 3218, in open
    fp =, "rb")
OSError: [Errno 22] Invalid argument: "'C:\\\\TEST\\\\IMG_5073.HEIC'"

I have searched through numerous sites such as stack overflow to see if anyone else has encountered this error but I have reached a dead end. This is what the code looks like.

from PIL import Image

input_import_img_path = input("""\nImport Image Path:
import_img_path = repr(input_import_img_path)  # repr() is there as a substitute for the 'r' string.
import_img =

input_export_img_path = input("""\nExport Image Path:
export_img_path = repr(input_export_img_path), format="JPG")

Hi Kimitsu, the problem starts here indicating that it can’t understand how to open the file… That’s why you are getting the OSError invalid argument

from the look of things it seems that repr() is adding additional single quotes to the file path whcih could be the cause of the error, can you try to provide the file path without the single quotes so comment out or remove the two lines with repr() method… run it and lemme know

So I have removed repr() and now the results are the same but the file path string has additional slashes.

Traceback (most recent call last):
  File "C:\Users\Anonymous\PycharmProjects\IMG_converter_gui\", line 6, in <module>
    import_img =
  File "C:\Users\Anonymous\PycharmProjects\IMG_converter_gui\venv\Lib\site-packages\PIL\", line 3280, in open
    raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file 'C:\\TEST\\IMG_5073.HEIC'

The result is not the same.

Originally, it was complaining about the path, but now it’s complaining about the file: it doesn’t recognise HEIC files.

A quick search showed that there’s a Python package called pillow-heif for reading such files.

Hey, so just as the error is shouting it doesn’t know how to open the file format. I must say its my debut to hear of this file format lol… nywy use another library to handle the format… install pyheif library and check this out for guidance,to%20a%20file%20on%20disk
lemme know of your progress