diff options
author | Eric Dao <eric@erickhangdao.com> | 2023-05-12 14:09:07 -0400 |
---|---|---|
committer | Eric Dao <eric@erickhangdao.com> | 2023-05-12 14:09:07 -0400 |
commit | 191e4bd8beae134295d481773823142d2fdc6a98 (patch) | |
tree | aaca4e7f8e229f9bd551d9bb1583b8ecd7a59d4a /OASIS/docs/convert_bmp.py | |
parent | 186daed7e179241377c117e9d208ccd301d4d712 (diff) | |
download | ura-master.tar.gz ura-master.tar.bz2 ura-master.zip |
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 |