-
Notifications
You must be signed in to change notification settings - Fork 2
/
heif_test.go
46 lines (40 loc) · 974 Bytes
/
heif_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//go:build heif || darwin
// +build heif darwin
package imagecoding
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestHeifTransform(t *testing.T) {
sample, err := os.ReadFile("testdata/world-political.heic")
if !assert.NoError(t, err) {
t.FailNow()
}
{
img, _, _, _, err := TransformHeif(sample, true, DefaultScale)
if assert.NoError(t, err) {
assert.Equal(t, 1754, img.Bounds().Dx())
assert.Equal(t, 1002, img.Bounds().Dy())
}
}
{
img, _, _, _, err := TransformHeif(sample, false, DefaultScale)
if assert.NoError(t, err) {
assert.Equal(t, 1754, img.Bounds().Dx())
assert.Equal(t, 1002, img.Bounds().Dy())
}
}
}
func BenchmarkHeifTransform(b *testing.B) {
sample, err := os.ReadFile("testdata/world-political.heic")
if !assert.NoError(b, err) {
b.FailNow()
}
for n := 0; n < b.N; n++ {
_, _, _, _, err := TransformHeif(sample, true, DefaultScale)
if !assert.NoError(b, err) {
b.FailNow()
}
}
}