feat(thumb): enhance native thumbnail generater with encoding format and quality (#2868)
* feat(thumb): enhance native thumbnail generater with encoding format and quality * Update thumbnail.go * Update obs.go
This commit is contained in:
@@ -277,10 +277,20 @@ func (handler *Driver) Delete(ctx context.Context, files ...string) ([]string, e
|
||||
// Thumb 获取文件缩略图
|
||||
func (handler *Driver) Thumb(ctx context.Context, expire *time.Time, ext string, e fs.Entity) (string, error) {
|
||||
w, h := handler.settings.ThumbSize(ctx)
|
||||
thumbParam := fmt.Sprintf("imageView2/1/w/%d/h/%d", w, h)
|
||||
|
||||
enco := handler.settings.ThumbEncode(ctx)
|
||||
switch enco.Format {
|
||||
case "jpg", "webp":
|
||||
thumbParam += fmt.Sprintf("/format/%s/q/%d", enco.Format, enco.Quality)
|
||||
case "png":
|
||||
thumbParam += fmt.Sprintf("/format/%s", enco.Format)
|
||||
}
|
||||
|
||||
return handler.signSourceURL(
|
||||
e.Source(),
|
||||
url.Values{
|
||||
fmt.Sprintf("imageView2/1/w/%d/h/%d", w, h): []string{},
|
||||
thumbParam: []string{},
|
||||
},
|
||||
expire,
|
||||
), nil
|
||||
|
||||
Reference in New Issue
Block a user