PIL (Pillow) Module

from PIL import Image, ImageFilter
import os

imag = Image.open('xyz.jpeg')

imag.show() 
# open image in image viewer
imag.save('xyz.png') 
# save file with other extension

for f in os.listdir('.'): # current directory
    if f.endswith('.jpeg'):
        i = Image.open(f)
        fn, fext = os.path.splittext(f) 
        # extract filename and file extension
        i.save(f'other_dir/{fn}.png') 
        # save each file with other file extension and same name


size_300 = (300, 300) # tuple
img.thumbnail(size_300).save(f'other_dir/{fn}.{fext}') 
# changing the resolution
img.rotate(90).save('image_modified.jpeg') 
# rotate clockwise
img.convert(mode='L').save('image_modified.jpeg') 
# black and white
img.filter(ImageFilter.GaussianBlur(10)).save('image_modified.jpeg') # Blur Image, 10 is level of Blur