0

I am trying to open a GIF file but it is coming up with a syntax error i do not understand. Does the image have to change to PNG / JPEG because i am trying to keep transparency which would be lost if i have to change the file type.

The Syntax Error i don't understand

I have tried to keep the image and open it with Turtle by using screen.addshape. That works for the image however i have had a problem with resizing the image so i am having to use the PIL library to open the images and then resize them

Cavan
  • 23
  • 4
  • 1
    Please, do not post errors as screenshots. Take the minute it needs to copy the message and type it here so other users might find your question (and perhaps a solution) based on the error message. – Twonky Jan 02 '20 at 18:09

2 Answers2

1

Image.open("your.gif") should work. However, the path is not the string you think it is. \ is the escape character. To type a \, you will need to use \\ in stead of \.

Thus Image.open("C:\Your\Path\to a funny\image.gif") becomes Image.open("C:\\Your\\Path\\to a funny\\image.gif") or Image.open(r"C:\Your\Path\to a funny\image.gif") (a raw string).

Pim
  • 850
  • 7
  • 17
0

Its String encoding of the file path which is causing the issue See: "Unicode Error "unicodeescape" codec can't decode bytes... Cannot open text files in Python 3

tomgalpin
  • 1,943
  • 1
  • 4
  • 12
  • It opens in Photos instead of in a python file, is there a way to make it so it opens in the actual python screen? For example to get the image to move locations on python screen. – Cavan Jan 02 '20 at 16:48