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 <alekratz@gmail.com>
This commit is contained in:
2024-08-02 10:25:06 -07:00
parent 4a7b0cc000
commit b5498b18be
2 changed files with 43 additions and 45 deletions

View File

@@ -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)

View File

@@ -1,42 +1,42 @@
<svg width="256" height="160" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="32" height="32" fill="hsl(30.00,100.00%,26.67%)" />
<rect x="32" y="0" width="32" height="32" fill="hsl(30.00,100.00%,26.67%)" />
<rect x="64" y="0" width="32" height="32" fill="hsl(30.00,100.00%,40.00%)" />
<rect x="96" y="0" width="32" height="32" fill="hsl(30.00,100.00%,46.67%)" />
<rect x="128" y="0" width="32" height="32" fill="hsl(30.00,100.00%,36.67%)" />
<rect x="160" y="0" width="32" height="32" fill="hsl(30.00,100.00%,16.67%)" />
<rect x="192" y="0" width="32" height="32" fill="hsl(30.00,100.00%,46.67%)" />
<rect x="224" y="0" width="32" height="32" fill="hsl(30.00,100.00%,6.67%)" />
<rect x="0" y="0" width="32" height="32" fill="hsl(30.00,100.00%,63.33%)" />
<rect x="32" y="0" width="32" height="32" fill="hsl(30.00,100.00%,83.33%)" />
<rect x="64" y="0" width="32" height="32" fill="hsl(30.00,100.00%,73.33%)" />
<rect x="96" y="0" width="32" height="32" fill="hsl(30.00,100.00%,86.67%)" />
<rect x="128" y="0" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="160" y="0" width="32" height="32" fill="hsl(30.00,100.00%,90.00%)" />
<rect x="192" y="0" width="32" height="32" fill="hsl(30.00,100.00%,90.00%)" />
<rect x="224" y="0" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="0" y="32" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="32" y="32" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="64" y="32" width="32" height="32" fill="hsl(30.00,100.00%,3.33%)" />
<rect x="96" y="32" width="32" height="32" fill="hsl(30.00,100.00%,13.33%)" />
<rect x="128" y="32" width="32" height="32" fill="hsl(30.00,100.00%,30.00%)" />
<rect x="160" y="32" width="32" height="32" fill="hsl(30.00,100.00%,0.00%)" />
<rect x="192" y="32" width="32" height="32" fill="hsl(30.00,100.00%,33.33%)" />
<rect x="224" y="32" width="32" height="32" fill="hsl(30.00,100.00%,30.00%)" />
<rect x="0" y="64" width="32" height="32" fill="hsl(30.00,100.00%,36.67%)" />
<rect x="32" y="64" width="32" height="32" fill="hsl(30.00,100.00%,36.67%)" />
<rect x="64" y="64" width="32" height="32" fill="hsl(30.00,100.00%,23.33%)" />
<rect x="96" y="64" width="32" height="32" fill="hsl(30.00,100.00%,23.33%)" />
<rect x="128" y="64" width="32" height="32" fill="hsl(30.00,100.00%,36.67%)" />
<rect x="160" y="64" width="32" height="32" fill="hsl(30.00,100.00%,0.00%)" />
<rect x="192" y="64" width="32" height="32" fill="hsl(30.00,100.00%,46.67%)" />
<rect x="224" y="64" width="32" height="32" fill="hsl(30.00,100.00%,43.33%)" />
<rect x="0" y="96" width="32" height="32" fill="hsl(30.00,100.00%,40.00%)" />
<rect x="32" y="96" width="32" height="32" fill="hsl(30.00,100.00%,16.67%)" />
<rect x="64" y="96" width="32" height="32" fill="hsl(30.00,100.00%,46.67%)" />
<rect x="96" y="96" width="32" height="32" fill="hsl(30.00,100.00%,33.33%)" />
<rect x="128" y="96" width="32" height="32" fill="hsl(30.00,100.00%,46.67%)" />
<rect x="160" y="96" width="32" height="32" fill="hsl(30.00,100.00%,26.67%)" />
<rect x="192" y="96" width="32" height="32" fill="hsl(30.00,100.00%,43.33%)" />
<rect x="224" y="96" width="32" height="32" fill="hsl(30.00,100.00%,30.00%)" />
<rect x="0" y="128" width="32" height="32" fill="hsl(30.00,100.00%,0.00%)" />
<rect x="32" y="128" width="32" height="32" fill="hsl(30.00,100.00%,23.33%)" />
<rect x="64" y="128" width="32" height="32" fill="hsl(30.00,100.00%,13.33%)" />
<rect x="96" y="128" width="32" height="32" fill="hsl(30.00,100.00%,16.67%)" />
<rect x="128" y="128" width="32" height="32" fill="hsl(30.00,100.00%,40.00%)" />
<rect x="160" y="128" width="32" height="32" fill="hsl(30.00,100.00%,6.67%)" />
<rect x="192" y="128" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="224" y="128" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="64" y="32" width="32" height="32" fill="hsl(30.00,100.00%,83.33%)" />
<rect x="96" y="32" width="32" height="32" fill="hsl(30.00,100.00%,80.00%)" />
<rect x="128" y="32" width="32" height="32" fill="hsl(30.00,100.00%,100.00%)" />
<rect x="160" y="32" width="32" height="32" fill="hsl(30.00,100.00%,66.67%)" />
<rect x="192" y="32" width="32" height="32" fill="hsl(30.00,100.00%,60.00%)" />
<rect x="224" y="32" width="32" height="32" fill="hsl(30.00,100.00%,73.33%)" />
<rect x="0" y="64" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="32" y="64" width="32" height="32" fill="hsl(30.00,100.00%,96.67%)" />
<rect x="64" y="64" width="32" height="32" fill="hsl(30.00,100.00%,73.33%)" />
<rect x="96" y="64" width="32" height="32" fill="hsl(30.00,100.00%,100.00%)" />
<rect x="128" y="64" width="32" height="32" fill="hsl(30.00,100.00%,63.33%)" />
<rect x="160" y="64" width="32" height="32" fill="hsl(30.00,100.00%,93.33%)" />
<rect x="192" y="64" width="32" height="32" fill="hsl(30.00,100.00%,90.00%)" />
<rect x="224" y="64" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="0" y="96" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="32" y="96" width="32" height="32" fill="hsl(30.00,100.00%,56.67%)" />
<rect x="64" y="96" width="32" height="32" fill="hsl(30.00,100.00%,63.33%)" />
<rect x="96" y="96" width="32" height="32" fill="hsl(30.00,100.00%,50.00%)" />
<rect x="128" y="96" width="32" height="32" fill="hsl(30.00,100.00%,56.67%)" />
<rect x="160" y="96" width="32" height="32" fill="hsl(30.00,100.00%,63.33%)" />
<rect x="192" y="96" width="32" height="32" fill="hsl(30.00,100.00%,63.33%)" />
<rect x="224" y="96" width="32" height="32" fill="hsl(30.00,100.00%,76.67%)" />
<rect x="0" y="128" width="32" height="32" fill="hsl(30.00,100.00%,83.33%)" />
<rect x="32" y="128" width="32" height="32" fill="hsl(30.00,100.00%,86.67%)" />
<rect x="64" y="128" width="32" height="32" fill="hsl(30.00,100.00%,90.00%)" />
<rect x="96" y="128" width="32" height="32" fill="hsl(30.00,100.00%,66.67%)" />
<rect x="128" y="128" width="32" height="32" fill="hsl(30.00,100.00%,100.00%)" />
<rect x="160" y="128" width="32" height="32" fill="hsl(30.00,100.00%,100.00%)" />
<rect x="192" y="128" width="32" height="32" fill="hsl(30.00,100.00%,70.00%)" />
<rect x="224" y="128" width="32" height="32" fill="hsl(30.00,100.00%,96.67%)" />
</svg>

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB