|
@@ -17,8 +17,8 @@ import (
|
|
|
"net/http"
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-func GetImageFromBase64(base64Img string) (image.Image, error) {
|
|
|
+
|
|
|
+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
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func GetImageFromBytes(imgBytes []byte) (image.Image, error) {
|
|
|
+
|
|
|
+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) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-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{}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func CircleImage(src image.Image) image.Image {
|
|
|
+
|
|
|
+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
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func Image2RGBA(img image.Image) *image.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
|