Deprecate fromarray mode argument by radarhere · Pull Request #9018 · python-pillow/Pillow
I have a numpy array of shape (h, w, 3) which contains YCbCr data. For instance, a single blue pixel might be
a = np.array([[[30, 255, 107]]], dtype=np.uint8)
I want to convert this to RGB:
ycbcrimg = PIL.Image.fromarray(a, 'YCbCr') ycbcrimg.convert('RGB').getpixel((0, 0))
yields (0, 1, 255) (our blue pixel).
It looks like I can do
ycbcrimg = PIL.Image.frombuffer('YCbCr', (a.shape[1], a.shape[0]), a.tobytes(), 'raw', 'YCbCr', 0, 1)
but that seems cumbersome compared to the now deprecated PIL.Image.fromarray(a, 'YCbCr'), and I was wondering if there was an alternative preferred idiom for this.