adding python script so to edit images using floyd steinberg dithering
This commit is contained in:
parent
f2834f81d8
commit
a1f05c79d4
28
image_processing/downgrademypic.py
Executable file
28
image_processing/downgrademypic.py
Executable file
|
@ -0,0 +1,28 @@
|
|||
from PIL import Image
|
||||
import cv2
|
||||
import numpy as np
|
||||
import optparse
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
|
||||
p = optparse.OptionParser()
|
||||
p.add_option('--image', '-i', default="image.png")
|
||||
options, arguments = p.parse_args()
|
||||
|
||||
print("Converting "+options.image)
|
||||
#print("the option is " + options.image)
|
||||
##################################################### Solution 1 ##############################################################
|
||||
|
||||
#PIL.Image.convert parametrs :
|
||||
#https://pillow.readthedocs.io/en/4.2.x/reference/Image.html?highlight=image.convert#PIL.Image.Image.convert
|
||||
|
||||
|
||||
#PIL.Image.convert Modes :
|
||||
#https://pillow.readthedocs.io/en/4.2.x/handbook/concepts.html#concept-modes
|
||||
|
||||
|
||||
#image convert to 1-bit pixels, black and white, stored with one pixel per byte and Dithering
|
||||
imageConvert = Image.open(options.image).convert(mode='1',dither=Image.FLOYDSTEINBERG)
|
||||
imageConvert.save('converted.png')
|
||||
|
||||
print("Done, saved in converted.png")
|
Loading…
Reference in New Issue
Block a user