Browse Source

fix image serving performance problem introduced in last release.

pull/2/head
Chris Lu 11 years ago
parent
commit
1c30a780a7
  1. 2
      go/weed/weed_server/volume_server_handlers.go

2
go/weed/weed_server/volume_server_handlers.go

@ -125,7 +125,6 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
} }
} }
if ext == ".png" || ext == ".jpg" || ext == ".gif" { if ext == ".png" || ext == ".jpg" || ext == ".gif" {
if srcImage, _, err := image.Decode(bytes.NewReader(n.Data)); err == nil {
width, height := 0, 0 width, height := 0, 0
if r.FormValue("width") != "" { if r.FormValue("width") != "" {
width, _ = strconv.Atoi(r.FormValue("width")) width, _ = strconv.Atoi(r.FormValue("width"))
@ -134,6 +133,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
height, _ = strconv.Atoi(r.FormValue("height")) height, _ = strconv.Atoi(r.FormValue("height"))
} }
if width != 0 || height != 0 { if width != 0 || height != 0 {
if srcImage, _, err := image.Decode(bytes.NewReader(n.Data)); err == nil {
bounds := srcImage.Bounds() bounds := srcImage.Bounds()
var dstImage *image.NRGBA var dstImage *image.NRGBA
if width == height && bounds.Dx() != bounds.Dy() { if width == height && bounds.Dx() != bounds.Dy() {

Loading…
Cancel
Save