Compare commits

..

No commits in common. "7ae08e10f4adee022d20bddaa65e2e11acc355af" and "d4bea327b368dcc18a88ce8c8f26ebe497653083" have entirely different histories.

3 changed files with 9 additions and 62 deletions

View File

@ -48,19 +48,6 @@ func ReadOrientation(filename string) (direct int, err error) {
return
}
// 旋转90度
func Rotate90(m image.Image) image.Image {
rotate90 := image.NewRGBA(image.Rect(0, 0, m.Bounds().Dy(), m.Bounds().Dx()))
// 矩阵旋转
for x := m.Bounds().Min.Y; x < m.Bounds().Max.Y; x++ {
for y := m.Bounds().Max.X - 1; y >= m.Bounds().Min.X; y-- {
// 设置像素点
rotate90.Set(m.Bounds().Max.Y-x, y, m.At(y, x))
}
}
return rotate90
}
// 旋转90度
func rotate90(m image.Image) image.Image {
rotate90 := image.NewRGBA(image.Rect(0, 0, m.Bounds().Dy(), m.Bounds().Dx()))
@ -171,32 +158,3 @@ func (u *Upload) PutBos(filePath string, mediaType string, needRemove bool) (url
url = fmt.Sprintf("%s/%s", config.ConfigData.Oss.CdnHost, objectName)
return
}
func MakeThumbnailDefault90(imagePath, savePath string) error {
prefix := strings.ToLower(path.Ext("./2.jpg"))
file, _ := os.Open(imagePath)
defer file.Close()
img, _, err := image.Decode(file)
if err != nil {
return err
}
img = rotate90(img)
newImg, _ := os.Create(savePath)
defer newImg.Close()
switch prefix {
case ".jpg", ".jpeg":
err = jpeg.Encode(newImg, img, &jpeg.Options{Quality: 100})
case "png":
err = png.Encode(newImg, img)
case "bmp":
err = bmp.Encode(newImg, img)
default:
err = jpeg.Encode(newImg, img, &jpeg.Options{Quality: 100})
}
if err != nil {
logger.Error("Encode err", err)
return err
}
return nil
}

View File

@ -1,16 +1,15 @@
package model
const (
HttpType = "http://"
HttpsType = "https://"
TmpArtworkDir = "./runtime/tmp/artworks"
TmpArtistDir = "./runtime/tmp/artists"
MediaPath = "./runtime/"
TplPath = "./data/"
ImgActionRotate = "rotate" //旋转
ImgActionRotate90 = "rotate90" //旋转
MediaTypeVideo = "video"
MediaTypeImage = "video"
HttpType = "http://"
HttpsType = "https://"
TmpArtworkDir = "./runtime/tmp/artworks"
TmpArtistDir = "./runtime/tmp/artists"
MediaPath = "./runtime/"
TplPath = "./data/"
ImgActionRotate = "rotate" //旋转
MediaTypeVideo = "video"
MediaTypeImage = "video"
)
const (

View File

@ -135,16 +135,6 @@ func UploadImg(c *gin.Context) {
_ = os.Remove(dst)
dst = newDst
}
} else if action == model.ImgActionRotate90 {
fileFullName = fmt.Sprintf("%s%s", filename, fileExt)
newDst := fmt.Sprintf("%s/%s_rotate%v", imgPath, filename, fileExt)
if err = logic.MakeThumbnailDefault90(dst, newDst); err != nil {
//ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ERROR_ROTATE_IMG), nil)
//return
} else {
_ = os.Remove(dst)
dst = newDst
}
}
//localUrl := fmt.Sprintf("%s/%s/%s/%s/%s", config.ServerDM, BaseRoute, source, mask, fileFullName)
var data map[string]string = make(map[string]string, 2)