user: Show practical ways to work with SpaceImageEditor(Space) in a Blender add-on or script – include code.

assistant: # SpaceImageEditor(Space)

base classes — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct"), [`Space`](bpy.types.Space.html#bpy.types.Space "bpy.types.Space")

*class* bpy.types.SpaceImageEditor(*Space*)
:   Image and UV editor space data

    annotation
    :   Annotation data for this space

        Type:
        :   [`Annotation`](bpy.types.Annotation.html#bpy.types.Annotation "bpy.types.Annotation")

    blend_factor
    :   Overlay blending factor of rasterized mask

        Type:
        :   float in [0, 1], default 0.0

    cursor_location
    :   2D cursor location for this view

        Type:
        :   [`mathutils.Vector`](mathutils.html#mathutils.Vector "mathutils.Vector") of 2 items in [-inf, inf], default (0.0, 0.0)

    display_channels
    :   Channels of the image to display

        - `COLOR_ALPHA`
          Color & Alpha – Display image with RGB colors and alpha transparency.
        - `COLOR`
          Color – Display image with RGB colors.
        - `ALPHA`
          Alpha – Display alpha transparency channel.
        - `Z_BUFFER`
          Z-Buffer – Display Z-buffer associated with image (mapped from camera clip start to end).
        - `RED`
          Red.
        - `GREEN`
          Green.
        - `BLUE`
          Blue.

        Type:
        :   enum in [`'COLOR_ALPHA'`, `'COLOR'`, `'ALPHA'`, `'Z_BUFFER'`, `'RED'`, `'GREEN'`, `'BLUE'`], default `'COLOR'`

    image
    :   Image displayed and edited in this space

        Type:
        :   [`Image`](bpy.types.Image.html#bpy.types.Image "bpy.types.Image")

    image_user
    :   Parameters defining which layer, pass and frame of the image is displayed

        Type:
        :   [`ImageUser`](bpy.types.ImageUser.html#bpy.types.ImageUser "bpy.types.ImageUser"), (readonly, never None)

    mask
    :   Mask displayed and edited in this space

        Type:
        :   [`Mask`](bpy.types.Mask.html#bpy.types.Mask "bpy.types.Mask")

    mask_display_type
    :   Display type for mask splines

        - `OUTLINE`
          Outline – Display white edges with black outline.
        - `DASH`
          Dash – Display dashed black-white edges.
        - `BLACK`
          Black – Display black edges.
        - `WHITE`
          White – Display white edges.

        Type:
        :   enum in [`'OUTLINE'`, `'DASH'`, `'BLACK'`, `'WHITE'`], default `'OUTLINE'`

    mask_overlay_mode
    :   Overlay mode of rasterized mask

        - `ALPHACHANNEL`
          Alpha Channel – Show alpha channel of the mask.
        - `COMBINED`
          Combined – Combine space background image with the mask.

        Type:
        :   enum in [`'ALPHACHANNEL'`, `'COMBINED'`], default `'ALPHACHANNEL'`

    mode
    :   Editing context being displayed

        Type:
        :   enum in [Space Image Mode All Items](bpy_types_enum_items/space_image_mode_all_items.html#rna-enum-space-image-mode-all-items), default `'VIEW'`

    overlay
    :   Settings for display of overlays in the UV/Image editor

        Type:
        :   [`SpaceImageOverlay`](bpy.types.SpaceImageOverlay.html#bpy.types.SpaceImageOverlay "bpy.types.SpaceImageOverlay"), (readonly, never None)

    pivot_point
    :   Rotation/Scaling Pivot

        - `BOUNDING_BOX_CENTER`
          Bounding Box Center – Pivot around bounding box center of selected object(s).
        - `CURSOR`
          3D Cursor – Pivot around the 3D cursor.
        - `INDIVIDUAL_ORIGINS`
          Individual Origins – Pivot around each object’s own origin.
        - `MEDIAN_POINT`
          Median Point – Pivot around the median point of selected objects.
        - `ACTIVE_ELEMENT`
          Active Element – Pivot around active object.

        Type:
        :   enum in [`'BOUNDING_BOX_CENTER'`, `'CURSOR'`, `'INDIVIDUAL_ORIGINS'`, `'MEDIAN_POINT'`, `'ACTIVE_ELEMENT'`], default `'BOUNDING_BOX_CENTER'`

    sample_histogram
    :   Sampled colors along line

        Type:
        :   [`Histogram`](bpy.types.Histogram.html#bpy.types.Histogram "bpy.types.Histogram"), (readonly)

    scopes
    :   Scopes to visualize image statistics

        Type:
        :   [`Scopes`](bpy.types.Scopes.html#bpy.types.Scopes "bpy.types.Scopes"), (readonly)

    show_annotation
    :   Show annotations for this view

        Type:
        :   boolean, default False

    show_gizmo
    :   Show gizmos of all types

        Type:
        :   boolean, default False

    show_gizmo_navigate
    :   Viewport navigation gizmo

        Type:
        :   boolean, default False

    show_mask_overlay
    :   Type:
        :   boolean, default False

    show_mask_spline
    :   Type:
        :   boolean, default False

    show_maskedit
    :   Show Mask editing related properties

        Type:
        :   boolean, default False, (readonly)

    show_paint
    :   Show paint related properties

        Type:
        :   boolean, default False, (readonly)

    show_region_asset_shelf
    :   Display a region with assets that may currently be relevant (such as brushes in paint modes, or poses in Pose Mode)

        Type:
        :   boolean, default False

    show_region_hud
    :   Type:
        :   boolean, default False

    show_region_tool_header
    :   Type:
        :   boolean, default False

    show_region_toolbar
    :   Type:
        :   boolean, default False

    show_region_ui
    :   Type:
        :   boolean, default False

    show_render
    :   Show render related properties

        Type:
        :   boolean, default False, (readonly)

    show_repeat
    :   Display the image repeated outside of the main view

        Type:
        :   boolean, default False

    show_sequencer_scene
    :   Display the render result for the sequencer scene instead of the active scene

        Type:
        :   boolean, default False

    show_stereo_3d
    :   Display the image in Stereo 3D

        Type:
        :   boolean, default False

    show_uvedit
    :   Show UV editing related properties

        Type:
        :   boolean, default False, (readonly)

    ui_mode
    :   Editing context being displayed

        - `VIEW`
          View – Inspect images or render results.
        - `PAINT`
          Paint – Paint images in 2D.
        - `MASK`
          Mask – View and edit masks.

        Type:
        :   enum in [`'VIEW'`, `'PAINT'`, `'MASK'`], default `'VIEW'`

    use_image_pin
    :   Display current image regardless of object selection

        Type:
        :   boolean, default False

    use_realtime_update
    :   Update other affected window spaces automatically to reflect changes during interactive operations such as transform

        Type:
        :   boolean, default False

    uv_editor
    :   UV editor settings

        Type:
        :   [`SpaceUVEditor`](bpy.types.SpaceUVEditor.html#bpy.types.SpaceUVEditor "bpy.types.SpaceUVEditor"), (readonly, never None)

    zoom
    :   Zoom factor

        Type:
        :   float array of 2 items in [-inf, inf], default (0.0, 0.0), (readonly)

    zoom_percentage
    :   Zoom percentage

        Type:
        :   float in [0.4, 80000], default 100.0

    *classmethod* bl_rna_get_subclass(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The RNA type or default when not found.

        Return type:
        :   [`bpy.types.Struct`](bpy.types.Struct.html#bpy.types.Struct "bpy.types.Struct") subclass

    *classmethod* bl_rna_get_subclass_py(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The class or default when not found.

        Return type:
        :   type

    *classmethod* draw_handler_add(*callback*, *args*, *region_type*, *draw_type*)
    :   Add a new draw handler to this space type.
        It will be called every time the specified region in the space type will be drawn.
        Note: All arguments are positional only for now.

        Parameters:
        :   - **callback** (*Callable**[**...**,* *Any**]*) – A function that will be called when the region is drawn.
              It gets the specified arguments as input, it’s return value is ignored.
            - **args** (*tuple**[**Any**,* *...**]*) – Arguments that will be passed to the callback.
            - **region_type** (*str*) – The region type the callback draws in; usually `WINDOW`. ([`bpy.types.Region.type`](bpy.types.Region.html#bpy.types.Region.type "bpy.types.Region.type"))
            - **draw_type** (*str*) – Usually `POST_PIXEL` for 2D drawing and `POST_VIEW` for 3D drawing. In some cases `PRE_VIEW` can be used. `BACKDROP` can be used for backdrops in the node editor.

        Returns:
        :   Handler that can be removed later on.

        Return type:
        :   object

    *classmethod* draw_handler_remove(*handler*, *region_type*)
    :   Remove a draw handler that was added previously.

        Parameters:
        :   - **handler** (*object*) – The draw handler that should be removed.
            - **region_type** (*str*) – Region type the callback was added to.