diff --git a/img2htmltables.py b/img2htmltables.py new file mode 100644 index 0000000..9b694ea --- /dev/null +++ b/img2htmltables.py @@ -0,0 +1,33 @@ +import sys +try: + from PIL import Image +except ImportError: + print('Python imaging not installed') + sys.exit(1) + + +def img2tables(img_file: str, height: int=None, width: int=None) -> str: + img = Image.open(img_file).convert('RGB') + if height and width: + img = img.resize((width, height), Image.ANTIALIAS) + sizex, sizey = img.size + + html = """
| ".format(img.getpixel((col, row))[0], img.getpixel((col, row))[1], img.getpixel((col, row))[2]) + html += " |