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

@@ -25,6 +25,8 @@ func TestGenerator(ctx context.Context, name, executable string) (string, error)
return testLibreOfficeGenerator(ctx, executable)
case "ffprobe":
return testFFProbeGenerator(ctx, executable)
case "libraw":
return testLibRawGenerator(ctx, executable)
default:
return "", ErrUnknownGenerator
}
@@ -89,3 +91,20 @@ 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, "-L")
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(), "Sony") {
return "", ErrUnknownOutput
}
cameraList := strings.Split(output.String(), "\n")
return fmt.Sprintf("N/A, %d cameras supported", len(cameraList)), nil
}