Created
December 31, 2022 11:06
-
-
Save JupyterJones/8f1c3d0e25cff512a7f7e80de2ba8c89 to your computer and use it in GitHub Desktop.
Create a removes a circle, blurs the edges and pastes that image on a blank transparent image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageFilter, ImageDraw | |
import glob | |
import time | |
def circleblur(FILENAME,saveDirectory,count): | |
im1 = Image.open(FILENAME) | |
im1 = im1.resize((512,512), Image.BICUBIC) | |
im2 = Image.new("RGBA",im1.size,(0,0,0,0)) | |
mask = Image.new("L", im1.size, 0) | |
draw = ImageDraw.Draw(mask) | |
draw.ellipse((50, 50, 462, 462), fill=255) | |
#draw.ellipse((100, 100, 412, 412), fill=250) | |
im = Image.composite(im1, im2, mask) | |
mask_blur = mask.filter(ImageFilter.GaussianBlur(15)) | |
im = Image.composite(im1, im2, mask_blur) | |
timestr = time.strftime("%Y%m%d-%H%M%S") | |
file = saveDirectory+timestr+"_"+str(count+1)+".png" | |
im.save(file) | |
return im | |
# Get a list of all .txt files in the current directory | |
FILENAMES = glob.glob('/home/jack/Downloads/to-vid/whiteborders/*.png') | |
count = 0 | |
for FILENAME in FILENAMES: | |
count = count +1 | |
saveDirectory ="/home/jack/Desktop/TENSORFLOW/clouds/" | |
circleblur(FILENAME,saveDirectory,count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The small circlular image in the larger image is an example. https://pbs.twimg.com/media/FlTO9kFaEAQcVi8?format=jpg&name=small |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment