Error: Loaded resource as image file, this will not work on export

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

Hello !
I imported several images to the project (just drugged some jpg to folder in environment).
I want to load one of them to the TextureRect (for instance).
Godot 3.1
Very simple code:

extends TextureRect
func _ready():
	load_image()

func load_image():
	var texture = ImageTexture.new()
	texture.load("res://Images/myPic.jpg")
	self.texture = texture

In godot it works but I getting this error:

Loaded resource as image file, this will not work on export:
‘res://Images/myPic.jpg’. Instead, import the image file as an Image
resource and load it normally as a resource.

What am I doing wrong ?
How should I load these pictures from the code ?

:bust_in_silhouette: Reply From: MasterBor

The answer I found here.
And the solution for the problem:

func load_image():
    self.texture = load("res://Graphics/myPic.png")

That’s all. So simple :slight_smile:

This works for me, thanks a lot.

Mostafa Karamizade | 2020-04-20 20:05