随笔 - 26,  文章 - 0,  评论 - 0,  阅读 - 13934
复制代码
from PIL import Image, ImageFilter
import os


class MyGaussianBlur(ImageFilter.Filter):
    name = "GaussianBlur"

    def __init__(self, radius=2, bounds=None):
        self.radius = radius
        self.bounds = bounds

    def filter(self, image):
        if self.bounds:
            clips = image.crop(self.bounds).gaussian_blur(self.radius)
            image.paste(clips, self.bounds)
            return image
        else:
            return image.gaussian_blur(self.radius)


if __name__ == '__main__':

    open_path = './image/'
    save_path = './images100k/'
    open_list_path = os.listdir(open_path)
    for i in open_list_path:
        frame_image = Image.open(open_path + i)
        image = frame_image.filter(MyGaussianBlur(radius=3))   # 通过调节redius的值调整图片的清晰度
        image.thumbnail((1920, 1020))  # 调整图片的尺寸
        image.save(save_path + str(i))

    print('success')
复制代码

如果觉得对你有帮助的话可以给我点个赞哦!么么哒~

posted on 2020-11-02 17:05  风雨无阻!  阅读(1604)  评论(0)    收藏  举报
编辑推荐:
· 行业思考:不是前端不行,是只会前端不行
· C#高级GDI+实战:从零开发一个流程图
· 2025年:是时候重新认识System.Text.Json了
· 源码浅析:SpringBoot main方法结束为什么程序不停止
· C#性能优化:为何 x * Math.Sqrt(x) 远胜 Math.Pow(x, 1.5)
阅读排行:
· 独立开发在线客服系统,我是如何与杀毒软件误报斗智斗勇的
· 换成.NET 9,你的LINQ代码还能快上7倍
· AI 时代,为什么我们还有必要写博客?
· where 1 = 1的作用?会影响性能吗?count(*) 和 count(1)哪个快?
· 独立开发:这才过去一个月?

< 2025年8月 >
27 28 29 30 31 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 1 2 3 4 5 6
点击右上角即可分享
微信分享提示