1
0
mirror of synced 2024-06-07 18:15:19 +02:00

adding python script so to edit images using floyd steinberg dithering

This commit is contained in:
paula 2023-08-20 14:20:23 +02:00
parent f2834f81d8
commit a1f05c79d4

View 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")