Chapter 22: Advanced Python Programming - Using the Pillow Library to Edit Images
            22.1 Introduction  Image processing is a common requirement in many Python applications, including automation, web development, and data science. The Pillow  library—an easy-to-use fork of the Python Imaging Library (PIL)—offers powerful tools for image manipulation such as resizing, cropping, filtering, and format conversion.  This chapter provides a practical introduction to Pillow, explaining its installation, basic operations, and advanced image editing techniques with code examples.   22.2 Installing Pillow  To install Pillow, use the Python package installer:  pip install Pillow  You can now import the library using:  from PIL import Image   22.3 Opening and Displaying Images  Opening an Image  from PIL import Image  img = Image.open("example.jpg") img.show()  Getting Image Information  print(img.format)       # JPEG, PNG, etc. print(img.size)         # (width, height) print(img.mode)         # RGB, L (grayscale), etc.   22.4 Saving Images  You can save an i...