Skip to content

Commit 683622d

Browse files
committed
Removed go-bindata, using Blur instead of logo
1 parent 97c0bdf commit 683622d

File tree

4 files changed

+11
-258
lines changed

4 files changed

+11
-258
lines changed

Diff for: assets/logo.png

-38.7 KB
Binary file not shown.

Diff for: bindata.go

-246
This file was deleted.

Diff for: go.sum

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeap
2222
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2323
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
2424
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
25-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2625
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2726
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2827
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

Diff for: resize.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/base64"
66
"fmt"
77
"image"
8-
"image/color"
98
"net/http"
109

1110
"github.com/disintegration/imaging"
@@ -17,12 +16,6 @@ const minHeight = 250
1716

1817
func ConvertImage(url string) image.Image {
1918
fmt.Printf("====> Should convert url: %s.\n", url)
20-
asset, err := Asset("assets/logo.png")
21-
if err != nil {
22-
fmt.Println("Can't load asset, falling back to black square")
23-
return imaging.New(width, height, color.Black)
24-
}
25-
background, _ := imaging.Decode(bytes.NewReader(asset))
2619

2720
fmt.Printf("Started request.\n")
2821
imageResp, err := http.Get(url)
@@ -33,14 +26,21 @@ func ConvertImage(url string) image.Image {
3326

3427
fmt.Printf("Finished request.\n")
3528
image, _ := imaging.Decode(imageResp.Body)
36-
image_h := image.Bounds().Max.Y
29+
imageH, imageW := image.Bounds().Max.Y, image.Bounds().Max.Y
3730

38-
if image_h < minHeight {
31+
if imageH < minHeight {
3932
image = imaging.Resize(image, 0, minHeight, imaging.Lanczos)
40-
image_h = image.Bounds().Max.Y
33+
imageH = image.Bounds().Max.Y
34+
} else if imageH > height || imageW > width {
35+
image = imaging.Fit(image, width, height, imaging.Lanczos)
36+
imageH = image.Bounds().Max.Y
4137
}
4238

43-
output := imaging.Resize(background, 0, image_h, imaging.Lanczos)
39+
bgWidth := int(float64(width) / (float64(height) / float64(imageH)))
40+
background := imaging.Resize(image, bgWidth, imageH, imaging.Lanczos)
41+
background = imaging.Blur(background, 20)
42+
43+
output := imaging.Resize(background, 0, imageH, imaging.Lanczos)
4444
output = imaging.PasteCenter(output, image)
4545
fmt.Printf("====> Returning image %s.\n", output.Bounds().Max)
4646
return output

0 commit comments

Comments
 (0)