From 5c6917d202857239ab0fdcec5b86abc354660864 Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 24 Sep 2018 00:11:51 +0200 Subject: [PATCH] Experimental python bmp converter (3-colours to 2-colours) --- experimental | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 experimental diff --git a/experimental b/experimental new file mode 100644 index 0000000..26820ab --- /dev/null +++ b/experimental @@ -0,0 +1,38 @@ +""" Experimental python script for converting a 3-colour bmp to a 2-colour bmp for use with 2-colour E-Paper displays. +Please use at your own risk. + +To use the converter, input a folder path containing the bmps that require converting (input folder) +and then specify an output folder for the converted bmps. +Lastly, replace the original bmp files with the converted ones and reboot to start the E-Paper software with the new bmps. +That's all + +Copyright by Ace-Laboratory +""" + +import glob, os, errno +from PIL import Image +import PIL.ImageOps +#--------------only change the following two lines-----------------# +path = '/home/pi/Desktop/input/' +path2 = '/home/pi/Desktop/output/' +#-----------------no need to change anything below----------------# + +imagenames = [] + +os.chdir(path) #folder containg files +for files in glob.glob("*.bmp"): #find bmp files + imagenames.append(files) #add these files to a list + +print('Found these files:', imagenames) #print this list +print('attempting to convert images to useful ones') + +try: + os.makedirs('/home/pi/Desktop/images/converted') +except OSError as e: + if e.errno != errno.EEXIST: + raise +for files in imagenames: + (PIL.ImageOps.posterize(Image.open(path+files), 1).save(path2+files)) + +print('All done!') +print('You can find your converted files in: ',path2)