Quick answer: The warning means you called Image.load() or Image.load_from_file() on a res:// file that Godot has imported. It works in the editor because the PNG is on disk, and fails in an exported game because only the imported .ctex is packed. Use load("res://file.png") for a texture, add .get_image() when you need pixels, or set the file to import as an Image.

This is one of the few Godot messages that tells you about a bug before it happens. Your scene runs, the image shows up, and a yellow line in the debugger says it will stop working once you export. It is right, and the exported build gives you far less to go on: a blank sprite or a null reference with no mention of images at all. The fix is a one-line change, but which line depends on whether you want a texture, pixel data, a player’s own file, or the raw bytes. This guide covers each case, plus the folder-scanning trap that comes from the same cause.

The exact warning

W 0:00:01:0312   load: Loaded resource as image file, this will not work on export: 'res://maps/heightmap.png'. Instead, import the image file as an Image resource and load it normally as a resource.
  <C++ Source>   core/io/image.cpp:NNNN @ load()
  <Stack Trace>  terrain.gd:12 @ _ready()

It appears in Debugger > Errors as a yellow warning and in the Output panel. The source line number differs between Godot versions. Two calls raise it: Image.load(path) on an existing Image, and the static Image.load_from_file(path). Both check the same thing: the path starts with res:// and points at a file Godot treats as a resource.

The check is compiled into the editor and debug export templates only. A release export prints no warning. The load just fails.

Why it works in the editor and fails in an export

