Browse Source

修改函数名

yjp 1 year ago
parent
commit
09fa98f3f9
1 changed files with 14 additions and 14 deletions
  1. 14 14
      imgutils/imgutils.go

+ 14 - 14
imgutils/imgutils.go

@@ -17,8 +17,8 @@ import (
 	"net/http"
 )
 
-// GetImageFromBase64 base64->image.image
-func GetImageFromBase64(base64Img string) (image.Image, error) {
+// GetFromBase64 base64->image.image
+func GetFromBase64(base64Img string) (image.Image, error) {
 	empty := image.NewRGBA(image.Rectangle{
 		Min: image.Point{},
 		Max: image.Point{},
@@ -40,8 +40,8 @@ func GetImageFromBase64(base64Img string) (image.Image, error) {
 	return img, nil
 }
 
-// GetImageFromBytes bytes->image.image
-func GetImageFromBytes(imgBytes []byte) (image.Image, error) {
+// GetFromBytes bytes->image.image
+func GetFromBytes(imgBytes []byte) (image.Image, error) {
 	empty := image.NewRGBA(image.Rectangle{
 		Min: image.Point{},
 		Max: image.Point{},
@@ -59,7 +59,7 @@ func GetImageFromBytes(imgBytes []byte) (image.Image, error) {
 }
 
 // ResizeImg 缩放原始图片 只给width,height,按比例缩放
-func ResizeImg(src image.Image, width, height uint) image.Image {
+func Resize(src image.Image, width, height uint) image.Image {
 	return resize.Resize(width, height, src, resize.Lanczos3)
 }
 
@@ -110,8 +110,8 @@ func (c *circle) At(x, y int) color.Color {
 	return color.Alpha{}
 }
 
-// CircleImage 从图片中间取圆形遮罩
-func CircleImage(src image.Image) image.Image {
+// CircleMask 从图片中间取圆形遮罩
+func CircleMask(src image.Image) image.Image {
 	c := circle{
 		p: src.Bounds().Max.Div(2),
 		r: src.Bounds().Dx() / 2,
@@ -134,8 +134,8 @@ func MiddleCoverCoordinate(background image.Image, coverImg image.Image) image.R
 	}
 }
 
-// Image2RGBA Image2RGBA
-func Image2RGBA(img image.Image) *image.RGBA {
+// RGBA RGBA
+func RGBA(img image.Image) *image.RGBA {
 	baseSrcBounds := img.Bounds().Max
 
 	newWidth := baseSrcBounds.X
@@ -192,9 +192,9 @@ func (tb *TextBrush) DrawFontOnRGBA(rgba *image.RGBA) error {
 	return nil
 }
 
-func DrawStringOnImageAndSave(img image.Image, infos []*TextBrush) (image.Image, error) {
+func DrawStringAndSave(img image.Image, infos []*TextBrush) (image.Image, error) {
 	// 创建画板
-	desImg := Image2RGBA(img)
+	desImg := RGBA(img)
 	for _, brush := range infos {
 		err := brush.DrawFontOnRGBA(desImg)
 		if err != nil {
@@ -205,7 +205,7 @@ func DrawStringOnImageAndSave(img image.Image, infos []*TextBrush) (image.Image,
 	return desImg, nil
 }
 
-func CreateWhiteBackgroundImg(w int, h int) *image.RGBA {
+func CreateWhiteBackground(w int, h int) *image.RGBA {
 	newRgba := image.NewRGBA(image.Rectangle{
 		Min: image.Point{},
 		Max: image.Point{X: w, Y: h},
@@ -242,7 +242,7 @@ func MergeImagesHighLow(highImg image.Image, lowImg image.Image) image.Image {
 	}
 
 	y = highImg.Bounds().Dy() + lowImg.Bounds().Dy()
-	destDraw := CreateWhiteBackgroundImg(x, y)
+	destDraw := CreateWhiteBackground(x, y)
 
 	// 先画风景图
 	draw.Draw(destDraw, destDraw.Bounds(), highImg, highImg.Bounds().Min, draw.Over)
@@ -256,7 +256,7 @@ func MergeImagesHighLow(highImg image.Image, lowImg image.Image) image.Image {
 	return destDraw
 }
 
-func GetUrlBase64(url string) (string, error) {
+func GetBase64FromUrl(url string) (string, error) {
 	res, err := http.Get(url)
 	if err != nil {
 		return "", err