From 625bd4063d729d528a013cbc0e0c90e17d3d056f Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Fri, 11 Aug 2023 00:27:32 -0400 Subject: [PATCH] add collage package --- collage/collage.go | 36 ++++++++++++++++++++++++++++++++++++ collage/collage_test.go | 24 ++++++++++++++++++++++++ go.mod | 2 +- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 collage/collage.go create mode 100644 collage/collage_test.go diff --git a/collage/collage.go b/collage/collage.go new file mode 100644 index 0000000..95e6018 --- /dev/null +++ b/collage/collage.go @@ -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) { +} diff --git a/collage/collage_test.go b/collage/collage_test.go new file mode 100644 index 0000000..e9ba6a4 --- /dev/null +++ b/collage/collage_test.go @@ -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) +} diff --git a/go.mod b/go.mod index 216f73c..d302191 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.balki.me/collage-maker -go 1.20 +go 1.21 require ( github.com/oliamb/cutter v0.2.2