Skip to content

Commit

Permalink
fixup! lottie: add convert function
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Jul 10, 2024
1 parent 63ce923 commit d5a995f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lottie/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,21 @@ func SetPath(path string) {
//
// The outputFilename and outputWriter parameters are mutually exclusive.
func Convert(ctx context.Context, input io.Reader, outputFilename string, outputWriter io.Writer, format string, width, height int, extraArgs ...string) error {
// Verify the input parameters and calculate the actual filenames that will
// be used when shelling out to lottieconverter.
// Verify the input parameters and calculate the actual outputFilename that
// will be used when shelling out to lottieconverter.
//
// We are panicking here because it's a programming error to call this
// function with invalid parameters.
out := outputFilename
if outputFilename == "" && outputWriter == nil {
panic("lottie.Convert: either outputFile or outputWriter must be provided")
} else if outputWriter != nil {
if outputFilename != "" {
panic("lottie.Convert: only one of outputFile or outputWriter can be provided")
}
out = "-"
outputFilename = "-"
}

args := []string{"-", out, format, fmt.Sprintf("%dx%d", width, height)}
args := []string{"-", outputFilename, format, fmt.Sprintf("%dx%d", width, height)}
args = append(args, extraArgs...)

cmd := exec.CommandContext(ctx, lottieconverterPath, args...)
Expand Down

0 comments on commit d5a995f

Please sign in to comment.