mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-16 21:56:43 -05:00
remove early bail out in image trasform
This commit is contained in:
parent
a0d0260f5e
commit
b9584c18cb
1 changed files with 8 additions and 13 deletions
|
@ -36,13 +36,6 @@ func Transform(img data.Image, opt *data.Options) (*data.Image, error) {
|
|||
return &img, nil
|
||||
}
|
||||
|
||||
if opt.Width == 0 && opt.Height == 0 {
|
||||
// TODO(willnorris): Currently, only resize related options are
|
||||
// supported, so bail if no sizes are specified. Remove this
|
||||
// check if we ever support non-resizing transformations.
|
||||
return &img, nil
|
||||
}
|
||||
|
||||
// decode image
|
||||
m, format, err := image.Decode(bytes.NewReader(img.Bytes))
|
||||
if err != nil {
|
||||
|
@ -63,13 +56,15 @@ func Transform(img data.Image, opt *data.Options) (*data.Image, error) {
|
|||
}
|
||||
|
||||
// resize
|
||||
if opt.Fit {
|
||||
m = imaging.Fit(m, w, h, imaging.Lanczos)
|
||||
} else {
|
||||
if opt.Width == 0 || opt.Height == 0 {
|
||||
m = imaging.Resize(m, w, h, imaging.Lanczos)
|
||||
if opt.Width != 0 && opt.Height != 0 {
|
||||
if opt.Fit {
|
||||
m = imaging.Fit(m, w, h, imaging.Lanczos)
|
||||
} else {
|
||||
m = imaging.Thumbnail(m, w, h, imaging.Lanczos)
|
||||
if opt.Width == 0 || opt.Height == 0 {
|
||||
m = imaging.Resize(m, w, h, imaging.Lanczos)
|
||||
} else {
|
||||
m = imaging.Thumbnail(m, w, h, imaging.Lanczos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue