poc of functions
This commit is contained in:
46
internal/thumbnail/thumbnail.go
Normal file
46
internal/thumbnail/thumbnail.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package thumbnail
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/sotigr/slic3r-api/internal/cli"
|
||||
)
|
||||
|
||||
// ThumbnailService generates preview images of 3D model files.
|
||||
type ThumbnailService interface {
|
||||
Generate(ctx context.Context, modelPath, outputPath string) error
|
||||
}
|
||||
|
||||
type f3dService struct{}
|
||||
|
||||
// NewThumbnailService creates a ThumbnailService backed by the f3d renderer.
|
||||
func NewThumbnailService() ThumbnailService {
|
||||
return &f3dService{}
|
||||
}
|
||||
|
||||
func (s *f3dService) Generate(ctx context.Context, modelPath, outputPath string) error {
|
||||
pipe := cli.Pipe{
|
||||
Command: "f3d",
|
||||
Args: []string{
|
||||
modelPath,
|
||||
"--resolution=128,128",
|
||||
"-a",
|
||||
"--anti-aliasing-mode=taa",
|
||||
"--filename=false",
|
||||
"--metadata=false",
|
||||
"--color=#999",
|
||||
"-t",
|
||||
"--grid=false",
|
||||
"--axis=false",
|
||||
"--no-background",
|
||||
"--output=" + outputPath,
|
||||
},
|
||||
}
|
||||
|
||||
_, _, err := pipe.Execute(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("f3d: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user