add collage package

This commit is contained in:
Balakrishnan Balasubramanian 2023-08-11 00:27:32 -04:00
parent 0791951d33
commit 625bd4063d
3 changed files with 61 additions and 1 deletions

36
collage/collage.go Normal file
View 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
View 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)
}

2
go.mod
View File

@ -1,6 +1,6 @@
module go.balki.me/collage-maker
go 1.20
go 1.21
require (
github.com/oliamb/cutter v0.2.2