ATH-MaaS/Pixelle-Video · error · ValueError
Invalid size format in path: {template_path}. Directory name
Error message
Invalid size format in path: {template_path}. Directory name should be 'WIDTHxHEIGHT' (e.g., '1080x1920') What it means
parse_template_size requires the template's parent directory name to contain 'x' so it can split into WIDTH and HEIGHT. If the directory name has no 'x' (e.g. 'default', 'mobile', 'hd'), it raises ValueError explaining the directory must be named 'WIDTHxHEIGHT'.
Source
Thrown at pixelle_video/utils/template_util.py:68
>>> parse_template_size("1920x1080/modern.html")
(1920, 1080)
"""
path = Path(template_path)
# Get parent directory name (should be like "1080x1920")
dir_name = path.parent.name
# Special case: if parent is "templates", go up one more level
if dir_name == "templates":
# This shouldn't happen in new structure, but handle it
raise ValueError(
f"Invalid template path format: {template_path}. "
f"Expected format: 'WIDTHxHEIGHT/template.html' or 'templates/WIDTHxHEIGHT/template.html'"
)
# Parse size from directory name
if 'x' not in dir_name:
raise ValueError(
f"Invalid size format in path: {template_path}. "
f"Directory name should be 'WIDTHxHEIGHT' (e.g., '1080x1920')"
)
try:
width_str, height_str = dir_name.split('x')
width = int(width_str)
height = int(height_str)
# Sanity check
if width < 100 or height < 100 or width > 10000 or height > 10000:
raise ValueError(f"Invalid size dimensions: {width}x{height}")
return (width, height)
except ValueError as e:
raise ValueError(
f"Failed to parse size from path: {template_path}. "
f"Expected format: 'WIDTHxHEIGHT/template.html' (e.g., '1080x1920/default.html'). "View on GitHub (pinned to 848b054e4f)
Solutions
- Rename the template directory to the 'WIDTHxHEIGHT' form, e.g. '1080x1920'.
- Replace non-'x' separators ('p', '-', '*', spaces) with 'x': '1920x1080'.
- Build paths via get_template_full_path(size, template_name) so the convention is enforced for you.
- Verify the parent directory of the exact .html file you pass is the resolution folder, not a grouping folder.
Example fix
// before
parse_template_size("templates/hd/default.html")
// after
parse_template_size("templates/1920x1080/default.html") Defensive patterns
Strategy: validation
Validate before calling
import re
from pathlib import Path
def dir_is_wxh(template_path: str) -> bool:
return bool(re.fullmatch(r"\d+x\d+", Path(template_path).parent.name)) Type guard
def extract_size_dir(template_path: str):
name = Path(template_path).parent.name
if 'x' in name:
w, _, h = name.partition('x')
if w.isdigit() and h.isdigit():
return (int(w), int(h))
return None Try / catch
try:
w, h = parse_template_size(template_path)
except ValueError:
logger.error("Template dir must be WIDTHxHEIGHT, got %r", Path(template_path).parent.name)
raise Prevention
- Name template folders strictly 'WIDTHxHEIGHT' (e.g. 1080x1920), never 'hd'/'4k'/'portrait'
- Use 'x' as the only separator; avoid '-', '*', 'p'
- Generate template directories from a size constant so names stay consistent
- Lint the templates tree at startup for non-conforming directory names
When it happens
Trigger: A template path whose immediate parent directory is not a resolution folder — e.g. 'templates/hd/default.html', '1080p/default.html', or the file placed directly in a named directory rather than a WxH one — passed through render_frame, __init__, render_single_output, or render_style_config.
Common situations: Users naming template folders semantically ('portrait', '4k') instead of by pixel size; creating custom templates in a new folder without following the WxH convention; typos like '1080*1920' or '1080-1920'.
Related errors
- Invalid template path format: {template_path}. Expected form
- Invalid size dimensions: {width}x{height}
- Failed to parse size from path: {template_path}. Expected fo
- frame_template is required to determine media size
- Progress must be between 0.0 and 1.0, got {self.progress}
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/8f3de7893242f34b.
Report an issue: GitHub.