Answer the question
In order to leave comments, you need to log in
Apply smooth blur to a part of an image?
Hello! can you tell me how to apply blur smoothly from top to bottom
def blur_filter(image):
img = Image.open(os.path.join(ROOT_DIR, image))
if img.mode != 'RGBA':
img = img.convert('RGBA')
width, height = img.size
box = (0, height // 100 * 20, width, height // 100 * 60)
img_box = img.crop(box)
img = img.filter(ImageFilter.GaussianBlur(2))
#imgt = Image.new('RGBA', (width, height), color=0xFFFFFF)
#imgt.paste(img_box, box)
#img = Image.blend(img, imgt, .1)
img.save(os.path.join(ROOT_DIR, image.replace('/', '/copy_')), 'PNG')
if __name__ == '__main__':
img_1 = 'img/9.jpg'
img_2 = 'img/8.jpg'
blur_filter(img_1)
print('='*20)
blur_filter(img_2)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question