-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHello_8bitBMP_Downscale.py
38 lines (33 loc) · 1.2 KB
/
Hello_8bitBMP_Downscale.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
notice = """
Downsample an image to 8 bit Demo
-----------------------------------
| Copyright 2022 by Joel C. Alcarez |
| [joelalcarez1975@gmail.com] |
|-----------------------------------|
| We make absolutely no warranty |
| of any kind, expressed or implied |
|-----------------------------------|
| This graphics library outputs |
| to a bitmap file. |
-----------------------------------
"""
from pythonbmp.BITMAPlib import(
reduce24bitimagebits as f,
getfuncmetastr as meta
)
import subprocess as proc
from os import path
def main():
print(f'{notice}\n{meta(f)}')
imgedt = 'mspaint' # replace with another editor if Unix
rootdir = path.dirname(__file__) # get path of this script
file = f'{rootdir}/../assets/earth.bmp'
newfile = '8bitBMP.bmp'
bits= 8 # valid values are 8,4,1
threshold = 4 # in computing new palette how far apart should colors be
usemono = False # can apply a mono filter
f(file, newfile, bits, threshold, usemono) # magic takes time
print(f'All done close {imgedt} to finish')
ret = proc.call([imgedt, newfile])
if __name__=="__main__":
main()