mirror of
https://github.com/coalaura/ffwebp.git
synced 2025-09-08 13:59:54 +00:00
pcx
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, PNG, PNM (PBM/PGM/PPM/PAM), PSD (decode-only), QOI, TGA, TIFF, WebP, and XBM
|
||||
- Supports AVIF, BMP, GIF, ICO, JPEG, JPEG XL, PCX, PNG, PNM (PBM/PGM/PPM/PAM), PSD (decode-only), QOI, 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
@@ -14,6 +14,7 @@ require (
|
||||
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/samuel/go-pcx v0.0.0-20210515040514-6a5ce4d132f7
|
||||
github.com/sergeymakinen/go-ico v1.0.0-beta.0
|
||||
github.com/spakin/netpbm v1.3.2
|
||||
github.com/xyproto/xbm v1.0.0
|
||||
|
2
go.sum
2
go.sum
@@ -25,6 +25,8 @@ github.com/oov/psd v0.0.0-20220121172623-5db5eafcecbb h1:JF9kOhBBk4WPF7luXFu5yR+
|
||||
github.com/oov/psd v0.0.0-20220121172623-5db5eafcecbb/go.mod h1:GHI1bnmAcbp96z6LNfBJvtrjxhaXGkbsk967utPlvL8=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/samuel/go-pcx v0.0.0-20210515040514-6a5ce4d132f7 h1:WhAiClm3vGzSl2EWdFsCFBEu2jEhHGa8qGsz4iIEpRc=
|
||||
github.com/samuel/go-pcx v0.0.0-20210515040514-6a5ce4d132f7/go.mod h1:8ofl4LzpDayZKQZYbUyCDW41Y6lgVoO02ABp57OASxY=
|
||||
github.com/sergeymakinen/go-bmp v1.0.0 h1:SdGTzp9WvCV0A1V0mBeaS7kQAwNLdVJbmHlqNWq0R+M=
|
||||
github.com/sergeymakinen/go-bmp v1.0.0/go.mod h1:/mxlAQZRLxSvJFNIEGGLBE/m40f3ZnUifpgVDlcUIEY=
|
||||
github.com/sergeymakinen/go-ico v1.0.0-beta.0 h1:m5qKH7uPKLdrygMWxbamVn+tl2HfiA3K6MFJw4GfZvQ=
|
||||
|
8
internal/builtins/pcx.go
Normal file
8
internal/builtins/pcx.go
Normal file
@@ -0,0 +1,8 @@
|
||||
//go:build pcx || core || full
|
||||
// +build pcx core full
|
||||
|
||||
package builtins
|
||||
|
||||
import (
|
||||
_ "github.com/coalaura/ffwebp/internal/codec/pcx"
|
||||
)
|
60
internal/codec/pcx/pcx.go
Normal file
60
internal/codec/pcx/pcx.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package pcx
|
||||
|
||||
import (
|
||||
"image"
|
||||
"io"
|
||||
|
||||
"github.com/samuel/go-pcx/pcx"
|
||||
|
||||
"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 "pcx"
|
||||
}
|
||||
|
||||
func (impl) Extensions() []string {
|
||||
return []string{"pcx"}
|
||||
}
|
||||
|
||||
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, 4)
|
||||
|
||||
if _, err := reader.ReadAt(buf, 0); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
if buf[0] != 0x0A {
|
||||
return 0, nil, nil
|
||||
}
|
||||
|
||||
if buf[2] != 0x01 {
|
||||
return 50, buf, nil
|
||||
}
|
||||
|
||||
return 100, buf, nil
|
||||
}
|
||||
|
||||
func (impl) Decode(r io.Reader) (image.Image, error) {
|
||||
return pcx.Decode(r)
|
||||
}
|
||||
|
||||
func (impl) Encode(w io.Writer, img image.Image, options opts.Common) error {
|
||||
return pcx.Encode(w, img)
|
||||
}
|
BIN
test/image.pcx
Normal file
BIN
test/image.pcx
Normal file
Binary file not shown.
Reference in New Issue
Block a user