SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
A hidden feature: dynamically resize image.
Chris Lu87b98711f79b
diff --git a/go/weed/weed_server/volume_server_handlers.go b/go/weed/weed_server/volume_server_handlers.goindex e2fd6e6f91..3c94a75f1c 100644--- a/go/weed/weed_server/volume_server_handlers.go+++ b/go/weed/weed_server/volume_server_handlers.go@@ -1,11 +1,17 @@package weed_serverimport (+ "bytes""code.google.com/p/weed-fs/go/glog""code.google.com/p/weed-fs/go/operation""code.google.com/p/weed-fs/go/stats""code.google.com/p/weed-fs/go/storage""code.google.com/p/weed-fs/go/topology"+ "github.com/disintegration/imaging"+ "image"+ "image/gif"+ "image/jpeg"+ "image/png""mime""net/http""strconv"@@ -118,6 +124,36 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,}}}+ if ext == ".png" || ext == ".jpg" || ext == ".gif" {+ if srcImage, _, err := image.Decode(bytes.NewReader(n.Data)); err == nil {+ width, height := 0, 0+ if r.FormValue("width") != "" {+ width, _ = strconv.Atoi(r.FormValue("width"))+ }+ if r.FormValue("height") != "" {+ height, _ = strconv.Atoi(r.FormValue("height"))+ }+ if width != 0 || height != 0 {+ bounds := srcImage.Bounds()+ var dstImage *image.NRGBA+ if width == height && bounds.Dx() != bounds.Dy() {+ dstImage = imaging.Thumbnail(srcImage, width, height, imaging.Lanczos)+ } else {+ dstImage = imaging.Resize(srcImage, width, height, imaging.Lanczos)+ }+ var buf bytes.Buffer+ switch ext {+ case ".png":+ png.Encode(&buf, dstImage)+ case ".jpg":+ jpeg.Encode(&buf, dstImage, nil)+ case ".gif":+ gif.Encode(&buf, dstImage, nil)+ }+ n.Data = buf.Bytes()+ }+ }+ }w.Header().Set("Content-Length", strconv.Itoa(len(n.Data)))if isGetMethod {if _, e = w.Write(n.Data); e != nil {