# 裁剪
import glob
import os.path
from PIL import Image
dir = "D:\\YRB\\Figure\\Fig6"
file_list = glob.glob(os.path.join(dir, "*.jpeg"))
for file1 in file_list:
# 打开图片
image = Image.open(file1)
width, height = image.size
# 打印图片大小
print(f"Image size: {width} x {height}")
# 定义裁剪区域(左、上、右、下)
crop_area = (0, 0, 2413, 5936)
# 裁剪图片
cropped_image = image.crop(crop_area)
# 保存裁剪后的图片为jpeg格式,并设置分辨率
outpath = file1.split(".jpeg")[0] + "_1.jpeg"
cropped_image.save(outpath,dpi=(600,600,0))