Skip to content

Commit f6a33ed

Browse files
committed
Image-helper clear
1 parent c9fd9cb commit f6a33ed

2 files changed

Lines changed: 1 addition & 40 deletions

File tree

app/helper/image-helper/image.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"image"
99
"os"
1010
"errors"
11-
"github.com/disintegration/imaging"
1211
)
1312

1413
type MyImage struct {
@@ -98,22 +97,8 @@ func (m MyImage) save(dir string, resized []ResizeImage) (error) {
9897
}
9998

10099
func (m MyImage) SaveInSize(path string, width uint, height uint) (error) {
101-
x, y := m.Image.Bounds().Dx(), m.Image.Bounds().Dy()
102100

103-
inputRatio := float64(x) / float64(y)
104-
outputRatio := float64(width) / float64(height)
105-
106-
var resizedImage image.Image
107-
switch {
108-
case inputRatio < outputRatio:
109-
tmpImg := resize.Resize(width, 0, m.Image, resize.Lanczos2)
110-
resizedImage = imaging.CropCenter(tmpImg, int(width), int(height))
111-
case inputRatio > outputRatio:
112-
tmpImg := resize.Resize(0, height, m.Image, resize.Lanczos2)
113-
resizedImage = imaging.CropCenter(tmpImg, int(width), int(height))
114-
default:
115-
resizedImage = resize.Resize(width, height, m.Image, resize.Lanczos2)
116-
}
101+
resizedImage := resize.Resize(width, height, m.Image, resize.Lanczos2)
117102

118103
return save(path, resizedImage, m.File.Extension)
119104
}

vendor/vendor.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
"comment": "",
33
"ignore": "test",
44
"package": [
5-
{
6-
"checksumSHA1": "YmarTNe8NlR3nkpX6MoCvhisfoA=",
7-
"path": "github.com/disintegration/imaging",
8-
"revision": "ac27d1805a555e1754fa177216ee07f4e63c30b5",
9-
"revisionTime": "2017-03-19T14:47:19Z"
10-
},
115
{
126
"checksumSHA1": "Oqx/4M+xDiB2ME3YkffeZmz/ohk=",
137
"path": "github.com/jessevdk/go-flags",
@@ -19,24 +13,6 @@
1913
"path": "github.com/nfnt/resize",
2014
"revision": "891127d8d1b52734debe1b3c3d7e747502b6c366",
2115
"revisionTime": "2016-07-24T20:39:20Z"
22-
},
23-
{
24-
"checksumSHA1": "UD/pejajPyS7WaWVXq2NU1eK4Ic=",
25-
"path": "golang.org/x/image/bmp",
26-
"revision": "426cfd8eeb6e08ab1932954e09e3c2cb2bc6e36d",
27-
"revisionTime": "2017-05-14T06:33:48Z"
28-
},
29-
{
30-
"checksumSHA1": "SmD/LkP3vgBGPKT6I38wH7Jb6QI=",
31-
"path": "golang.org/x/image/tiff",
32-
"revision": "426cfd8eeb6e08ab1932954e09e3c2cb2bc6e36d",
33-
"revisionTime": "2017-05-14T06:33:48Z"
34-
},
35-
{
36-
"checksumSHA1": "PF6VjvpNpOdR8epWH1Liyy7x1Qg=",
37-
"path": "golang.org/x/image/tiff/lzw",
38-
"revision": "426cfd8eeb6e08ab1932954e09e3c2cb2bc6e36d",
39-
"revisionTime": "2017-05-14T06:33:48Z"
4016
}
4117
],
4218
"rootPath": "github.com/beplus/makeicon"

0 commit comments

Comments
 (0)