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.open() Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the load() method). See new().
Syntax: PIL.Image.open(fp, mode=’r’)
fp – A filename (string), pathlib.Path object or a file object. The file object must implement read(), seek(), and tell() methods, and be opened in binary mode.
mode – The mode. If given, this argument must be “r”.
Returns type: An image object.
Raises: IOError – If the file cannot be found, or the image cannot be opened and identified.
Output:.JPG extension image open.
Another Example: Here we used .PNG extension file.
Output:.PNG extension image open.
- Difference between Method Overloading and Method Overriding in Python
- class method vs static method in Python
- Python | set() method
- Python | os.dup() method
- Python | next() method
- Python | os.fstatvfs() method
- Python | setattr() method
- Python | os.statvfs() method
- Python PIL | getbands() method
- Python | bytes() method
- Python | PyTorch tan() method
- Python | Tensorflow sin() method
- Python | os.WIFSIGNALED() method
- Python | iter() method
- Python | os.WSTOPSIG() method
- Python | os.WIFCONTINUED() method
- Python | hash() method
- Python | os.fsdecode() method
- Python | cmath.log() method
- Python | cmath.exp() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.