def METHOD_NAME(self, context, _event):
    import os
    sd = context.space_data
    try:
        image = sd.image
    except AttributeError:
        self.report({'ERROR'}, "Context incorrect, image not found")
        return {'CANCELLED'}
    if image.packed_file:
        self.report({'ERROR'}, "Image is packed, unpack before editing")
        return {'CANCELLED'}
    if sd.type == 'IMAGE_EDITOR':
        filepath = image.filepath_from_user(image_user=sd.image_user)
    else:
        filepath = image.filepath
    filepath = bpy.path.abspath(filepath, library=image.library)
    self.filepath = os.path.normpath(filepath)
    self.execute(context)
    return {'FINISHED'}