An error from https://github.com/godotengine/godot/issues/2319 is occurring in Godot 3.0.2. This error does not occur when loading a tscn file.
ERROR: _load: No loader found for resource: user://icon.png
At: core/io/resource_loader.cpp:186.
I may be wrong here but isn't the problem here that loading an image like that when it's not imported by the editor doesn't work? The resource loader tries to load SteamTextures which don't exist for user://. You could try using ImageTexture I believe.
func load_jpg(file):
var jpg_file = File.new()
jpg_file.open(file, File.READ)
var bytes = jpg_file.get_buffer(jpg_file.get_len())
var img = Image.new()
var data = img.load_jpg_from_buffer(bytes)
var imgtex = ImageTexture.new()
imgtex.create_from_image(img)
jpg_file.close()
return imgtex
```
func load_png(file):
var png_file = File.new()
png_file.open(file, File.READ)
var bytes = png_file.get_buffer(png_file.get_len())
var img = Image.new()
var data = img.load_png_from_buffer(bytes)
var imgtex = ImageTexture.new()
imgtex.create_from_image(img)
png_file.close()
return imgtex
```
File is the path in this case, like
var img = "user://image.jpg"
texturebutton.normal = load_jpg(img)
duplicate: #17748 (#17848 is the new issue)
Yes, looks like a duplicate of #17848 indeed. Closing.
Most helpful comment
```
func load_png(file):
```
File is the path in this case, like