Hey there! Was having an issue sending the alpha channel from a TOP into ComfyUI's workflow. I made a small change to the imagetobytes function in the TdcomfyEXT script to achieve this.
def imagetobytes(self, img):
image = img.numpyArray(delayed=False)*255
image = np.flipud(image).astype(np.uint8)
# Check if the image has an alpha channel
if image.shape[2] == 4:
image = cv.cvtColor(image, cv.COLOR_BGRA2RGBA)
else:
image = cv.cvtColor(image, cv.COLOR_BGR2RGB)
imageData = cv.imencode('.png', image)[1].tobytes()
init_image = str(base64.b64encode(imageData), "utf-8")
return init_image
This checks the numpyArray to see if it has an alpha channel, and if so makes sure to use BGRA2RGBA instead of the BGR2RGB conversion. Thanks a bunch for this!
Hey there! Was having an issue sending the alpha channel from a TOP into ComfyUI's workflow. I made a small change to the imagetobytes function in the TdcomfyEXT script to achieve this.
This checks the numpyArray to see if it has an alpha channel, and if so makes sure to use BGRA2RGBA instead of the BGR2RGB conversion. Thanks a bunch for this!