mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 05:32:02 +08:00
feat: automatic load pages in animated images (#231)
* feat: automatic load pages in animated images Signed-off-by: STRRL <im@strrl.dev> * chore: remove destination file during test Signed-off-by: STRRL <im@strrl.dev> * chore: change import param code style Signed-off-by: STRRL <im@strrl.dev> --------- Signed-off-by: STRRL <im@strrl.dev>
This commit is contained in:
parent
f5eda9eaed
commit
90680bef6c
@ -165,8 +165,11 @@ func webpEncoder(p1, p2 string, quality int, extraParams ExtraParams) error {
|
||||
var buf []byte
|
||||
var boolFalse vips.BoolParameter
|
||||
boolFalse.Set(false)
|
||||
var intMinusOne vips.IntParameter
|
||||
intMinusOne.Set(-1)
|
||||
img, err := vips.LoadImageFromFile(p1, &vips.ImportParams{
|
||||
FailOnError: boolFalse,
|
||||
NumPages: intMinusOne,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -96,6 +96,11 @@ func TestWebPEncoder(t *testing.T) {
|
||||
_ = os.Remove(dest)
|
||||
}
|
||||
|
||||
func TestAnimatedGIFWithWebPEncoder(t *testing.T) {
|
||||
runEncoder(t, "./pics/gif-animated.gif", dest)
|
||||
_ = os.Remove(dest)
|
||||
}
|
||||
|
||||
func TestAvifEncoder(t *testing.T) {
|
||||
// Only one file: img_over_16383px.jpg might cause memory issues on CI environment
|
||||
assert.Nil(t, avifEncoder("./pics/big.jpg", dest, 80, ExtraParams{Width: 0, Height: 0}))
|
||||
|
BIN
pics/gif-animated.gif
Normal file
BIN
pics/gif-animated.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Loading…
x
Reference in New Issue
Block a user