chore: Update version to 0.7.1 and improve poster display using viu

This commit is contained in:
sHa
2026-01-03 19:40:24 +00:00
parent 390e8e8f83
commit 65d9759880
4 changed files with 28 additions and 36 deletions

BIN
dist/renamer-0.7.1-py3-none-any.whl vendored Normal file

Binary file not shown.

View File

@@ -1,6 +1,6 @@
[project]
name = "renamer"
version = "0.6.12"
version = "0.7.1"
description = "Terminal-based media file renamer and metadata viewer"
readme = "README.md"
requires-python = ">=3.11"

View File

@@ -74,39 +74,31 @@ class CatalogFormatter:
return console.file.getvalue()
def _display_poster(self, image_path: str) -> str:
"""Display poster image in terminal using simple ASCII art"""
try:
from PIL import Image
import os
"""Display poster image in terminal using viu"""
import subprocess
import shutil
if not os.path.exists(image_path):
return f"Image file not found: {image_path}"
# Open and resize image
img = Image.open(image_path).convert('L').resize((80, 40), Image.Resampling.LANCZOS)
# Check if viu is available
if not shutil.which('viu'):
return f"viu not installed. Install with: cargo install viu\nPoster at: {image_path}"
# ASCII characters from dark to light
ascii_chars = '@%#*+=-:. '
try:
# Run viu to render the image
# -w 40: width in characters
# -h 30: height in characters
# -t: transparent background
result = subprocess.run(
['viu', '-w', '40', '-t', image_path],
capture_output=True,
text=True,
check=True
)
return result.stdout
# Convert to ASCII
pixels = img.getdata()
width, height = img.size
ascii_art = []
for y in range(0, height, 2): # Skip every other row for aspect ratio
row = []
for x in range(width):
# Average of two rows for better aspect
pixel1 = pixels[y * width + x] if y < height else 255
pixel2 = pixels[(y + 1) * width + x] if y + 1 < height else 255
avg = (pixel1 + pixel2) // 2
char = ascii_chars[avg * len(ascii_chars) // 256]
row.append(char)
ascii_art.append(''.join(row))
return '\n'.join(ascii_art)
except ImportError:
return f"Image at {image_path} (PIL not available)"
except subprocess.CalledProcessError as e:
return f"Failed to render image with viu: {e.stderr}\nPoster at: {image_path}"
except Exception as e:
return f"Failed to display image at {image_path}: {e}"
return f"Failed to display image: {e}\nPoster at: {image_path}"

2
uv.lock generated
View File

@@ -462,7 +462,7 @@ wheels = [
[[package]]
name = "renamer"
version = "0.6.12"
version = "0.7.1"
source = { editable = "." }
dependencies = [
{ name = "langcodes" },