Convert Image to RGB and Grayscale using PIL

im = Image.open("audacious.png")
rgb_im = im.convert('RGB')
rgb_im.save('audacious.jpg')
from PIL import Image
img = Image.open('image.png').convert('LA')
img.save('greyscale.png')

LA mode has luminosity (brightness) and alpha. If you use LA mode, then greyscale.png will be an RGBA image with the alpha channel of image.png preserved. If you use L mode, then greyscale.png will be an RGB image (with no alpha).

References
https://stackoverflow.com/questions/48248405/cannot-write-mode-rgba-as-jpeg
https://stackoverflow.com/questions/12201577/how-can-i-convert-an-rgb-image-into-grayscale-in-python

Open Image in Python PIL

# Imports PIL module 
from PIL import Image 

# open method used to open different extension image file 
im = Image.open(r"C:\Users\System-Pc\Desktop\ybear.jpg") 

# This method will show image in any image viewer 
im.show() 
# Imports PIL module 
from PIL import Image 

# open method used to open different extension image file 
im = Image.open(r"C:\Users\System-Pc\Desktop\lion.png") 

# This method will show image in any image viewer 
im.show() 

References
https://www.geeksforgeeks.org/python-pil-image-open-method/

Take Screenshot using Python PIL

# Importing Image and ImageGrab module from PIL package 
from PIL import Image, ImageGrab 
  
# creating an image object 
im1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG") 
  
# using the grab method 
im2 = ImageGrab.grab(bbox = None) 
  
im2.show() 

Taking screenshots of specific size or taking screenshots from specific region

# Importing Image and ImageGrab module from PIL package 
from PIL import Image, ImageGrab 
  
# creating an image object 
im1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG") 
  
# using the grab method 
im2 = ImageGrab.grab(bbox =(0, 0, 300, 300)) 
  
im2.show() 

Parameters: box – The crop rectangle, as a (left, upper, right, lower)-tuple.

References
https://www.geeksforgeeks.org/pyhton-pil-imagegrab-grab-method/
https://stackoverflow.com/questions/19697210/taking-screen-shots-of-specific-size
https://stackoverflow.com/questions/47337811/what-do-the-parameters-of-bbox-mean-in-pillow