diff options
Diffstat (limited to 'OASIS/docs/convert_bmp.py')
-rw-r--r-- | OASIS/docs/convert_bmp.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/OASIS/docs/convert_bmp.py b/OASIS/docs/convert_bmp.py new file mode 100644 index 0000000..05de100 --- /dev/null +++ b/OASIS/docs/convert_bmp.py @@ -0,0 +1,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)
\ No newline at end of file |