# coding:utf-8 # !/usr/bin/env python3 from PIL import Image, ImageOps liste = """52272434262_08161ca956_k.jpg 52273667914_c67e59883f_k.jpg 52273896340_a5d7a5b569_k.jpg 52282000756_4350b904a6_o.png 52439772940_0a908517fd_k.jpg 52272434422_6e763311e0_k.jpg 52273667939_00a7a82d85_k.jpg 52273896530_32364a5ae9_k.jpg 52282013983_431b84da93_o.png 52439843783_6b199f85d8_k.jpg 52273406946_9270259682_k.jpg 52273668079_69d33c4f5d_k.jpg 52281021382_92b4cfc3ce_o.png 52282014418_6df2d3ddbd_o.png 52439844463_fed718866f_k.jpg 52273407231_50a6d90bce_k.jpg 52273668119_6f6b12e472_k.jpg 52281972878_1efc0e0f77_o.png 52439703339_6668e4e7b6_h.jpg """ i = 1 target = (1920, 1080) band = Image.new("RGB",(1920, 2)) y_split = 730 for name in liste.split(): im = Image.open(name) #be sure that the width is 1920px size = (1920, int(im.height * 1920 / im.width)) im = im.resize(size) im = ImageOps.fit(im, target, centering=(0.5,1)) # select the upper part box = (0, 0, 1920, y_split) # define the bottom part bottom_box = (0, y_split + 2, 1920, 1080) bottom_size = (1920, 1078-y_split) # mirrot the upper part bottom = ImageOps.flip(im.crop(box)) # keep only a part of the mirrored part bottom = ImageOps.fit(bottom, bottom_size, centering=(0.5,0)) # fade to black from top to bottom of the mirrored part pixels = bottom.load() gamma = 1.4 for y in range(bottom.height): darker = pow((bottom.height -y)/bottom.height, gamma) for x in range(bottom.width): pixels[x,y] = (int(pixels[x, y][0] * darker), int(pixels[x, y][1] * darker), int(pixels[x, y][2] * darker),) # join the 2 parts im.paste(bottom, bottom_box) # add the band im.paste(band, (0, y_split)) # export the result with open(f"Screensaver-{i:02}.jpg",'w') as new_im: im.save(new_im) i += 1