Image processing with pillow?


To write a piece of python code for image processing with the help of pillow library in python.


PNG Image.


  Gray_scale image

  Blurred version of original image.

  Load the image source.

  Import pillow library.

  Convert the image into gray_scale image.

  Make the image blurred using pillow filter.

  Save both the images.


#import pillow library
from PIL import Image, ImageFilter

#load image
image =‘ml_map.png’)

#The file format of the source file
print(“Image format\n”,image.format,”\n”)

#The pixel format used by the image
print(“Image mode\n”,image.mode,”\n”)

#Image size, in pixels
print(“Image size\n”,image.size,”\n”)

#Convert original into gray_scale image
greyscale_image = image.convert(‘L’)

#Show the grayscale image

#save the gray_scale image“gray_scale.png”)

#Blur the image
blurred = image.filter(ImageFilter.BLUR)

#Display blurred images

#save the new image“blurred.png”)

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit