Loading a Image via code

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

So basically I want to do loading images via code, there will a lot of them, so I want to know exactly what is going, in terms of storage, what format they are stored in, what gives best optimization memory wise.

I’ve did several experimentation, but it is still unclear how to yield results. For example this piece of code design to load image resources:

func loading_resource(path):
	for ext in ResourceLoader.get_recognized_extensions_for_type("ImageTexture"):
		if path.extension() == ext:
			var texture = ImageTexture.new();
			var image = Image();
			image.load(path);
			texture.create_from_image(image,0);
			texture.set_storage(ImageTexture.STORAGE_COMPRESS_LOSSLESS);
			texture.set_path(path);
			texture.set_name(path.basename());
			resBank.add_resource(path,texture);
			return OK;
	return FAILED;

Another alternative would be to use texture.load(path) in that case. Either way I don’t seem to get any difference between type of compression, wether lossless, or lossy. It does however have a difference from just using a plain load(path), of about 40% in corresponding memory size.