From 38d8f20d562b24a1f11a43501846aa838509fdc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 11 Apr 2021 17:56:07 +0200 Subject: [PATCH] Rename package --- internal/libwebp/a__encoder.go | 6 +++--- libwebp/encode.go | 4 ++-- libwebp/encode_test.go | 10 +++++----- libwebp/{options => webpoptions}/options.go | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) rename libwebp/{options => webpoptions}/options.go (95%) diff --git a/internal/libwebp/a__encoder.go b/internal/libwebp/a__encoder.go index 3293348..e020327 100644 --- a/internal/libwebp/a__encoder.go +++ b/internal/libwebp/a__encoder.go @@ -91,7 +91,7 @@ import ( "io" "unsafe" - "github.com/bep/gowebp/libwebp/options" + "github.com/bep/gowebp/libwebp/webpoptions" ) type ( @@ -105,7 +105,7 @@ type ( // // TODO(bep) Can we handle *image.YCbCr without conversion? // TODO(bep) check filled alpha channel. -func Encode(w io.Writer, src image.Image, o options.EncodingOptions) error { +func Encode(w io.Writer, src image.Image, o webpoptions.EncodingOptions) error { config, err := encodingOptionsToCConfig(o) if err != nil { return err @@ -175,7 +175,7 @@ func ConvertToNRGBA(src image.Image) *image.NRGBA { return dst } -func encodingOptionsToCConfig(o options.EncodingOptions) (*C.WebPConfig, error) { +func encodingOptionsToCConfig(o webpoptions.EncodingOptions) (*C.WebPConfig, error) { cfg := &C.WebPConfig{} quality := C.float(o.Quality) diff --git a/libwebp/encode.go b/libwebp/encode.go index fba1a11..55be8c1 100644 --- a/libwebp/encode.go +++ b/libwebp/encode.go @@ -4,12 +4,12 @@ import ( "image" "io" - "github.com/bep/gowebp/libwebp/options" + "github.com/bep/gowebp/libwebp/webpoptions" "github.com/bep/gowebp/internal/libwebp" ) // Encode encodes src as Webp into w using the options in o. -func Encode(w io.Writer, src image.Image, o options.EncodingOptions) error { +func Encode(w io.Writer, src image.Image, o webpoptions.EncodingOptions) error { return libwebp.Encode(w, src, o) } diff --git a/libwebp/encode_test.go b/libwebp/encode_test.go index d257884..4d617ac 100644 --- a/libwebp/encode_test.go +++ b/libwebp/encode_test.go @@ -19,20 +19,20 @@ import ( "github.com/bep/gowebp/internal/libwebp" - "github.com/bep/gowebp/libwebp/options" + "github.com/bep/gowebp/libwebp/webpoptions" "golang.org/x/image/webp" ) type testCase struct { name string inputFile string - opts options.EncodingOptions + opts webpoptions.EncodingOptions } var testCases = []testCase{ - {"lossy", "source.jpg", options.EncodingOptions{Quality: 75, EncodingPreset: options.EncodingPresetPhoto, UseSharpYuv: true}}, - {"lossless", "source.jpg", options.EncodingOptions{}}, - {"bw", "bw-gopher.png", options.EncodingOptions{Quality: 75}}, + {"lossy", "source.jpg", webpoptions.EncodingOptions{Quality: 75, EncodingPreset: webpoptions.EncodingPresetPhoto, UseSharpYuv: true}}, + {"lossless", "source.jpg", webpoptions.EncodingOptions{}}, + {"bw", "bw-gopher.png", webpoptions.EncodingOptions{Quality: 75}}, } func TestEncode(t *testing.T) { diff --git a/libwebp/options/options.go b/libwebp/webpoptions/options.go similarity index 95% rename from libwebp/options/options.go rename to libwebp/webpoptions/options.go index 2410b08..781e5f9 100644 --- a/libwebp/options/options.go +++ b/libwebp/webpoptions/options.go @@ -1,4 +1,4 @@ -package options +package webpoptions const ( EncodingPresetDefault EncodingPreset = iota