I am trying to display a photoshop image in PyQt. I have been using the python imageio module to load images and through a series of steps convert them to a QImage as below. This works for many different things such as .exr, .hdr, etc. However when trying to load a .psd I get strange results like rainbow colors all over the place and a lot of noise. It seems that something is going wrong within the conversion process, but I cannot find enough documentation online from FreeImage, ImageIO or PIL to explain what is going wrong.
Here's a simple example of the conversion process I am using:
import os
from PIL import Image
from PyQt5 import QtGui
import imageio, numpy
path = 'path/to/image.psd'
imio = imageio.imread(path)
imio_np = numpy.uint8(imio) # convert from 16bpc to 8bpc
im = Image.fromarray(imio_np)
im.convert('RGB')
data = im.tobytes('raw', 'RGB')
qim = QtGui.QImage(data, im.size[0], im.size[1], QtGui.QImage.Format_RGB888)
# then just apply that qim to a QLabel
Ok turns out this is easier than I thought. I found the answer here: Convert 16-bit Tiff image to 8-bit RGB. The problem was just converting from 16bpc to 8bpc, and I'll post that here in case anyone else has this issue.