mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2025-10-13 20:18:52 +02:00
fix(webp): fix installing newer version of webp
This commit is contained in:
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -4,6 +4,13 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch file",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "debug",
|
||||||
|
"program": "${file}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Optimize Testdata",
|
"name": "Optimize Testdata",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
package webp
|
package webp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/belphemur/go-webpbin/v2"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/belphemur/go-webpbin/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const libwebpVersion = "1.6.0"
|
const libwebpVersion = "1.6.0"
|
||||||
@@ -15,8 +18,18 @@ func PrepareEncoder() error {
|
|||||||
prepareMutex.Lock()
|
prepareMutex.Lock()
|
||||||
defer prepareMutex.Unlock()
|
defer prepareMutex.Unlock()
|
||||||
container := webpbin.NewCWebP(webpbin.SetLibVersion(libwebpVersion))
|
container := webpbin.NewCWebP(webpbin.SetLibVersion(libwebpVersion))
|
||||||
return container.BinWrapper.Run()
|
version, err := container.Version()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.HasPrefix(version, libwebpVersion) {
|
||||||
|
return fmt.Errorf("unexpected webp version: got %s, want %s", version, libwebpVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Encode(w io.Writer, m image.Image, quality uint) error {
|
func Encode(w io.Writer, m image.Image, quality uint) error {
|
||||||
return webpbin.NewCWebP(webpbin.SetLibVersion(libwebpVersion)).
|
return webpbin.NewCWebP(webpbin.SetLibVersion(libwebpVersion)).
|
||||||
Quality(quality).
|
Quality(quality).
|
||||||
|
Reference in New Issue
Block a user