mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-16 21:56:43 -05:00
properly handle thumbnail requests
if both height and width are specified, we assume you want an image at exactly those dimensions, so use imaging.Thumbnail, which will resize and crop the image. if either height or width are left unspecified, then it's just a simple resize request.
This commit is contained in:
parent
2794d47390
commit
8310f6eb79
1 changed files with 5 additions and 1 deletions
|
@ -39,7 +39,11 @@ func Transform(img data.Image, opt *data.Options) (*data.Image, error) {
|
|||
if opt.Fit {
|
||||
m = imaging.Fit(m, opt.Width, opt.Height, imaging.Lanczos)
|
||||
} else {
|
||||
if opt.Width == 0 || opt.Height == 0 {
|
||||
m = imaging.Resize(m, opt.Width, opt.Height, imaging.Lanczos)
|
||||
} else {
|
||||
m = imaging.Thumbnail(m, opt.Width, opt.Height, imaging.Lanczos)
|
||||
}
|
||||
}
|
||||
|
||||
// encode image
|
||||
|
|
Loading…
Reference in a new issue