You are on page 1of 3

SYSTEM LIBRARIES

These are modules that come with the installation of Python.

The OS Module;
The purpose of the OS module is for the ease of directory operations; changing
path, making directories (folders), deleting or moving them around.

import os
import time

os.mkdir('newDir')

time.sleep(2)
os.rename('newDir', 'newDir2')

time.sleep(2)
os.rmdir('newDir2')

13.7 The Python Package Index (PyPi)


The Python Package Index PyPi (also known as the Cheese Shop) is the Python
recognized repository for third party packages. PyPi helps you to find and
install software developed a third party and shared by the Python community.
PyPi is used by package authors as a medium to freely share their software.
The index, located at www.pypi.org hosts over one hundred and thirteen
thousand (113,000) tried, tested and trusted packages. These packages are in
different fields, ranging from

Python Image Library (PIL)


First download the 'Pillow' package from PyPi.

Import into script;

from PIL import Image # Called PIL in old version

img = Image.open('01_Hydrangeas.jpg') # img is now a PILLOW object

print (img.size)
print (img.format)
img.show()

Cropping Images
from PIL import Image # Called PIL in old version

img = Image.open('01_Hydrangeas.jpg') # img is now a PILLOW object

area = (200, 150, 800, 700) # Make sure you don't go outside the image area
cropped_img = img.crop(area) # Create new image from cropped image

img.show()
cropped_img.show()

Combining images together


from PIL import Image # Called PIL in old version

logo = Image.open('aul.jpg')
img = Image.open('01_Hydrangeas.jpg')

area = (0, 0, 260, 176)

img.paste(logo, area)
img.show()
img.save('result.jpg')

Getting Individual Channels


from PIL import Image # Called PIL in old version

img = Image.open('03_Penguins.jpg')

#print (img.mode)
img.show()

r, g, b, = img.split() # Returns a tuple

r.show()
g.show()
b.show()

Builder Web Crawlers using


BeautifulSoup4
Gathering information from web pages

You might also like