Converting a CompressedTexture from load() into an Image in v4?

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

I can use Image.load() successfully but get a warning:

WARNING: Loaded resource as image file, this will not work on export: ‘res://art/menu/screenshot-logo-bottom.png’. Instead, import the image file as an Image resource and load it normally as a resource.

When I try to workaround this, using load(), it returns a CompressedTexture object.

But how to convert that into an Image?

Or, is there a better way than load()?

:bust_in_silhouette: Reply From: AlexTheRegent

You can convert CompressedImage2D (and any texture that inherits Texture2D) using get_image method (Texture2D — Godot Engine (stable) documentation in English). Note that each time you call this method new Image is created (this method is not cached).