anthropics/skills · error · RuntimeError

Image conversion failed

Error message

Image conversion failed

What it means

Raised when `pdftoppm -jpeg -r DPI` (from poppler-utils) exits non-zero while rasterizing the PDF that LibreOffice just produced. It is the second stage of the pptx->pdf->jpg pipeline in thumbnail.py; the PDF exists but poppler could not turn it into slide-*.jpg images.

Source

Thrown at skills/pptx/scripts/thumbnail.py:213

    )
    if result.returncode != 0 or not pdf_path.exists():
        detail = (result.stderr or result.stdout or "").strip()
        raise RuntimeError(f"PDF conversion failed: {detail}" if detail else "PDF conversion failed")

    result = subprocess.run(
        [
            "pdftoppm",
            "-jpeg",
            "-r",
            str(CONVERSION_DPI),
            str(pdf_path),
            str(temp_dir / "slide"),
        ],
        capture_output=True,
        text=True,
    )
    if result.returncode != 0:
        raise RuntimeError("Image conversion failed")

    return sorted(temp_dir.glob("slide-*.jpg"))


def create_grids(
    slides: list[tuple[Path, str]],
    cols: int,
    width: int,
    output_path: Path,
) -> list[str]:
    max_per_grid = cols * (cols + 1)
    grid_files = []

    for chunk_idx, start_idx in enumerate(range(0, len(slides), max_per_grid)):
        end_idx = min(start_idx + max_per_grid, len(slides))
        chunk_slides = slides[start_idx:end_idx]

        grid = create_grid(chunk_slides, cols, width)

View on GitHub (pinned to f6656c1256)

Solutions

  1. Install poppler-utils: `apt-get install -y poppler-utils` (or `apk add poppler-utils`)
  2. Run `pdftoppm -jpeg -r 150 out.pdf /tmp/slide` by hand on the intermediate PDF to see the real exit status
  3. Open the intermediate PDF (e.g. with pdfinfo) to confirm it is valid and has pages; if not, fix the stage-1 conversion (error 20)
  4. Check temp_dir permissions and free disk space

Example fix

// before
if result.returncode != 0:
    raise RuntimeError("Image conversion failed")
// after: surface poppler's own diagnostics
detail = (result.stderr or result.stdout or "").strip()
raise RuntimeError(f"Image conversion failed: {detail}" if detail else "Image conversion failed")
Defensive patterns

Strategy: validation

Validate before calling

import shutil

def can_rasterize_pdf() -> bool:
    return shutil.which("pdftoppm") is not None

Try / catch

try:
    jpgs = convert_to_images(pptx, tmp)
except RuntimeError as e:
    if "Image conversion" in str(e):
        log.error("poppler stage failed; install poppler-utils")
    raise

Prevention

When it happens

Trigger: Calling convert_to_images() on a machine where poppler-utils (pdftoppm) is missing (returncode 127); the generated PDF is malformed or zero pages; CONVERSION_DPI string is invalid; temp disk is full so writing slide-*.jpg fails.

Common situations: Alpine/slim Docker images that have LibreOffice but not the poppler package; a PPTX that LibreOffice converts into a damaged PDF; running as a user without write permission in temp_dir; very old poppler versions failing on newer PDF features.

Related errors


AI-assisted analysis of anthropics/skills@f6656c1256 (2026-08-14). Data as JSON: /api/errors/09b4257b1ea225e3. Report an issue: GitHub.