From b5498b18be2d0b48506cea730e589f8d9038b6f2 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Fri, 2 Aug 2024 10:25:06 -0700 Subject: [PATCH] Fix PNG generation Accidentally was passing two args instead of one to PNGWriter, also it wasn't being imported (oops) Signed-off-by: Alek Ratzloff --- colorhash/cli.py | 12 +++---- examples/commithash.svg | 76 ++++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/colorhash/cli.py b/colorhash/cli.py index 73e235f..5eb4fa9 100644 --- a/colorhash/cli.py +++ b/colorhash/cli.py @@ -1,19 +1,17 @@ "Main driver for the colorhash program." import argparse import hashlib -from pathlib import Path import sys import textwrap +from pathlib import Path from .color import colorize from .matricizer import Matricizer, NibbleMatricizer, RandomartMatricizer -from .palettes import Palette, PALETTES -from .writer import ANSIWriter, SVGWriter, Writer - +from .palettes import PALETTES, Palette +from .writer import ANSIWriter, PNGWriter, SVGWriter, Writer # TODO - option to add a caption based on the filename (for SVG) # TODO - load palettes from a file -# TODO - PNG output def cli_main() -> None: @@ -152,7 +150,7 @@ def cli_main() -> None: infile = sys.stdin.buffer else: # TODO - pretty error message for when the file doesn't exist - infile = open(args.input, "rb") + infile = open(args.input, "rb") # pylint: disable=consider-using-with # file_digest (I hope) will not load too much into memory hashdata = hashlib.file_digest(infile, args.hash).digest() # type: ignore # NOTE : previous line has typing ignored because file_digest requires a @@ -202,7 +200,7 @@ def cli_main() -> None: case "svg": writer = SVGWriter(args.square_size) case "png": - writer = PNGWriter(args,square_size) + writer = PNGWriter(args.square_size) output = writer.write(colors) diff --git a/examples/commithash.svg b/examples/commithash.svg index 64b9870..97a148e 100644 --- a/examples/commithash.svg +++ b/examples/commithash.svg @@ -1,42 +1,42 @@ - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file