Skip to content

Commit 20d9cfe

Browse files
committed
Add GitHub test action etc.
1 parent 38d8f20 commit 20d9cfe

File tree

11 files changed

+40
-8
lines changed

11 files changed

+40
-8
lines changed

‎.github/FUNDING.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [bep]

‎.github/workflows/test.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on: [push, pull_request]
2+
name: Test
3+
jobs:
4+
test:
5+
strategy:
6+
matrix:
7+
go-version: [1.16.x]
8+
os: [ubuntu-latest, macos-latest, windows-latest]
9+
runs-on: ${{ matrix.os }}
10+
steps:
11+
- name: Install Go
12+
uses: actions/setup-go@v2
13+
with:
14+
go-version: ${{ matrix.go-version }}
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
- name: Test
18+
run: go test -race ./libwebp -coverprofile=coverage.txt -covermode=atomic
19+
- name: Upload coverage
20+
if: success() && matrix.os == 'ubuntu-latest'
21+
run: |
22+
curl -s https://codecov.io/bash | bash
23+
env:
24+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
25+
shell: bash

‎FUNDING.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [bep]

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[![Go Report Card](https://goreportcard.com/badge/github.com/bep/golibwebp)](https://goreportcard.com/report/github.com/bep/golibwebp)
2-
[![libwebp Version](https://img.shields.io/badge/libwebp-v1.2.0-blue)](https://github.com/sass/libwebp)
3-
[![codecov](https://codecov.io/gh/bep/golibwebp/branch/master/graph/badge.svg)](https://codecov.io/gh/bep/golibwebp)
4-
[![GoDoc](https://godoc.org/github.com/bep/golibwebp/libwebp?status.svg)](https://godoc.org/github.com/bep/golibwebp/libwebp)
1+
[![Go Report Card](https://goreportcard.com/badge/github.com/bep/gowebp)](https://goreportcard.com/report/github.com/bep/gowebp)
2+
[![libwebp Version](https://img.shields.io/badge/libwebp-v1.2.0-blue)](https://github.com/webmproject/libwebp)
3+
[![codecov](https://codecov.io/gh/bep/gowebp/branch/master/graph/badge.svg)](https://codecov.io/gh/bep/gowebp)
4+
[![GoDoc](https://godoc.org/github.com/bep/gowebp/libwebp?status.svg)](https://godoc.org/github.com/bep/gowebp/libwebp)
55

66
This library provides C bindings and an API for **encoding** Webp images using Google's [libwebp](https://github.com/webmproject/libwebp).
77

‎internal/libwebp/a__encoder.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ type (
103103

104104
// Encode encodes src into w considering the options in o.
105105
//
106-
// TODO(bep) Can we handle *image.YCbCr without conversion?
107-
// TODO(bep) check filled alpha channel.
106+
// Any src that isn't one of *image.RGBA, *image.NRGBA, or *image.Gray
107+
// will be converted to *image.NRGBA using draw.Draw first.
108+
//
108109
func Encode(w io.Writer, src image.Image, o webpoptions.EncodingOptions) error {
109110
config, err := encodingOptionsToCConfig(o)
110111
if err != nil {

‎libwebp/encode.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
)
1111

1212
// Encode encodes src as Webp into w using the options in o.
13+
//
14+
// Any src that isn't one of *image.RGBA, *image.NRGBA, or *image.Gray
15+
// will be converted to *image.NRGBA using draw.Draw first.
16+
//
1317
func Encode(w io.Writer, src image.Image, o webpoptions.EncodingOptions) error {
1418
return libwebp.Encode(w, src, o)
1519
}

‎libwebp/encode_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ type testCase struct {
3030
}
3131

3232
var testCases = []testCase{
33-
{"lossy", "source.jpg", webpoptions.EncodingOptions{Quality: 75, EncodingPreset: webpoptions.EncodingPresetPhoto, UseSharpYuv: true}},
33+
{"lossy", "sunset.jpg", webpoptions.EncodingOptions{Quality: 75, EncodingPreset: webpoptions.EncodingPresetPhoto, UseSharpYuv: true}},
3434
{"lossless", "source.jpg", webpoptions.EncodingOptions{}},
3535
{"bw", "bw-gopher.png", webpoptions.EncodingOptions{Quality: 75}},
3636
}
3737

3838
func TestEncode(t *testing.T) {
39-
writeGolden := false
39+
writeGolden := true
4040
for _, test := range testCases {
4141
t.Run(test.name, func(t *testing.T) {
4242
r, err := os.Open(filepath.Join("../test_data/images", test.inputFile))
-28.9 KB
Loading
-13 KB
Binary file not shown.
103 KB
Loading

0 commit comments

Comments
 (0)