Project 3 Notes on Resizing Images with Python PIL

1. Vernon's Machine Vision book:

2. Pillow

3. for loops

4. glob.glob()

How to Use Image.resize()

  • Pass a tuple of (width, height) to the argument size.
  • Pass the filter for resample.
    Resampling Filters
    -NEAREST (which is used by default)
  • For images created by the library itself (via a factory function, or by running a method on an existing image), this attribute is set to None.
  • If the image was not read from a file, it is set to None.
  • Image size needs to be specified as integers.
In [1]:
import sys
'3.6.9 (default, Oct  8 2020, 12:12:24) \n[GCC 8.4.0]'
In [2]:
pip uninstall PIL
WARNING: Skipping PIL as it is not installed.
In [3]:
pip install Pillow==8.1.0
Requirement already satisfied: Pillow==8.1.0 in /usr/local/lib/python3.6/dist-packages (8.1.0)
In [4]:
import PIL
In [5]:
from google.colab import drive
Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force_remount=True).
In [6]:
import shutil
shutil.unpack_archive('/content/drive/My Drive/', '/content/drive/My Drive')
In [7]:
from PIL import Image
im ='/content/drive/My Drive/pallasite/Esquel.jpg')
print(im.format, im.size, im.mode)
JPEG (2736, 2014) RGB