Python example code for batch modification of picture resolution
- 2021-07-09 08:48:37
- OfStack
To process pictures, we need to convert pictures into 1920*1280 size. python is very convenient to implement. We need to import Image package for picture processing and matching glob package. It is very simple. The code is as follows:
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')