Python PIL | Image.frombytes() Method Last Updated : 07 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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). Syntax: PIL.Image.frombytes(mode, size, data, decoder_name='raw', *args) Parameters: 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. Python3 1== # importing image object from PIL from PIL import Image # using tobytes data as raw for frombyte function tobytes = b'xd8\xe1\xb7\xeb\xa8\xe5 \xd2\xb7\xe1' img = Image.frombytes("L", (3, 2), tobytes) # creating list img1 = list(img.getdata()) print(img1) Output: [120, 100, 56, 225, 183, 235] Another Example: Here we use different raw in tobytes. Python3 1== # importing image object from PIL from PIL import Image # using tobytes data as raw for frombyte function tobytes = b'\xbf\x8cd\xba\x7f\xe0\xf0\xb8t\xfe' img = Image.frombytes("L", (3, 2), tobytes) # creating list img1 = list(img.getdata()) print(img1) Output: [191, 140, 100, 186, 127, 224] Comment More infoAdvertise with us Next Article Python PIL | Image.crop() method S Sunitamamgai Follow Improve Article Tags : Python Python-pil Practice Tags : python Similar Reads Python PIL | Image.frombuffer() 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, 2 min read Python PIL | Image.crop() method PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. PIL.Image.crop() method is used to crop a rectangular portion of any image. Syntax: PIL.Image.crop(box = None)Parameters: box - a 4-tuple defining the left, upper, right, and lower pixel coordin 2 min read Python PIL | Image.draft() 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, 2 min read Python PIL | Image.convert() 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, 2 min read Python PIL Attributes | Image.width 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, 1 min read Python PIL Attributes | Image.height 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, 1 min read Like