import numpy as np
from PIL import Image, ImageDraw
#https://stackoverflow.com/questions/51486297/cropping-an-image-in-a-circular-way-using-python
import requests
import io
buf = requests.get("https://crashlaker.github.io/assets/static/crashlaker-logo.png").content
buf = io.BytesIO(buf)
img = Image.open(buf).convert("RGB")
npImage=np.array(img)
h,w=img.size
# Create same size alpha layer with circle
alpha = Image.new('L', img.size,0)
draw = ImageDraw.Draw(alpha)
draw.pieslice([0,0,h,w],0,360,fill=255)
# Convert alpha Image to numpy array
npAlpha=np.array(alpha)
# Add alpha layer to RGB
npImage=np.dstack((npImage,npAlpha))
Image.fromarray(npImage).save('result.png')
Image.fromarray(npImage)