I am using PIL in python to combine images vertically and horizontally from dermen's answer in here. However, I am getting a warning:
/home/ceren/Documents/Python/combine_image.py:17: FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.
imgs_comb = np.hstack( (np.asarray( i.resize(min_shape) ) for i in imgs ) )
I am a python beginner, so I cannot quite understand what to do to resolve this issue. I thought [f2, f4, f5]
in the code is already a list. However, the warning says it is not?? I know it is not an essential thing to fix, but learning how to fix it would be nice.
What should I change in my code so that I do not receive that warning any further?
My code is below:
Inside main:
fcom1 = 'Image.png'
ci.combine_horizontal([f2, f4, f5], fcom1, date)
In image combining function:
def combine_horizontal(f, fcom, date):
list_im = f
imgs = [ PIL.Image.open(i) for i in list_im ]
min_shape = sorted( [(np.sum(i.size), i.size ) for i in imgs])[0][1]
imgs_comb = np.hstack( (np.asarray( i.resize(min_shape) ) for i in imgs )
imgs_comb = PIL.Image.fromarray( imgs_comb)
imgs_comb.save(fcom)