mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-16 21:56:43 -05:00
rename jpegQuality to defaultQuality
Also fix a few go vet errors
This commit is contained in:
parent
e7b0a5b88c
commit
d74dd6e985
3 changed files with 9 additions and 10 deletions
|
@ -181,7 +181,7 @@ func TestProxy_ServeHTTP(t *testing.T) {
|
|||
p.ServeHTTP(resp, req)
|
||||
|
||||
if got, want := resp.Code, tt.code; got != want {
|
||||
t.Errorf("ServeHTTP(%q) returned status %d, want %d", req, got, want)
|
||||
t.Errorf("ServeHTTP(%v) returned status %d, want %d", req, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,10 +200,10 @@ func TestProxy_ServeHTTP_is304(t *testing.T) {
|
|||
p.ServeHTTP(resp, req)
|
||||
|
||||
if got, want := resp.Code, http.StatusNotModified; got != want {
|
||||
t.Errorf("ServeHTTP(%q) returned status %d, want %d", req, got, want)
|
||||
t.Errorf("ServeHTTP(%v) returned status %d, want %d", req, got, want)
|
||||
}
|
||||
if got, want := resp.Header().Get("Etag"), `"tag"`; got != want {
|
||||
t.Errorf("ServeHTTP(%q) returned etag header %v, want %v", req, got, want)
|
||||
t.Errorf("ServeHTTP(%v) returned etag header %v, want %v", req, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ func TestTransformingTransport(t *testing.T) {
|
|||
t.Errorf("RoundTrip(%v) did not return expected error", tt.url)
|
||||
}
|
||||
if got, want := resp.StatusCode, tt.code; got != want {
|
||||
t.Errorf("RoundTrip(%v) returned status code %d, want %d", got, want)
|
||||
t.Errorf("RoundTrip(%v) returned status code %d, want %d", tt.url, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import (
|
|||
"github.com/disintegration/imaging"
|
||||
)
|
||||
|
||||
// compression quality of resized jpegs
|
||||
const jpegQuality = 95
|
||||
// default compression quality of resized jpegs
|
||||
const defaultQuality = 95
|
||||
|
||||
// resample filter used when resizing images
|
||||
var resampleFilter = imaging.Lanczos
|
||||
|
@ -54,9 +54,8 @@ func Transform(img []byte, opt Options) ([]byte, error) {
|
|||
gif.Encode(buf, m, nil)
|
||||
case "jpeg":
|
||||
quality := opt.Quality
|
||||
|
||||
if quality == 0 {
|
||||
quality = jpegQuality
|
||||
quality = defaultQuality
|
||||
}
|
||||
|
||||
jpeg.Encode(buf, m, &jpeg.Options{Quality: quality})
|
||||
|
|
|
@ -60,10 +60,10 @@ func TestTransform(t *testing.T) {
|
|||
|
||||
out, err := Transform(in, emptyOptions)
|
||||
if err != nil {
|
||||
t.Errorf("Transform with encoder %s returned unexpected error: %v", err)
|
||||
t.Errorf("Transform with encoder %s returned unexpected error: %v", tt.name, err)
|
||||
}
|
||||
if !reflect.DeepEqual(in, out) {
|
||||
t.Errorf("Transform with with encoder %s with empty options returned modified result")
|
||||
t.Errorf("Transform with with encoder %s with empty options returned modified result", tt.name)
|
||||
}
|
||||
|
||||
out, err = Transform(in, Options{Width: -1, Height: -1})
|
||||
|
|
Loading…
Reference in a new issue