Python PIL | Image.frombytes() Method
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The
Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.
PIL.Image.frombytes() Creates a copy of an image memory from pixel data in a buffer. In its simplest form, this function takes three arguments (mode, size, and unpacked pixel data).
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Syntax: PIL.Image.frombytes(mode, size, data, decoder_name=’raw’, *args)
mode – The image mode. See: Modes.
size – The image size.
data – A byte buffer containing raw data for the given mode.
decoder_name – What decoder to use.
args – Additional parameters for the given decoder.
Returns: An Image object.
[120, 100, 56, 225, 183, 235]
Another Example: Here we use different raw in tobytes.
[191, 140, 100, 186, 127, 224]