# How to load and display an image in the image editor using python?

How could I load an external image and display it in Image Editor automatically? Basically the same as when rendering an image and displaying the Render Result.

I'm already able to load the image programatically. However, I don't get how to display the image in the Image Editor.

If the image editor is used in one of the visible areas of the current workspace, you can iterate through bpy.context.screen.areas to find the one with type IMAGE_EDITOR. The image that is shown in the editor can be set through the space of the area.

An image can be loaded through bpy.data.images.load().

import bpy

img = bpy.data.images["Render Result"]