summaryrefslogtreecommitdiff
path: root/OASIS/docs/convert_bmp.py
blob: 05de1006e301e37622d09f4be89f1b95830c265f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from PIL import Image
import os

jpeg_folder = "/mnt/c/Users/eric/Documents/repos/URA/OASIS/JPEG/DPOS"
bmp_folder = "/mnt/c/Users/eric/Documents/repos/URA/OASIS/BMP/DPOS"

# Create the BMP folder if it doesn't exist
if not os.path.exists(bmp_folder):
    os.makedirs(bmp_folder)

# Loop over all the JPEG files in the folder
for file in os.listdir(jpeg_folder):
    if file.endswith(".jpg"):
        # Load the JPEG file and convert it to BMP format
        jpeg_file = os.path.join(jpeg_folder, file)
        bmp_file = os.path.join(bmp_folder, os.path.splitext(file)[0] + ".bmp")
        with Image.open(jpeg_file) as im:
            im.convert("L").save(bmp_file)