Skip to content

Commit

Permalink
Image-helper clear
Browse files Browse the repository at this point in the history
  • Loading branch information
janmisek1 committed Jul 31, 2017
1 parent c9fd9cb commit f6a33ed
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
17 changes: 1 addition & 16 deletions app/helper/image-helper/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"image"
"os"
"errors"
"github.com/disintegration/imaging"
)

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

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

inputRatio := float64(x) / float64(y)
outputRatio := float64(width) / float64(height)

var resizedImage image.Image
switch {
case inputRatio < outputRatio:
tmpImg := resize.Resize(width, 0, m.Image, resize.Lanczos2)
resizedImage = imaging.CropCenter(tmpImg, int(width), int(height))
case inputRatio > outputRatio:
tmpImg := resize.Resize(0, height, m.Image, resize.Lanczos2)
resizedImage = imaging.CropCenter(tmpImg, int(width), int(height))
default:
resizedImage = resize.Resize(width, height, m.Image, resize.Lanczos2)
}
resizedImage := resize.Resize(width, height, m.Image, resize.Lanczos2)

return save(path, resizedImage, m.File.Extension)
}
Expand Down
24 changes: 0 additions & 24 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
"comment": "",
"ignore": "test",
"package": [
{
"checksumSHA1": "YmarTNe8NlR3nkpX6MoCvhisfoA=",
"path": "github.com/disintegration/imaging",
"revision": "ac27d1805a555e1754fa177216ee07f4e63c30b5",
"revisionTime": "2017-03-19T14:47:19Z"
},
{
"checksumSHA1": "Oqx/4M+xDiB2ME3YkffeZmz/ohk=",
"path": "github.com/jessevdk/go-flags",
Expand All @@ -19,24 +13,6 @@
"path": "github.com/nfnt/resize",
"revision": "891127d8d1b52734debe1b3c3d7e747502b6c366",
"revisionTime": "2016-07-24T20:39:20Z"
},
{
"checksumSHA1": "UD/pejajPyS7WaWVXq2NU1eK4Ic=",
"path": "golang.org/x/image/bmp",
"revision": "426cfd8eeb6e08ab1932954e09e3c2cb2bc6e36d",
"revisionTime": "2017-05-14T06:33:48Z"
},
{
"checksumSHA1": "SmD/LkP3vgBGPKT6I38wH7Jb6QI=",
"path": "golang.org/x/image/tiff",
"revision": "426cfd8eeb6e08ab1932954e09e3c2cb2bc6e36d",
"revisionTime": "2017-05-14T06:33:48Z"
},
{
"checksumSHA1": "PF6VjvpNpOdR8epWH1Liyy7x1Qg=",
"path": "golang.org/x/image/tiff/lzw",
"revision": "426cfd8eeb6e08ab1932954e09e3c2cb2bc6e36d",
"revisionTime": "2017-05-14T06:33:48Z"
}
],
"rootPath": "github.com/beplus/makeicon"
Expand Down

0 comments on commit f6a33ed

Please sign in to comment.