Hello! I am currently previewing the levels of my game in the menu using a viewport capture. However, the game has a level editor and whenever a level is edited, I take a new screenshot and save it in the file system with the same name. I then replace the sprite with the new image by loading it. Unfortunately, the image only updates after I close and reopen the game. I am unsure if Godot keeps images in the cache or if there is another issue at play. Does anyone have any suggestions for resolving this?

$SubViewport.get_texture().get_image().save_png(singleton.capture_path + ".png")
level_image.texture_normal = load(singleton.capture_path + ".png")

Resources (that includes images) are cached. I don't think that there is an explicit way to drop a cached resource.

You could try to remove all references to the old image before you save the new one. But I am not sure if that would work.

Why not just load the texture directly? Then you can reload it normally when you restart.

var tex = $SubViewport.get_texture()
level_image.texture_normal = tex
tex.get_image().save_png(singleton.capture_path + ".png")