feat(thumb): support generating thumbnails using simple_dcraw from LibRAW

This commit is contained in:
Aaron Liu
2025-06-24 10:47:36 +08:00
parent d1bbfd4bc4
commit 3db522609e
6 changed files with 322 additions and 11 deletions

View File

@@ -4,12 +4,13 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/cloudreve/Cloudreve/v4/inventory/types"
"net/url"
"strconv"
"strings"
"time"
"github.com/cloudreve/Cloudreve/v4/inventory/types"
"github.com/cloudreve/Cloudreve/v4/pkg/auth/requestinfo"
"github.com/cloudreve/Cloudreve/v4/pkg/boolset"
)
@@ -187,6 +188,14 @@ type (
AvatarProcess(ctx context.Context) *AvatarProcess
// UseFirstSiteUrl returns the first site URL.
AllSiteURLs(ctx context.Context) []*url.URL
// LibRawThumbGeneratorEnabled returns true if libraw thumb generator is enabled.
LibRawThumbGeneratorEnabled(ctx context.Context) bool
// LibRawThumbMaxSize returns the maximum size of libraw thumb generator.
LibRawThumbMaxSize(ctx context.Context) int64
// LibRawThumbExts returns the supported extensions of libraw thumb generator.
LibRawThumbExts(ctx context.Context) []string
// LibRawThumbPath returns the path of libraw executable.
LibRawThumbPath(ctx context.Context) string
}
UseFirstSiteUrlCtxKey = struct{}
)
@@ -387,6 +396,22 @@ func (s *settingProvider) VipsPath(ctx context.Context) string {
return s.getString(ctx, "thumb_vips_path", "vips")
}
func (s *settingProvider) LibRawThumbGeneratorEnabled(ctx context.Context) bool {
return s.getBoolean(ctx, "thumb_libraw_enabled", false)
}
func (s *settingProvider) LibRawThumbMaxSize(ctx context.Context) int64 {
return s.getInt64(ctx, "thumb_libraw_max_size", 78643200)
}
func (s *settingProvider) LibRawThumbExts(ctx context.Context) []string {
return s.getStringList(ctx, "thumb_libraw_exts", []string{})
}
func (s *settingProvider) LibRawThumbPath(ctx context.Context) string {
return s.getString(ctx, "thumb_libraw_path", "simple_dcraw")
}
func (s *settingProvider) LibreOfficeThumbGeneratorEnabled(ctx context.Context) bool {
return s.getBoolean(ctx, "thumb_libreoffice_enabled", false)
}