mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
safari & 644 perm
This commit is contained in:
parent
bd5ef5aa6e
commit
062b9dcf69
@ -101,7 +101,7 @@ func webpEncoder(p1, p2 string, quality float32, Log bool, c chan int) (err erro
|
|||||||
chanErr(c)
|
chanErr(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = ioutil.WriteFile(p2, buf.Bytes(), os.ModePerm); err != nil {
|
if err = ioutil.WriteFile(p2, buf.Bytes(), 0644); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
chanErr(c)
|
chanErr(c)
|
||||||
return
|
return
|
||||||
@ -133,7 +133,7 @@ func Convert(ImgPath string, AllowedTypes []string, QUALITY string) func(c *fibe
|
|||||||
UA := c.Get("User-Agent")
|
UA := c.Get("User-Agent")
|
||||||
if strings.Contains(UA, "Safari") && !strings.Contains(UA, "Chrome") &&
|
if strings.Contains(UA, "Safari") && !strings.Contains(UA, "Chrome") &&
|
||||||
!strings.Contains(UA, "Firefox") {
|
!strings.Contains(UA, "Firefox") {
|
||||||
finalFile = RawImageAbs
|
c.SendFile(RawImageAbs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ func Convert(ImgPath string, AllowedTypes []string, QUALITY string) func(c *fibe
|
|||||||
}
|
}
|
||||||
|
|
||||||
//for webp, we need to create dir first
|
//for webp, we need to create dir first
|
||||||
_ = os.MkdirAll(path.Dir(WebpAbsPath), os.ModePerm)
|
_ = os.MkdirAll(path.Dir(WebpAbsPath), 0644)
|
||||||
q, _ := strconv.ParseFloat(QUALITY, 32)
|
q, _ := strconv.ParseFloat(QUALITY, 32)
|
||||||
err = webpEncoder(RawImageAbs, WebpAbsPath, float32(q), true, nil)
|
err = webpEncoder(RawImageAbs, WebpAbsPath, float32(q), true, nil)
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ func prefetchImages(confImgPath string, QUALITY string) {
|
|||||||
proposedURI := strings.Replace(picAbsPath, confImgPath, "", 1)
|
proposedURI := strings.Replace(picAbsPath, confImgPath, "", 1)
|
||||||
_, p2 := genWebpAbs(picAbsPath, info.Name(), proposedURI)
|
_, p2 := genWebpAbs(picAbsPath, info.Name(), proposedURI)
|
||||||
q, _ := strconv.ParseFloat(QUALITY, 32)
|
q, _ := strconv.ParseFloat(QUALITY, 32)
|
||||||
_ = os.MkdirAll(path.Dir(p2), os.ModePerm)
|
_ = os.MkdirAll(path.Dir(p2), 0644)
|
||||||
go webpEncoder(picAbsPath, p2, float32(q), false, finishChan)
|
go webpEncoder(picAbsPath, p2, float32(q), false, finishChan)
|
||||||
count += <-finishChan
|
count += <-finishChan
|
||||||
//progress bar
|
//progress bar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user