feat(thumb): support generating thumbnails using simple_dcraw from LibRAW
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user