Skip to content

Commit

Permalink
change report.ImageMatch to report.CombineImagesInput
Browse files Browse the repository at this point in the history
  • Loading branch information
sfomuseumbot committed Sep 3, 2024
1 parent 1d9d22b commit 699f93a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions report/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@ import (
"image/color"
)

type ImageMatch struct {
// CombineImagesInput is a struct containing image data to be passed to the `CombineImages` method.
type CombineImagesInput struct {
// The underlying `image.Image` instance being combined.
Image image.Image
// The "score" of the image being combined relative to another image (typically the first in a list of the `CombineImagesInput` instances).
Similarity float32
}

// CombineImages() sorts all the images defined by 'images' according to their "similarity" score in ascending
// order and then combines them in to a montage with (1) row and (n) columns. Each image is scaled to a maximum
// dimension of 250 pixels.
func CombineImages(images []*ImageMatch) (image.Image, error) {
func CombineImages(input []*CombineImagesInput) (image.Image, error) {

// https://github.com/ashleymcnamara/artwork/blob/master/collage.go

cols := len(images)
cols := len(input)
cell := 250

rows := (len(images) + cols - 1) / cols
rows := (cols + cols - 1) / cols
dst := image.NewRGBA(image.Rect(0, 0, cell*cols, cell*rows))
draw.Draw(dst, dst.Bounds(), image.NewUniform(color.RGBA{0xFF, 0xFF, 0xFF, 0xFF}), image.Point{}, draw.Src)

for i, m := range images {
for i, m := range input {

im := m.Image

Expand Down

0 comments on commit 699f93a

Please sign in to comment.