缩略图生成器支持 LibRaw (#2109)

* feat: 增加 LibRaw 缩略图生成器。

* feat: 生成 RAW 图像的缩略图时,旋转缩略图的方向。

* update: RAW 缩略图支持镜像方向。
This commit is contained in:
sam
2024-07-31 12:11:33 +08:00
committed by GitHub
parent 23d009d611
commit 12e3f10ad7
4 changed files with 304 additions and 0 deletions

View File

@@ -23,6 +23,8 @@ func TestGenerator(ctx context.Context, name, executable string) (string, error)
return testFfmpegGenerator(ctx, executable)
case "libreOffice":
return testLibreOfficeGenerator(ctx, executable)
case "libRaw":
return testLibRawGenerator(ctx, executable)
default:
return "", ErrUnknownGenerator
}
@@ -72,3 +74,18 @@ func testLibreOfficeGenerator(ctx context.Context, executable string) (string, e
return output.String(), nil
}
func testLibRawGenerator(ctx context.Context, executable string) (string, error) {
cmd := exec.CommandContext(ctx, executable)
var output bytes.Buffer
cmd.Stdout = &output
if err := cmd.Run(); err != nil {
return "", fmt.Errorf("failed to invoke libraw executable: %w", err)
}
if !strings.Contains(output.String(), "LibRaw") {
return "", ErrUnknownOutput
}
return output.String(), nil
}