From 36b06a644c494f91fbe0ae98caad333a000b10b8 Mon Sep 17 00:00:00 2001 From: Agustinus Jason Tan Wijaya Date: Sun, 3 May 2026 18:03:59 +0700 Subject: [PATCH 1/2] Fix border width calculation when --color is on --- jp2a/jp2a.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jp2a/jp2a.py b/jp2a/jp2a.py index e95047c..fdd7752 100644 --- a/jp2a/jp2a.py +++ b/jp2a/jp2a.py @@ -104,7 +104,10 @@ def image_to_ascii( result.append(line) if border: - top_bottom = "+" + "-"*len(result[0][1:-1]) + "+" + pattern = r"\x1b\[[0-9;*]+m" + width = len(re.sub(pattern, "", result[0])) - 2 + + top_bottom = "+" + "-"*width + "+" result.insert(0, top_bottom) result.append(top_bottom) From cc78ac8630d2b0ae27eb46ba286800a760942d2c Mon Sep 17 00:00:00 2001 From: Agustinus Jason Tan Wijaya Date: Sun, 3 May 2026 18:08:23 +0700 Subject: [PATCH 2/2] added the necessary imports --- jp2a/jp2a.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jp2a/jp2a.py b/jp2a/jp2a.py index fdd7752..310df3e 100644 --- a/jp2a/jp2a.py +++ b/jp2a/jp2a.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import argparse, shutil, sys, os, time +import argparse, shutil, sys, os, time, re from PIL import Image, ImageOps, ImageFilter import requests from io import BytesIO