From 86a9350a1798b613c0570f523ec31b5bfc42e714 Mon Sep 17 00:00:00 2001 From: Lephe Date: Sun, 16 Jun 2019 00:16:47 -0400 Subject: [PATCH] fxconv: minor fixes * Explicitly convert to RGB to avoid errors with exotic formats. * Don't pollute the user's /tmp directory for debugging purposes. --- fxconv/fxconv.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fxconv/fxconv.py b/fxconv/fxconv.py index a91563e..2d7f010 100644 --- a/fxconv/fxconv.py +++ b/fxconv/fxconv.py @@ -258,8 +258,8 @@ def _convert_font(input, output, params): if charset is None: raise FxconvError(f"unknown character set '{charset}'") if charset.count > grid.size(img): - raise FxconvError(f"not enough elements in grid (got {grid.size()}, "+ - f"need {charset.count} for '{charset.name}'") + raise FxconvError(f"not enough elements in grid (got {grid.size(img)}, "+ + f"need {charset.count} for '{charset.name}')") #-- # Proportionality and metadata @@ -310,7 +310,6 @@ def _convert_font(input, output, params): # Get glyph area glyph = img.crop(region) - glyph.save(f"/tmp/img{number}.png") if proportional: glyph = _trim(glyph) data_widths.append(glyph.width) @@ -380,7 +379,6 @@ def quantize(img, dither=False): for (i, c) in enumerate(colors): palette.putpixel((i, 0), c) palette = palette.convert("P") - palette.save("/tmp/palette.png") # Save the alpha channel, and make it either full transparent or opaque try: @@ -397,7 +395,7 @@ def quantize(img, dither=False): img.load() palette.load() im = img.im.convert("P", int(dither), palette.im) - img = img._new(im) + img = img._new(im).convert("RGB") # Put back the alpha channel img.putalpha(alpha_channel)