Create new image in Python | PIL.Image.new() method

You can create a new image in Python using PIL library’s Image.new() method.

Syntax:

Image.new(mode, size, color)

Parameters:
mode – type of pixel (RGB, HSV etc). Check the modes supported by Python

size – a tuple, (width, height) in pixels

color – color of the new image. default is black (=0).

Example#1

Creating an image of 600×800 size, RGB type

from PIL import Image

newImage = Image.new('RGB', (600, 800), color=0) # with default black color
newImage.show()

Also See: How to download Instagram Images using Python?


About the Author

SRINI S

A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps

Leave a Reply

Your email address will not be published. Required fields are marked *