Feature Request: Vips AVIF Support (#6337)

This commit is contained in:
Gykes
2025-11-27 22:00:23 -06:00
committed by GitHub
parent de8139cf1b
commit c6ae43c1d6
2 changed files with 44 additions and 4 deletions

View File

@@ -96,10 +96,14 @@ func (e *ThumbnailEncoder) GetThumbnail(f models.File, maxSize int) ([]byte, err
// AVIF cannot be read from stdin, must use file path
// AVIF in zip files is not supported
// Note: No Windows check needed here since we use file path, not stdin
if format == "avif" {
if f.Base().ZipFileID != nil {
return nil, fmt.Errorf("%w: AVIF in zip file", ErrNotSupportedForThumbnail)
}
if e.vips != nil {
return e.vips.ImageThumbnailPath(f.Base().Path, maxSize)
}
return e.ffmpegImageThumbnailPath(f.Base().Path, maxSize)
}
}
@@ -110,11 +114,15 @@ func (e *ThumbnailEncoder) GetThumbnail(f models.File, maxSize int) ([]byte, err
}
// vips has issues loading files from stdin on Windows
if e.vips != nil && runtime.GOOS != "windows" {
return e.vips.ImageThumbnail(buf, maxSize)
} else {
return e.ffmpegImageThumbnail(buf, maxSize)
if e.vips != nil {
if runtime.GOOS == "windows" && f.Base().ZipFileID == nil {
return e.vips.ImageThumbnailPath(f.Base().Path, maxSize)
}
if runtime.GOOS != "windows" {
return e.vips.ImageThumbnail(buf, maxSize)
}
}
return e.ffmpegImageThumbnail(buf, maxSize)
}
// GetPreview returns the preview clip of the provided image clip resized to