| import os | |
| from PIL import Image | |
| from pillow_heif import register_heif_opener | |
| register_heif_opener() | |
| src = "/vast/ds5725/OOPS/OOPS_raw_data" | |
| dst = "/vast/ds5725/OOPS/images" | |
| os.makedirs(dst, exist_ok=True) | |
| for fname in os.listdir(src): | |
| if fname.lower().endswith(".jpg") or fname.lower().endswith(".jpeg"): | |
| jpg_path = os.path.join(src, fname) | |
| png_name = os.path.splitext(fname)[0] + ".png" | |
| png_path = os.path.join(dst, png_name) | |
| if os.path.exists(png_path): | |
| print(f"Skipping (exists): {png_path}") | |
| continue | |
| img = Image.open(jpg_path).convert("RGB") | |
| img.save(png_path, "PNG") | |
| print("Done!") | |