diff --git a/internal/services/media_scanner.go b/internal/services/media_scanner.go index f32677f..607cf8b 100644 --- a/internal/services/media_scanner.go +++ b/internal/services/media_scanner.go @@ -2147,7 +2147,11 @@ func (s *MediaScanner) renderPDFCoverPage(pdfPath string) string { }() outPrefix := filepath.Join(tmpDir, "cover") - cmd := exec.Command("pdftoppm", "-jpeg", "-f", "1", "-l", "1", "-singlefile", "-r", "150", pdfPath, outPrefix) + // -cropbox renders the CropBox (the viewer-visible region, matching pdf.js) + // rather than the MediaBox; poppler falls back to the MediaBox when no + // CropBox is defined. This matters for PDFs whose page 1 is a full print + // cover wrap (back + spine + front) with a CropBox covering just the front. + cmd := exec.Command("pdftoppm", "-jpeg", "-f", "1", "-l", "1", "-singlefile", "-cropbox", "-r", "150", pdfPath, outPrefix) if output, err := cmd.CombinedOutput(); err != nil { fmt.Printf("Warning: failed to render PDF cover from %s: %v, output: %s\n", pdfPath, err, string(output)) return ""