Commit d90ac8e1 by Li Feifei

add jpge

parent 4799b4a9
Pipeline #14580 passed with stages
in 58 seconds
......@@ -11,6 +11,7 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/astaxie/beego/orm"
"github.com/chai2010/webp"
"image/jpeg"
"image/png"
"io"
"io/ioutil"
......@@ -21,6 +22,7 @@ import (
"path"
"ppt_server/models"
"regexp"
"image"
Qurl "net/url"
"strconv"
......@@ -490,7 +492,16 @@ func pdfThumbnail(objectPath string, file *zip.File, bucket *oss.Bucket) error {
return err
}
defer fc.Close()
img, _ := png.Decode(fc)
var img image.Image
fileSuffix := path.Ext(file.Name) //获取文件后缀
switch fileSuffix {
case ".png":
img, _ = png.Decode(fc)
case ".jpeg":
img, _ = jpeg.Decode(fc)
default:
return errors.New("image ext is not found")
}
var buf bytes.Buffer
if err = webp.Encode(&buf, img, &webp.Options{Lossless:true}); err != nil {
......@@ -498,8 +509,6 @@ func pdfThumbnail(objectPath string, file *zip.File, bucket *oss.Bucket) error {
}
objectPathName := objectPath + "images/"
var fileSuffix string
fileSuffix = path.Ext(file.Name) //获取文件后缀
var filenameOnly string
filenameOnly = strings.TrimRight(file.Name, fileSuffix)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment