Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image, ImageDraw
- import math
- def create_background(size, color):
- r = color[0]
- g = color[1]
- b = color[2]
- ri = math.floor((255-r)/size[0])
- gi = math.floor((255 - g) / size[0])
- bi = math.floor((255 - b) / size[0])
- img = Image.new("RGB", size)
- pixels = img.load()
- for i in range(size[0]):
- for j in range(size[1]):
- pixels[i,j] = (r,g,b)
- r += ri
- g += gi
- b += bi
- return img
- def add_frame(pic, color):
- imageObject = Image.open(pic)
- degree_flippedImage = imageObject.transpose(Image.ROTATE_180)
- #degree_flippedImage.show()
- w,h = degree_flippedImage.size
- i = create_background((w+40,h+40), color)
- Image.Image.paste(i, degree_flippedImage, (20, 20))
- i.show()
- add_frame("images.jpg", (130,10,20))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement