Add image cropping. (#4117)

This commit is contained in:
monchickey
2023-01-07 01:28:07 +08:00
committed by GitHub
parent 296fdc296c
commit 3e2c9ea73d
3 changed files with 116 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
package images
import (
"bytes"
"os"
"testing"
"github.com/seaweedfs/seaweedfs/weed/util"
)
func TestCropping(t *testing.T) {
fname := "sample1.jpg"
dat, _ := os.ReadFile(fname)
cropped, _ := Cropped(".jpg", bytes.NewReader(dat), 1072, 932, 1751, 1062)
buf := new(bytes.Buffer)
buf.ReadFrom(cropped)
util.WriteFile("cropped1.jpg", buf.Bytes(), 0644)
}