godot: Mono: Image.Load() doesn't recognize res:// outside of editor

Godot version: 3.0.6

OS/device including version: Windows 10

Issue description: Image.Load won’t accepted res:// path’s in exported projects, but works fine in editor. I was told image.load() wasn’t meant for res:// paths (which doesn’t make logical sense), so I’m assuming this method is broken or doesn’t explicitly state its correct usage in the method name.

Steps to reproduce:

  1. Create an asset
  2. Try loading it using
                var image = new Image();
                image.Load($"res://pathtoasset");
  1. Create an image texture
                var imageTexture = new ImageTexture();
                imageTexture.CreateFromImage(image, (int) Texture.FlagsEnum.Mipmaps);
  1. Add it to the scene
  2. Run scene to make sure it outputs
  3. Export project and watch the image not print to the screen because it can’t find the .png path

Minimal reproduction project: Will create one after ludum dare 42

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (21 by maintainers)

Most upvoted comments

Yes, those functions should be removed, they are confusing and error prone

On Mon, Aug 13, 2018, 21:11 PetePete1984 notifications@github.com wrote:

Update: Seems to also be the case for ImageTexture.load()

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/20972#issuecomment-412708370, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z25Ic5sG0siJCuLDWseDS91l1h8Zoks5uQhWWgaJpZM4V6j6p .

Please don’t remove Image.load, or you will piss off everyone loading non-resource images dynamically in their games and tools 😕

Use GD.Load and import the file as an image. Should probably unbind that and other functions, as it confuses users.

On Mon, Aug 13, 2018, 18:32 PetePete1984 notifications@github.com wrote:

To clarify a bit, Image.Load() seems to expect a path to a physical file: it works when the file is present while you’re running the project from the editor, but once you’re into exported virtual filesystem .pck territory, Image.Load doesn’t get redirected to the imported .stex files (the .png doesn’t exist in the .pck at that point). In contrast to that, GD.Load() explicitly tries to load a Resource and as such probably respects the virtual filesystem (ie it loads the .stex when you tell it to load the corresponding .png). Absolute or relative paths are irrelevant to the problem.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/20972#issuecomment-412672151, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z2zzlEcLrqfJ6cks1rCyNSdR-4Nxrks5uQfB-gaJpZM4V6j6p .