diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2018-07-22 19:54:04 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-22 19:54:04 -0700 |
| commit | ff331178aac1ab733229dbea2ba5a47a354580ef (patch) | |
| tree | 9613faab9cb720796336ae9756fc8aa81fd8790f /weed/images/preprocess.go | |
| parent | 7e76a7d21be7ddba9f371dac25a5e358e5b5b49e (diff) | |
| parent | 79d18c69b4ba68e6fb84893ff7b43027b4db5387 (diff) | |
| download | seaweedfs-ff331178aac1ab733229dbea2ba5a47a354580ef.tar.xz seaweedfs-ff331178aac1ab733229dbea2ba5a47a354580ef.zip | |
Merge pull request #695 from zhangmingfeng/master
增加chunk图片文件支持width和height
Diffstat (limited to 'weed/images/preprocess.go')
| -rw-r--r-- | weed/images/preprocess.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/weed/images/preprocess.go b/weed/images/preprocess.go index 56f14eaa4..0cfb66c6b 100644 --- a/weed/images/preprocess.go +++ b/weed/images/preprocess.go @@ -3,6 +3,8 @@ package images import ( "path/filepath" "strings" + "bytes" + "io" ) /* @@ -13,15 +15,15 @@ import ( * Call this function on any file uploaded to SeaweedFS * */ -func MaybePreprocessImage(filename string, data []byte, width, height int) (resized []byte, w int, h int) { +func MaybePreprocessImage(filename string, data []byte, width, height int) (resized io.ReadSeeker, w int, h int) { ext := filepath.Ext(filename) ext = strings.ToLower(ext) switch ext { case ".png", ".gif": - return Resized(ext, data, width, height, "") + return Resized(ext, bytes.NewReader(data), width, height, "") case ".jpg", ".jpeg": data = FixJpgOrientation(data) - return Resized(ext, data, width, height, "") + return Resized(ext, bytes.NewReader(data), width, height, "") } - return data, 0, 0 + return bytes.NewReader(data), 0, 0 } |
