mirror of
https://github.com/coalaura/ffwebp.git
synced 2025-09-07 21:45:31 +00:00
farbfeld
This commit is contained in:
@@ -6,7 +6,7 @@ FFWebP is a small, single-binary CLI for converting images between formats, thin
|
||||
|
||||
- Single binary: no external tools required
|
||||
- Auto-detects input codec and infers output from the file extension
|
||||
- Supports AVIF, BMP, GIF, ICO, JPEG, JPEG XL, PCX, PNG, PNM (PBM/PGM/PPM/PAM), PSD (decode-only), QOI, SVG (decode-only), TGA, TIFF, WebP, and XBM
|
||||
- Supports AVIF, BMP, Farbfeld, GIF, ICO, JPEG, JPEG XL, PCX, PNG, PNM (PBM/PGM/PPM/PAM), PSD (decode-only), QOI, SVG (decode-only), TGA, TIFF, WebP, and XBM
|
||||
- Lossy or lossless output with configurable quality
|
||||
- Thumbnail generation via Lanczos3 resampling
|
||||
- Per-codec flags for fine-grained control (see `ffwebp --help`)
|
||||
|
1
go.mod
1
go.mod
@@ -10,6 +10,7 @@ require (
|
||||
github.com/gen2brain/avif v0.4.4
|
||||
github.com/gen2brain/jpegxl v0.4.5
|
||||
github.com/gen2brain/webp v0.5.5
|
||||
github.com/hullerob/go.farbfeld v0.0.0-20181222022525-3661193c725f
|
||||
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
|
||||
|
2
go.sum
2
go.sum
@@ -14,6 +14,8 @@ github.com/gen2brain/webp v0.5.5 h1:MvQR75yIPU/9nSqYT5h13k4URaJK3gf9tgz/ksRbyEg=
|
||||
github.com/gen2brain/webp v0.5.5/go.mod h1:xOSMzp4aROt2KFW++9qcK/RBTOVC2S9tJG66ip/9Oc0=
|
||||
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
||||
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
|
||||
github.com/hullerob/go.farbfeld v0.0.0-20181222022525-3661193c725f h1:1LkiAnH6RhOEbQAcfcEcixM5IsegqFi6IH0Nz0ZGqYs=
|
||||
github.com/hullerob/go.farbfeld v0.0.0-20181222022525-3661193c725f/go.mod h1:mQEoc766DxPTAwQ54neWTK/lFqIeSO7OU6bqZsceglw=
|
||||
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=
|
||||
|
8
internal/builtins/farbfeld.go
Normal file
8
internal/builtins/farbfeld.go
Normal file
@@ -0,0 +1,8 @@
|
||||
//go:build farbfeld || core || full
|
||||
// +build farbfeld core full
|
||||
|
||||
package builtins
|
||||
|
||||
import (
|
||||
_ "github.com/coalaura/ffwebp/internal/codec/farbfeld"
|
||||
)
|
57
internal/codec/farbfeld/farbfeld.go
Normal file
57
internal/codec/farbfeld/farbfeld.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package farbfeld
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"io"
|
||||
|
||||
farbfeld "github.com/hullerob/go.farbfeld"
|
||||
|
||||
"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 "farbfeld"
|
||||
}
|
||||
|
||||
func (impl) Extensions() []string {
|
||||
return []string{"farbfeld", "ff"}
|
||||
}
|
||||
|
||||
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) {
|
||||
buf := make([]byte, 8)
|
||||
|
||||
if _, err := reader.ReadAt(buf, 0); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
if bytes.Equal(buf, []byte("farbfeld")) {
|
||||
return 100, buf, nil
|
||||
}
|
||||
|
||||
return 0, nil, nil
|
||||
}
|
||||
|
||||
func (impl) Decode(reader io.Reader) (image.Image, error) {
|
||||
return farbfeld.Decode(reader)
|
||||
}
|
||||
|
||||
func (impl) Encode(writer io.Writer, img image.Image, _ opts.Common) error {
|
||||
return farbfeld.Encode(writer, img)
|
||||
}
|
BIN
test/image.ff
Normal file
BIN
test/image.ff
Normal file
Binary file not shown.
Reference in New Issue
Block a user