Apl Practical 1
Apl Practical 1
Program :
#Rotating an image
from PIL import Image
img = Image.open("rotate.jpg")
rotated_image1 = img.rotate(180)
rotated_image2 = img.rotate(60)
rotated_image1.show()
rotated_image2.show()
Output :
Program :
#Cropping an image
from PIL import Image
img = Image.open("crop.jpg")
width, height = img.size
left = 5
top = height / 4
right = 164
bottom = 3 * height / 4
cropped_image = img.crop((left, top, right, bottom))
cropped_image.show()
Output :
Program :
#Resizing an image
from PIL import Image
img = Image.open("resize.jpg")
width, height = img.size
left = 4#
top = height / 5
right = 154
bottom = 3 * height / 5
resized_image = img.crop((left, right, bottom, top))
newsize = (300, 300)
resized_image = resized_image.resize(newsize)
resized_image.show()
Output :