feat(thumb): support output webp thumbnails for vips generator (#2657)
This commit is contained in:
@@ -41,7 +41,7 @@ func (f *FfmpegGenerator) Generate(ctx context.Context, es entitysource.EntitySo
|
||||
tempOutputPath := filepath.Join(
|
||||
util.DataPath(f.settings.TempPath(ctx)),
|
||||
thumbTempFolder,
|
||||
fmt.Sprintf("thumb_%s.%s", uuid.Must(uuid.NewV4()).String(), f.settings.ThumbEncode(ctx).Format),
|
||||
fmt.Sprintf("thumb_%s.png", uuid.Must(uuid.NewV4()).String()),
|
||||
)
|
||||
|
||||
if err := util.CreatNestedFolder(filepath.Dir(tempOutputPath)); err != nil {
|
||||
|
||||
@@ -69,10 +69,9 @@ func (l *LibreOfficeGenerator) Generate(ctx context.Context, es entitysource.Ent
|
||||
}
|
||||
|
||||
// Convert the document to an image
|
||||
encode := l.settings.ThumbEncode(ctx)
|
||||
cmd := exec.CommandContext(ctx, l.settings.LibreOfficePath(ctx), "--headless",
|
||||
"--nologo", "--nofirststartwizard", "--invisible", "--norestore", "--convert-to",
|
||||
encode.Format, "--outdir", tempOutputPath, tempInputPath)
|
||||
"png", "--outdir", tempOutputPath, tempInputPath)
|
||||
|
||||
// Redirect IO
|
||||
var stdErr bytes.Buffer
|
||||
@@ -86,7 +85,7 @@ func (l *LibreOfficeGenerator) Generate(ctx context.Context, es entitysource.Ent
|
||||
return &Result{
|
||||
Path: filepath.Join(
|
||||
tempOutputPath,
|
||||
strings.TrimSuffix(filepath.Base(tempInputPath), filepath.Ext(tempInputPath))+"."+encode.Format,
|
||||
strings.TrimSuffix(filepath.Base(tempInputPath), filepath.Ext(tempInputPath))+".png",
|
||||
),
|
||||
Continue: true,
|
||||
Cleanup: []func(){func() { _ = os.RemoveAll(tempOutputPath) }},
|
||||
|
||||
@@ -38,8 +38,8 @@ func (v *VipsGenerator) Generate(ctx context.Context, es entitysource.EntitySour
|
||||
|
||||
outputOpt := ".png"
|
||||
encode := v.settings.ThumbEncode(ctx)
|
||||
if encode.Format == "jpg" {
|
||||
outputOpt = fmt.Sprintf(".jpg[Q=%d]", encode.Quality)
|
||||
if encode.Format == "jpg" || encode.Format == "webp" {
|
||||
outputOpt = fmt.Sprintf(".%s[Q=%d]", encode.Format, encode.Quality)
|
||||
}
|
||||
|
||||
input := "[descriptor=0]"
|
||||
|
||||
Reference in New Issue
Block a user