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')
如果觉得对你有帮助的话可以给我点个赞哦!么么哒~
分类:
python
【推荐】AI 的力量,开发者的翅膀:欢迎使用 AI 原生开发工具 TRAE
【推荐】2025 HarmonyOS 鸿蒙创新赛正式启动,百万大奖等你挑战
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 行业思考:不是前端不行,是只会前端不行
· 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)哪个快?
· 独立开发:这才过去一个月?