网络编程
位置:首页>> 网络编程>> Python编程>> Python批量修改图片分辨率的实例代码

Python批量修改图片分辨率的实例代码

作者:芋艿ashes  发布时间:2023-01-30 01:59:10 

标签:Python,图片,分辨率

前言:处理图片需要,需把图片都转换成1920*1280的大小, python实现很方便,需要导入图片处理的Image包和匹配的glob包,很简单,代码如下:


img_path = glob.glob("D:/chosed/*.jpg")
path_save = "D:/closedd"
for file in img_path:
 name = os.path.join(path_save, file)
 im = Image.open(file)
 im.thumbnail((1920,1280))
 print(im.format, im.size, im.mode)
 im.save(name,'JPEG')

来源:https://blog.csdn.net/u014257192/article/details/79187205

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com