mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-02 00:02:39 +02: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
|
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
|
// decode image
|
||||||
m, format, err := image.Decode(bytes.NewReader(img.Bytes))
|
m, format, err := image.Decode(bytes.NewReader(img.Bytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -63,13 +56,15 @@ func Transform(img data.Image, opt *data.Options) (*data.Image, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// resize
|
// resize
|
||||||
if opt.Fit {
|
if opt.Width != 0 && opt.Height != 0 {
|
||||||
m = imaging.Fit(m, w, h, imaging.Lanczos)
|
if opt.Fit {
|
||||||
} else {
|
m = imaging.Fit(m, w, h, imaging.Lanczos)
|
||||||
if opt.Width == 0 || opt.Height == 0 {
|
|
||||||
m = imaging.Resize(m, w, h, imaging.Lanczos)
|
|
||||||
} else {
|
} 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…
Add table
Add a link
Reference in a new issue