ATH-MaaS/Pixelle-Video · error · ValueError
No image paths provided
Error message
No image paths provided
What it means
stitch_images merges multiple split images back into one and raises ValueError when image_paths is empty or None. It is a guard: opening image_paths[0] would otherwise crash with an opaque IndexError.
Source
Thrown at pixelle_video/services/api_services/image_processor.py:114
left_box = (0, 0, mid_col, self.height)
right_box = (mid_col, 0, self.width, self.height)
left_image = self.image.crop(left_box)
right_image = self.image.crop(right_box)
save_dir, filename = os.path.split(self.image_path)
base, extension = os.path.splitext(filename)
left_image_path = os.path.join(save_dir, base + '_front' + extension)
right_image_path = os.path.join(save_dir, base + '_back' + extension)
left_image.save(left_image_path)
right_image.save(right_image_path)
return left_image_path, right_image_path
def stitch_images(self, image_paths, output_path):
"""拼接多张图片"""
if not image_paths:
raise ValueError("No image paths provided")
sample_image = Image.open(image_paths[0])
single_width, single_height = sample_image.size
num_images = len(image_paths)
total_desired_width = single_width
total_current_width = single_width * num_images
total_width_to_cut = max(0, total_current_width - total_desired_width)
width_to_cut_per_image = total_width_to_cut // num_images
stitched_image = Image.new('RGB', (total_desired_width, single_height), "white")
current_x = 0
for path in image_paths:
image = Image.open(path)
if width_to_cut_per_image > 0:
left_margin = width_to_cut_per_image // 2
right_margin = image.width - width_to_cut_per_image + left_margin
image = image.crop((left_margin, 0, right_margin, image.height))
stitched_image.paste(image, (current_x, 0))
current_x += image.widthView on GitHub (pinned to 848b054e4f)
Solutions
- Ensure the caller collects the actual saved image paths before calling stitch_images.
- Check the source directory contains the expected split images (correct path and extensions).
- Guard the call site with a length check and skip stitching gracefully when nothing to merge.
Example fix
// before
processor.stitch_images(paths, out)
// after
paths = sorted(glob.glob(os.path.join(split_dir, '*.png')))
if paths:
processor.stitch_images(paths, out) Defensive patterns
Strategy: validation
Validate before calling
if not image_paths:
raise ValueError("stitch_images called with no paths")
missing = [p for p in image_paths if not os.path.exists(p)]
assert not missing, f"missing files: {missing}" Type guard
def is_valid_path_list(paths) -> bool:
return isinstance(paths, (list, tuple)) and len(paths) > 0 and all(
isinstance(p, str) and os.path.exists(p) for p in paths) Try / catch
try:
processor.stitch_images(paths, out)
except ValueError as e:
logging.warning(f"Nothing to stitch: {e}") # skip stitching step Prevention
- Always collect saved file paths from the split step rather than re-globbing
- Check directory contents and extension filters before merging
- Skip stitching gracefully when the list is empty after filtering
- Use sorted stable ordering so partial results are handled predictably
When it happens
Trigger: Calling stitch_images([]), stitch_images(None), or with a list of paths that a previous collection step (e.g. split/glob) produced zero results for.
Common situations: Glob/directory scan returned no files (wrong directory or extension filter), all split operations failed earlier leaving an empty list, caller passes an empty list after filtering nonexistent files.
Related errors
- No suitable white column found within the specified range
- No default workflow configured for {self.service_name}. Plea
- Workflow '{workflow}' not found. Available workflows: {avail
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/0ebf3e7748760fcf.
Report an issue: GitHub.