def create_wallpaper(screen, urls, size=(100, 100), randomise=False):
if randomise:
random.shuffle(urls)
wallpaper = Image.new("RGB", screen, "blue")
width = int(math.ceil(float(screen[0]) / size[0]))
height = int(math.ceil(float(screen[1]) / size[1]))
offset = [0,0]
for i in xrange(height):
y = size[1] * i
for j in xrange(width):
x = size[0] * j
photo = load_photo(urls.pop())
if photo.size != size:
photo = photo.resize(size, Image.BICUBIC)
wallpaper.paste(photo, (x, y))
del photo
return wallpaper
评论列表
文章目录