From 4162766c46e5b3ece57de69de99754bf239eb44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=BF=9C=E5=86=9B?= Date: Fri, 17 Jul 2020 19:57:35 +0800 Subject: [PATCH] Fix the bug of "http://xx/xx,xxx.PNG?width=100" If you want to do a resize a UPPER ext pic file, there is a bug caused by commit 308688c8d0b29caa06739338748cb3882c3a8559 (also see https://github.com/chrislusf/seaweedfs/blob/master/weed/images/resizing.go#L43) --- weed/server/volume_server_handlers_read.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go index 7ef1170b3..d508849bc 100644 --- a/weed/server/volume_server_handlers_read.go +++ b/weed/server/volume_server_handlers_read.go @@ -208,7 +208,9 @@ func (vs *VolumeServer) tryHandleChunkedFile(n *needle.Needle, fileName string, func conditionallyResizeImages(originalDataReaderSeeker io.ReadSeeker, ext string, r *http.Request) io.ReadSeeker { rs := originalDataReaderSeeker - + if len(ext) > 0 { + ext = strings.ToLower(ext) + } width, height, mode, shouldResize := shouldResizeImages(ext, r) if shouldResize { rs, _, _ = images.Resized(ext, originalDataReaderSeeker, width, height, mode) @@ -217,9 +219,6 @@ func conditionallyResizeImages(originalDataReaderSeeker io.ReadSeeker, ext strin } func shouldResizeImages(ext string, r *http.Request) (width, height int, mode string, shouldResize bool) { - if len(ext) > 0 { - ext = strings.ToLower(ext) - } if ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif" { if r.FormValue("width") != "" { width, _ = strconv.Atoi(r.FormValue("width"))