Experimental python bmp converter (3-colours to 2-colours)
This commit is contained in:
parent
7b036db3aa
commit
5c6917d202
1 changed files with 38 additions and 0 deletions
38
experimental
Normal file
38
experimental
Normal file
|
@ -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)
|
Loading…
Reference in a new issue