mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-03 16:52:40 +02:00
add tests for transformImage
This commit is contained in:
parent
882c2b3782
commit
dd1df4631b
2 changed files with 144 additions and 3 deletions
|
|
@ -27,6 +27,9 @@ import (
|
|||
// compression quality of resized jpegs
|
||||
const jpegQuality = 95
|
||||
|
||||
// resample filter used when resizing images
|
||||
var resampleFilter = imaging.Lanczos
|
||||
|
||||
// Transform the provided image. img should contain the raw bytes of an
|
||||
// encoded image in one of the supported formats (gif, jpeg, or png). The
|
||||
// bytes of a similarly encoded image is returned.
|
||||
|
|
@ -91,12 +94,12 @@ func transformImage(m image.Image, opt Options) image.Image {
|
|||
// resize
|
||||
if w != 0 || h != 0 {
|
||||
if opt.Fit {
|
||||
m = imaging.Fit(m, w, h, imaging.Lanczos)
|
||||
m = imaging.Fit(m, w, h, resampleFilter)
|
||||
} else {
|
||||
if w == 0 || h == 0 {
|
||||
m = imaging.Resize(m, w, h, imaging.Lanczos)
|
||||
m = imaging.Resize(m, w, h, resampleFilter)
|
||||
} else {
|
||||
m = imaging.Thumbnail(m, w, h, imaging.Lanczos)
|
||||
m = imaging.Thumbnail(m, w, h, resampleFilter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue