I'm trying to convert an image to cmyk array and write those array to a text file. When I read from the same file and try to display it, error appears. I think I did some error but I can't found the solution. Code below:
from PIL import Image
import numpy as np
imgs = Image.open('rgb.jpg').convert('CMYK')
imgs_image = np.array(imgs)
str2 =str(imgs_image)
f=open("rgb_real_cmyk.txt","w")
f.write(str2)
f.close()
fh = open("rgb_real_cmyk.txt","r")
string=fh.read()
file_image = np.array(string)
file_test = Image.fromarray(file_image, mode='CMYK')
file_test.save("file_image.jpeg")
Error:
"in fromarray size = shape[1], shape[0]
IndexError: tuple index out of range"