add collage package
This commit is contained in:
parent
0791951d33
commit
625bd4063d
36
collage/collage.go
Normal file
36
collage/collage.go
Normal file
@ -0,0 +1,36 @@
|
||||
// Package collage makes a pic collage
|
||||
package collage
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
type Dimension struct {
|
||||
Width uint `json:"width"`
|
||||
Height uint `json:"height"`
|
||||
}
|
||||
|
||||
type Point struct {
|
||||
X uint `json:"x"`
|
||||
Y uint `json:"y"`
|
||||
}
|
||||
|
||||
type Rectangle struct {
|
||||
Start Point `json:"start"`
|
||||
End Point `json:"end"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
BackgroundImage string `json:"background_image"`
|
||||
Aspect Dimension `json:"aspect"`
|
||||
Dimension Dimension `json:"dimension"`
|
||||
Photos []struct {
|
||||
ImageName string `json:"image"`
|
||||
Crop Rectangle `json:"crop"`
|
||||
Frame Rectangle `json:"frame"`
|
||||
} `json:"photos"`
|
||||
}
|
||||
|
||||
func Make(request Request, source fs.FS, output io.Writer) {
|
||||
}
|
24
collage/collage_test.go
Normal file
24
collage/collage_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package collage
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed test_data/*
|
||||
var testData embed.FS
|
||||
|
||||
func TestMake(t *testing.T) {
|
||||
t.Log("Test was run")
|
||||
ifs, err := fs.Sub(testData, "test_data")
|
||||
if err != nil {
|
||||
t.Fatalf("getting test_data subdir failed %v", err)
|
||||
}
|
||||
img1f, err := ifs.Open("img1.jpg")
|
||||
if err != nil {
|
||||
t.Fatalf("opening image failed %v", err)
|
||||
}
|
||||
fmt.Printf("%#v\n", img1f)
|
||||
}
|
Loading…
Reference in New Issue
Block a user