Page 1 of 1

DynamicImage translates path the wrong way

Posted: Sun Nov 14, 2021 3:00 pm
by DrVoom
I have a python variable that leads to an image.

Code: Select all

$ img = "D:\dir\image.jpg"
when i display the variable with

Code: Select all

e "[img]" 
all is looking fine - i get D:\dir\image.jpg

when i set it as an image with

Code: Select all

 image profile = "[img]"
and show it with

Code: Select all

 show profile 
i get
"Exception: DynamicImage u'[img]': could not find image. (u'D:\\dir\\image.jpg')

There are double \\'s in the Exception Statement. The image exists at that place. Any hints what newbie error i am making? Thanks!

Re: DynamicImage translates path the wrong way

Posted: Sun Nov 14, 2021 3:07 pm
by rayminator
it should look like this

Code: Select all

$ img = "images\dir\image.jpg"
you are including you hard driver directory in the code that other players don't have that drive letter

Re: DynamicImage translates path the wrong way

Posted: Sun Nov 14, 2021 4:26 pm
by drKlauz
Avoid using \ in paths, it is escape character in python. It is not obvious from your example, but if you use

Code: Select all

img = "D:\dir\bg.jpg"
print(img)
it will print "D:\dig.jpg", because \b is converted to backspace character. In this case img will be "D:\\dir\x08g.jpg"
Use / instead.