diff --git a/imageproxy.go b/imageproxy.go index 699ff0c..fba2f03 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -113,7 +113,7 @@ func NewProxy(transport http.RoundTripper, cache Cache) *Proxy { Transport: &TransformingTransport{ Transport: transport, CachingClient: client, - log: func(format string, v ...interface{}) { + log: func(format string, v ...any) { if proxy.Verbose { proxy.logf(format, v...) } @@ -445,7 +445,7 @@ func should304(req *http.Request, resp *http.Response) bool { return false } -func (p *Proxy) log(v ...interface{}) { +func (p *Proxy) log(v ...any) { if p.Logger != nil { p.Logger.Print(v...) } else { @@ -453,7 +453,7 @@ func (p *Proxy) log(v ...interface{}) { } } -func (p *Proxy) logf(format string, v ...interface{}) { +func (p *Proxy) logf(format string, v ...any) { if p.Logger != nil { p.Logger.Printf(format, v...) } else { @@ -474,7 +474,7 @@ type TransformingTransport struct { // responses are properly cached. CachingClient *http.Client - log func(format string, v ...interface{}) + log func(format string, v ...any) } // RoundTrip implements the http.RoundTripper interface. diff --git a/transform.go b/transform.go index c7da391..a5e87d4 100644 --- a/transform.go +++ b/transform.go @@ -212,14 +212,8 @@ func cropParams(m image.Image, opt Options) image.Rectangle { } // bottom right coordinate of crop - x1 := x0 + w - if x1 > imgW { - x1 = imgW - } - y1 := y0 + h - if y1 > imgH { - y1 = imgH - } + x1 := min(x0+w, imgW) + y1 := min(y0+h, imgH) return image.Rect(x0, y0, x1, y1) }