package picture import ( "servicebase/pkg/datasource" "servicebase/pkg/log" "fmt" "testing" "github.com/disintegration/imaging" "github.com/spf13/viper" ) func init() { viper.Set("db.connectString", "zhzl:Zhzl_2022@tcp(cq.anxpp.com:3306)/data_front?charset=utf8mb4&parseTime=True&loc=Local") log.Init() datasource.InitMySQl() } func TestThumbTask(t *testing.T) { path := "../../../data/IMAGE/d4d7c746cce146a190cf97154c6f07c1.jfif" tsrc, err := imaging.Open(path) if err != nil { println(err) return } // 以下质量由低到高 //dstImage := imaging.Resize(tsrc, 0, 100, imaging.NearestNeighbor) //err = imaging.Save(dstImage, fmt.Sprintf("%s%s.%s", "../../../data/IMAGE/", "NearestNeighbor", "jpg")) //if err != nil { // println(err.Error()) //} //dstImage = imaging.Resize(tsrc, 0, 100, imaging.Linear) //err = imaging.Save(dstImage, fmt.Sprintf("%s%s.%s", "../../../data/IMAGE/", "Linear", "jpg")) //if err != nil { // println(err.Error()) //} //dstImage = imaging.Resize(tsrc, 0, 100, imaging.CatmullRom) //err = imaging.Save(dstImage, fmt.Sprintf("%s%s.%s", "../../../data/IMAGE/", "CatmullRom", "jpg")) //if err != nil { // println(err.Error()) //} dstImage := imaging.Resize(tsrc, 0, 100, imaging.Lanczos) err = imaging.Save(dstImage, fmt.Sprintf("%s%s.%s", "../../../data/IMAGE/", "Lanczos", "jpg")) if err != nil { println(err.Error()) } dstImage = imaging.Resize(tsrc, 0, 100, imaging.Lanczos) err = imaging.Save(dstImage, fmt.Sprintf("%s%s.%s", "../../../data/IMAGE/", "Lanczos", "png")) if err != nil { println(err.Error()) } } func Test_curIndexPID(t *testing.T) { gotPid, err := curIndexPID() println(gotPid, err) }