Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 3

PILLOW

Pillow is an image-processing library used in Python


Programs.
USAGE: If you are building your application with Python and need to
add image processing features to it, there are various libraries you
could use. Some popular ones are OpenCV, scikit-image, Python
Imaging Library and Pillow.
• Pillow has extensive APIs to support image processing which provide methods for
Geometrical transformations
• Image filtering
• Image enhancement
• Color space conversions of Images
• Statistical analysis of images like histogram
• It supports a range of image file formats such as PNG, JPEG, PPM,
GIF, TIFF and BMP.
Installation: $ pip install Pillow
Methods and Attributes
 Image .open() Image.resize()
 Image.show() Image.rotate()
 Image.save() Image.transpose()
 Image.thumbnail() Image.convert()
Image.filter()
 Image.crop() Image.point()
 Image.transpose() ImageEnhance.contrast()
 Image.paste()  Image.format
 Image.merge()  Image.size
 Image.split()  Image.mode
Example code
Color Transforms
from PIL import Image
# Display individual frames from
im = the loaded animated GIF file
Image.open("peacock.jpg").convert("L") imageObject=Image.open('xmas.gif')
im.show() images=[]
for frame in
Filters range(0,imageObject.n_frames):
from PIL import ImageFilter
im=Image.open('peacock.jpg') imageObject.seek(frame)
out = im.filter(ImageFilter.DETAIL) images.append(imageObject)
out.show() imageObject.show()
# multiply each pixel by 1.2
out = im.point(lambda i: i * 1.2) #creating gif's
out.show()
images[0].save('anitest.gif',
Enhancing image save_all=True,
#Enhancing images append_images=images[1:],
from PIL import ImageEnhance duration=100,
enh = ImageEnhance.Contrast(im) loop=0)
enh.enhance(1.3).show("30% more
contrast")

You might also like