mirror of
https://github.com/coalaura/ffwebp.git
synced 2025-09-08 05:49:54 +00:00
qoi
This commit is contained in:
@@ -5,7 +5,7 @@ FFWebP is a command line utility for converting images between multiple formats.
|
||||
## Features
|
||||
|
||||
- Pure Go implementation with no external runtime dependencies
|
||||
- Supports AVIF, BMP, GIF, ICO, JPEG, JPEGXL, PNG, PNM (PBM/PGM/PPM/PAM), PSD (no encoding), TGA, TIFF, WEBP and XBM
|
||||
- Supports AVIF, BMP, GIF, ICO, JPEG, JPEGXL, PNG, PNM (PBM/PGM/PPM/PAM), PSD (no encoding), QOI, TGA, TIFF, WEBP and XBM
|
||||
- Lossy or lossless output with configurable quality
|
||||
- Output codec selected from the output file extension when `--codec` is omitted
|
||||
- Full set of format-specific flags for every supported format (see `ffwebp --help`)
|
||||
|
1
go.mod
1
go.mod
@@ -10,6 +10,7 @@ require (
|
||||
github.com/gen2brain/jpegxl v0.4.5
|
||||
github.com/gen2brain/webp v0.5.5
|
||||
github.com/knieriem/g v0.5.0
|
||||
github.com/kriticalflare/qoi v0.0.0-20240815192827-34f66f23bcef
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/oov/psd v0.0.0-20220121172623-5db5eafcecbb
|
||||
github.com/sergeymakinen/go-ico v1.0.0-beta.0
|
||||
|
2
go.sum
2
go.sum
@@ -14,6 +14,8 @@ github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25d
|
||||
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
|
||||
github.com/knieriem/g v0.5.0 h1:0WGfg4rfLD70T5e3SLZ9HtmmLQlRPChoKG15B3dfyqI=
|
||||
github.com/knieriem/g v0.5.0/go.mod h1:fhVCOebbqbZTIN+bv0aU/gOAasuZlP0ETeaF4N2553A=
|
||||
github.com/kriticalflare/qoi v0.0.0-20240815192827-34f66f23bcef h1:XHb/eK43B8XuqAO5jHILCXzZP3pBamGmn5PcGjTZTuE=
|
||||
github.com/kriticalflare/qoi v0.0.0-20240815192827-34f66f23bcef/go.mod h1:skc5Zgfi3XE//1zgGGPC1abynJwsZhFxOiwkCrwL4Z8=
|
||||
github.com/lionkov/go9p v0.0.0-20180620135904-0a603dd6808a/go.mod h1:Nbrxd4FljESFB/bUvzT5xm1VNO2VfzMKSIv4L++4J4U=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
|
8
internal/builtins/qoi.go
Normal file
8
internal/builtins/qoi.go
Normal file
@@ -0,0 +1,8 @@
|
||||
//go:build qoi || full
|
||||
// +build qoi full
|
||||
|
||||
package builtins
|
||||
|
||||
import (
|
||||
_ "github.com/coalaura/ffwebp/internal/codec/qoi"
|
||||
)
|
59
internal/codec/qoi/qoi.go
Normal file
59
internal/codec/qoi/qoi.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package qoi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"io"
|
||||
|
||||
"github.com/kriticalflare/qoi"
|
||||
|
||||
"github.com/coalaura/ffwebp/internal/codec"
|
||||
"github.com/coalaura/ffwebp/internal/opts"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func init() {
|
||||
codec.Register(impl{})
|
||||
}
|
||||
|
||||
type impl struct{}
|
||||
|
||||
func (impl) String() string {
|
||||
return "qoi"
|
||||
}
|
||||
|
||||
func (impl) Extensions() []string {
|
||||
return []string{"qoi"}
|
||||
}
|
||||
|
||||
func (impl) CanEncode() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (impl) Flags(flags []cli.Flag) []cli.Flag {
|
||||
return flags
|
||||
}
|
||||
|
||||
func (impl) Sniff(reader io.ReaderAt) (int, []byte, error) {
|
||||
magic := []byte{'q', 'o', 'i', 'f'}
|
||||
|
||||
buf := make([]byte, 4)
|
||||
|
||||
if _, err := reader.ReadAt(buf, 0); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
if bytes.Equal(buf, magic) {
|
||||
return 100, magic, nil
|
||||
}
|
||||
|
||||
return 0, nil, nil
|
||||
}
|
||||
|
||||
func (impl) Decode(reader io.Reader) (image.Image, error) {
|
||||
return qoi.ImageDecode(reader)
|
||||
}
|
||||
|
||||
func (impl) Encode(writer io.Writer, img image.Image, _ opts.Common) error {
|
||||
return qoi.ImageEncode(writer, img)
|
||||
}
|
@@ -56,6 +56,6 @@ func (impl) Decode(r io.Reader) (image.Image, error) {
|
||||
return decode.Decode(r)
|
||||
}
|
||||
|
||||
func (impl) Encode(w io.Writer, img image.Image, options opts.Common) error {
|
||||
func (impl) Encode(w io.Writer, img image.Image, _ opts.Common) error {
|
||||
return xbm.Encode(w, img)
|
||||
}
|
||||
|
BIN
test/image.qoi
Normal file
BIN
test/image.qoi
Normal file
Binary file not shown.
Reference in New Issue
Block a user