Can I use an image file provided by the player as a texture?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By unfa

I’d like to allow a player to load a custom texture from their local storage.
I’d also need to know the dimensions of the file so I can map it to assure proper aspect ratio.

:bust_in_silhouette: Reply From: Zylann

You can if you get access to the path to that file, but I’m not sure that getting the path will work the same on platforms where filesystem access is restricted.

Once you get the file, you can do something like this:

var im =
var err = im.load(path)
if err != OK:
	print("Could not load image file")

var tex =
tex.create_from_image(im, Texture.FLAGS_DEFAULT)