When you add heightmap.png to a project, Godot imports it. It writes a converted copy (a .ctex file in Godot 4, under res://.godot/imported/) and a small heightmap.png.import file beside the original that records the settings and where the converted copy lives. load("res://maps/heightmap.png") does not read the PNG. It follows the .import file to the converted texture.

Image.load() skips all of that and opens the path as a plain file. In the editor the PNG is sitting in your project folder, so it succeeds. An exported game contains the converted texture and the .import file, and the source PNG is left out. The same call now opens a file that is not there.

What a player sees depends on the call:

Neither failure names the image. The log shows a file-open error and then whatever broke afterwards, which is why this is much cheaper to fix while the warning is still on screen. Godot 3 behaves the same way with its .import/ folder and .stex files.

How to find the call and pick a fix

The Stack Trace line in the warning gives the script and line. To find every instance before it bites, search the project (Ctrl + Shift + F) for load_from_file( and for .load("res://, and include the addons folder. Then decide what the image is for:

What the code needsUse
A texture to drawload() or preload()
Pixel values from a game assetload(path).get_image(), or import the file as an Image
A file the player or the game created at run timeImage.load_from_file() with a user:// or absolute path
The original file bytes, shipped with the gameImport as Keep File, then FileAccess

Fix 1: you only need a texture

This is the usual case: code copied from a tutorial that loads an image and wraps it in an ImageTexture.

# Broken in an exported game
var img := Image.new()
img.load("res://ui/portrait.png")
$Portrait.texture = ImageTexture.create_from_image(img)
# Fixed
$Portrait.texture = load("res://ui/portrait.png")

# or, when the path is fixed at edit time
$Portrait.texture = preload("res://ui/portrait.png")

load() returns the imported texture as a Texture2D, with the compression and mipmap settings you chose in the Import dock. Paths built at run time work the same way, for example load("res://ui/portraits/%s.png" % character_id), as long as the file is in the project and your export preset includes it. The default export mode includes every resource.

Fix 2: you need the pixels

Heightmaps, collision masks, level layouts drawn as images and colour lookups all read individual pixels. Load the texture and ask it for its image:

var tex: Texture2D = load("res://maps/heightmap.png")
var img: Image = tex.get_image()
if img.is_compressed():
    img.decompress()

var height := img.get_pixel(x, y).r

Three details matter here:

Fix 3: import the file as an Image

This is the route the warning itself names. If a file is only ever read as data, tell Godot to import it as an Image resource:

  1. Select the file in the FileSystem dock.
  2. In the Import dock, change Import As from Texture2D to Image.
  3. Click Reimport.
var img: Image = load("res://maps/heightmap.png")
var height := img.get_pixel(x, y).r

Now load() hands back an Image directly, with no trip through the renderer and no compression to undo. The trade-off is that the file is no longer a texture: you cannot drop it into a Sprite2D in the Inspector. If you also need to draw it, build the texture yourself with ImageTexture.create_from_image(img).

Fix 4: the file is not part of the game

Image.load_from_file() exists for files that are not project resources: screenshots, player avatars, mod content, anything under user:// or an absolute path. Those paths never trigger the warning, and they work identically in the editor and in an export.

var img := Image.load_from_file("user://screenshots/shot_001.png")
if img == null:
    push_error("Could not read the screenshot")
    return
$Preview.texture = ImageTexture.create_from_image(img)

Check the result every time. A file the player deleted or a truncated download is a normal event for this kind of path. For an image that arrives over HTTP, skip the file and decode the bytes with load_png_from_buffer() or load_jpg_from_buffer().

Fix 5: you must ship the original file

Sometimes the code really does need the untouched bytes: a sample folder for modders, a file a native library parses, a file you hash. Stop Godot from converting it:

  1. Select the file, open the Import dock.
  2. Set Import As to Keep File (exported as is). Earlier 4.x releases label it Keep File (No Import).
  3. Click Reimport.

The original is now packed into the export. Read it as bytes and decode it:

var bytes := FileAccess.get_file_as_bytes("res://mods/sample/icon.png")
var img := Image.new()
var err := img.load_png_from_buffer(bytes)
if err != OK:
    push_error("icon.png could not be decoded: %d" % err)

This is a separate mechanism from the export preset’s Resources > Filters to export non-resource files/folders box. That filter is for file types Godot does not import at all, such as .json or .txt. Adding *.png there does not help with a PNG that is still being imported as a texture. See data files missing in an exported game for that side of the problem.

The same trap when you list a folder

Code that scans a directory for images breaks for the same reason. In an exported game, DirAccess does not see portrait.png. It sees portrait.png.import. A loop that looks for names ending in .png finds every file in the editor and none in the build.

func load_textures(dir_path: String) -> Array[Texture2D]:
    var out: Array[Texture2D] = []
    var seen := {}
    for file in DirAccess.get_files_at(dir_path):
        file = file.trim_suffix(".import")
        if file.ends_with(".png") and not seen.has(file):
            seen[file] = true
            out.append(load(dir_path.path_join(file)))
    return out

Stripping the suffix gives the original name, which load() resolves in both environments. The seen dictionary matters in the editor, where both the PNG and its .import file are listed. Godot 4.4 added ResourceLoader.list_directory(), which returns the original resource names without this workaround.

How to confirm the fix

Run the scene in the editor and check that Debugger > Errors no longer shows the warning. Then test the thing the warning was predicting: export the project and run the exported build, not the editor. Export with debug first, because a debug build still prints the warning and gives readable script errors. Walk through every screen that loads images from code, then open the log and look for file-open errors. The log locations are in where Godot writes godot.log on each platform.

Make the exported build part of your routine before each release. The editor runs with the whole project folder on disk, so any code that reads res:// as ordinary files will pass there and fail for players.

What Bugnet reports when this reaches players

A release export does not print this warning, so no tool can report it from a player’s machine. What exists there is the consequence: the file-open error in the log, then the script error on the line that used the empty image. The Bugnet Godot SDK files the errors the engine logs, with the recent log lines attached, so both lines arrive together and the image path is in the report. Automatic capture reads the engine’s log file, which means File Logging has to be enabled, and it is off by default on mobile exports. If the missing image only produces a blank sprite and no error, nothing is filed automatically. That case reaches you when a player uses the in-game report form, with a screenshot and their game version attached.

Frequently asked questions

What does “Loaded resource as image file, this will not work on export” mean in Godot?

Your code called Image.load or Image.load_from_file on a res:// file that Godot imports as a resource. That reads the original PNG, which exists in the editor but is not packed into an exported game, so the same call fails for players.

How do I load an image from res:// correctly in Godot 4?

Use load or preload with the res:// path. That returns the imported texture as a Texture2D. If you need pixel data, call get_image on the texture, or change the file’s Import As setting to Image so that load returns an Image directly.

Why does my image load in the editor but not in the exported game?

The editor runs with your project folder on disk, so the source PNG is there. The export only contains the imported texture file and the .import file that points to it. Code that opens the PNG as a plain file finds nothing in the export.

Is Image.load_from_file safe to use at all?

Yes, for files that are not project resources: screenshots, downloaded images, mod content, anything under user:// or an absolute path. The warning only fires for res:// paths that Godot has imported. Always check the result for null.

Why does get_pixel fail on an image from a texture?

The texture was imported with VRAM compression, and pixel reads do not work on compressed data. Call decompress on the image first, or set the file’s Compress Mode to Lossless in the Import dock, which also keeps the pixel values exact.

The editor always has your source files on disk, so it cannot tell you what an export is missing. Run the exported build before every release, and treat this warning as a failed test.