How can you load an external .jpg or .png file

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

Hey Guys!
I am trying to find a way of loading a extern image into Godot.
I found multiple discussions about more or less the same topic, but the examples I find are only for audio files and after a few hours of googeling, experimenting and reading the docs up an down, I just can’t get them to work with image files.

I know that there is no easy built-in function or anything like that in Godot right know, but for example in this thread someone is saying, importing a .png file is “simple enough”:

I hope somebody can help me, thank you in advance!

:bust_in_silhouette: Reply From: lewis glasgow
func _ready():
	var image = Image.new()
	image.load("image path")
	var t = ImageTexture.new()
	t.create_from_image(image)
	$Sprite.texture = t

Thank you but thats not what I meant.
Your code only works if Godot imported the Image already,.
I am searching for a solution that can import a Image, from a external source.

yukkitimmy | 2021-08-03 07:59

like a website or from another directory on the file manager like C://user:/Desktop/image.png

lewis glasgow | 2021-08-03 17:01

From another directory on the Drive, loading already imported Images works Just fine.

yukkitimmy | 2021-08-03 17:04

like this

lewis glasgow | 2021-08-03 22:28

Exactly! Would you be so kind and a share your Code?

yukkitimmy | 2021-08-04 15:51

funny enough its exactly the same as the answer but only difference is using the filedialog node as a path project file here

lewis glasgow | 2021-08-05 07:04

Your implementation still didn’t wotk for me :frowning: But still thank you a lot, for taking your time!
If anyone stumbles uppon this poblem, over on Reddit, someone suggested a solution that worked for me: Reddit - Dive into anything

yukkitimmy | 2021-08-07 09:36