Simple border effect

import numpy as np from PIL import Image def set_border(imnp, width, shade, start_width = 0, step = 1): imnp[:start_width+width:step,:,:] = \ imnp[:,:start_width+width:step,:] = \ imnp[-start_width-width::step,:,:] = \ imnp[:,-start_width-width::step,:] = shade return imnp im = Image.open('image.jpg') imnp = np.array(im) height, width, _ = imnp.shape white_width, black_width, white, black = 8, 2, 255, 0 iterations, border_width, shade, offset, dot_step = 40, 24, black, 0, 2 for i in range(iterations): imnp = set_border(imnp, border_width, shade, offset, dot_step) shade += white // iterations imnp = set_border(imnp, white_width, white) imnp = set_border(imnp, black_width, black) im = Image.fromarray(imnp) im.show() Image with border effect