Remove PDF thumbnails, fix 3MF clipping, fix PDF range-request loading
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m6s

This commit is contained in:
Elijah 2026-05-31 22:00:54 -07:00
parent c239fbb296
commit 3c47584bb2
5 changed files with 47 additions and 105 deletions

View file

@ -82,7 +82,7 @@ func (m *ThumbnailManager) ScanMissingThumbnails() {
mimeType = "video/"
} else if ext == ".mp3" || ext == ".flac" || ext == ".wav" || ext == ".m4a" || ext == ".aac" {
mimeType = "audio/"
} else if ext == ".docx" || ext == ".pptx" || ext == ".xlsx" || ext == ".pdf" {
} else if ext == ".docx" || ext == ".pptx" || ext == ".xlsx" {
mimeType = "application/"
} else {
continue
@ -148,8 +148,6 @@ func (m *ThumbnailManager) worker(id int) {
err = generateVideoThumbnail(fullSourcePath, destPath)
} else if strings.HasPrefix(job.MimeType, "audio/") {
err = generateAudioThumbnail(fullSourcePath, destPath)
} else if strings.HasSuffix(strings.ToLower(job.FilePath), ".pdf") {
err = generatePdfThumbnail(fullSourcePath, destPath)
} else if strings.HasSuffix(job.FilePath, ".docx") || strings.HasSuffix(job.FilePath, ".pptx") || strings.HasSuffix(job.FilePath, ".xlsx") {
err = generateOfficeThumbnail(job.FilePath, destPath, m.Config)
} else {
@ -213,38 +211,6 @@ func generateAudioThumbnail(src, dest string) error {
return nil
}
func generatePdfThumbnail(src, dest string) error {
// Use Ghostscript to render the first page of the PDF as a JPEG
tmpFile := dest + ".tmp.jpg"
cmd := exec.Command("gs",
"-dNOPAUSE", "-dBATCH", "-dSAFER", "-dQUIET",
"-sDEVICE=jpeg",
"-dFirstPage=1", "-dLastPage=1",
"-r72", // 72 DPI is enough for a thumbnail
"-dJPEGQ=85",
fmt.Sprintf("-sOutputFile=%s", tmpFile),
src,
)
timer := time.AfterFunc(30*time.Second, func() {
if cmd.Process != nil {
cmd.Process.Kill()
}
})
err := cmd.Run()
timer.Stop()
if err != nil {
os.Remove(tmpFile)
return fmt.Errorf("ghostscript failed: %w", err)
}
// Resize the rendered page to standard thumbnail size
err = generateImageThumbnail(tmpFile, dest)
os.Remove(tmpFile)
return err
}
func generateOfficeThumbnail(filePath, destPath string, cfg *config.Config) error {
// Generate a download token for the Conversion API to fetch the file from our backend