def METHOD_NAME(self):
    if len(self.filepath.value) == 0:
        return
    with PIL.Image.open(self.filepath.value) as im:
        # convert image first, if it uses a color palette
        if im.mode == 'P':
            im = im.convert(mode=im.palette.mode)
        channels = len(im.getbands())
        # flip image upside down since Inviwo assumes OpenGL coordinates (origin at lower-left)
        im = im.transpose(PIL.Image.Transpose.FLIP_TOP_BOTTOM)
        # create numpy representation
        npImgData = np.array(im)
        # create a LayerPy representation
        layerpy = ivw.data.LayerPy(npImgData)
        # directly access the layer data as numpy array via `layerpy.data`
        # create a Layer from the representation
        layer = ivw.data.Layer(layerpy)
        swizzleDict = {
            1: ivw.data.SwizzleMask.luminance,
            2: ivw.data.SwizzleMask.luminanceAlpha,
            3: ivw.data.SwizzleMask.rgb,
            4: ivw.data.SwizzleMask.rgba
        }
        # set swizzle mask depending on the number of channels
        layer.swizzlemask = swizzleDict[channels]
        # finally, create an Image containing the layer
        ivwImg = ivw.data.Image(layer)
        self.outport.setData(ivwImg)
        # update properties for feedback
        self.imgdims.value = ivw.glm.ivec2(im.size)
        self.channels.value = channels