def _condense(img):
"""PNG image is returned as 3 bands representing RGB on each plane.
Flattens into 1 plane array with each (R,G,B) value represented as RGB.
"""
im = [band.tobytes() for band in img.split()]
band_fmt = 'c'
band_iter = [struct.iter_unpack(band_fmt, split_im) for split_im in im]
comb = []
for val in band_iter[0]:
val_2 = next(band_iter[1])
val_3 = next(band_iter[2])
comb.append(b''.join([*val, *val_2, *val_3]))
return comb
评论列表
文章目录