| from PIL import Image | |
| # 读取图片 | |
| img_path = "/vol/zhaoy/ds-ocr/data/CCI3-Data/CCI3_100-5k_sample100_interval500_per10/images/char_deletion/RS061_ned-0.0907.png" # 原始图片路径 | |
| output_path = "/vol/RS061_ned-0.0907.png" # 保存路径 | |
| target_size = (1280, 1280) # 指定尺寸 (宽, 高) | |
| # 打开并 resize | |
| img = Image.open(img_path) | |
| img_resized = img.resize(target_size, Image.Resampling.LANCZOS) # 高质量缩放 | |
| # 保存 | |
| img_resized.save(output_path) | |
| print(f"✅ 图片已保存到 {output_path},尺寸为 {img_resized.size}") | |