批量压缩tif文件到指定物理宽度mm,同时保持DPI大于300
压缩代码:
import os
from PIL import Image
def resize_imageto_width_mm(image_path, desired_width_mm):
# 打开图像文件
with Image.open(image_path) as img:
# 尝试获取图像的DPI,如果不存在,则默认为300 DPI
dpi = max(
压缩代码:
import os
from PIL import Image
def resize_imageto_width_mm(image_path, desired_width_mm):
# 打开图像文件
with Image.open(image_path) as img:
# 尝试获取图像的DPI,如果不存在,则默认为300 DPI
dpi = max(