Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ppt_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Li Feifei
ppt_server
Commits
d90ac8e1
Commit
d90ac8e1
authored
May 13, 2021
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add jpge
parent
4799b4a9
Pipeline
#14580
passed with stages
in 58 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
upload.go
upload/upload.go
+12
-3
No files found.
upload/upload.go
View file @
d90ac8e1
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/orm"
"github.com/chai2010/webp"
"github.com/chai2010/webp"
"image/jpeg"
"image/png"
"image/png"
"io"
"io"
"io/ioutil"
"io/ioutil"
...
@@ -21,6 +22,7 @@ import (
...
@@ -21,6 +22,7 @@ import (
"path"
"path"
"ppt_server/models"
"ppt_server/models"
"regexp"
"regexp"
"image"
Qurl
"net/url"
Qurl
"net/url"
"strconv"
"strconv"
...
@@ -490,7 +492,16 @@ func pdfThumbnail(objectPath string, file *zip.File, bucket *oss.Bucket) error {
...
@@ -490,7 +492,16 @@ func pdfThumbnail(objectPath string, file *zip.File, bucket *oss.Bucket) error {
return
err
return
err
}
}
defer
fc
.
Close
()
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
var
buf
bytes
.
Buffer
if
err
=
webp
.
Encode
(
&
buf
,
img
,
&
webp
.
Options
{
Lossless
:
true
});
err
!=
nil
{
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 {
...
@@ -498,8 +509,6 @@ func pdfThumbnail(objectPath string, file *zip.File, bucket *oss.Bucket) error {
}
}
objectPathName
:=
objectPath
+
"images/"
objectPathName
:=
objectPath
+
"images/"
var
fileSuffix
string
fileSuffix
=
path
.
Ext
(
file
.
Name
)
//获取文件后缀
var
filenameOnly
string
var
filenameOnly
string
filenameOnly
=
strings
.
TrimRight
(
file
.
Name
,
fileSuffix
)
filenameOnly
=
strings
.
TrimRight
(
file
.
Name
,
fileSuffix
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment