mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
commit
66447e14d4
2 changed files with 30 additions and 2 deletions
5
vips.go
5
vips.go
|
|
@ -246,8 +246,9 @@ func vipsExifOrientation(image *C.VipsImage) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func vipsExifShort(s string) string {
|
func vipsExifShort(s string) string {
|
||||||
if strings.Contains(s, " (") {
|
i := strings.Index(s, " (")
|
||||||
return s[:strings.Index(s, "(")-1]
|
if i > 0 {
|
||||||
|
return s[:i]
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
vips_test.go
27
vips_test.go
|
|
@ -219,6 +219,33 @@ func TestVipsMemory(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestVipsExifShort(t *testing.T) {
|
||||||
|
tt := []struct {
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
input: `( ()`,
|
||||||
|
expected: `(`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: ` ()`,
|
||||||
|
expected: ` ()`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: `sRGB`,
|
||||||
|
expected: `sRGB`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tt {
|
||||||
|
got := vipsExifShort(tc.input)
|
||||||
|
if got != tc.expected {
|
||||||
|
t.Fatalf("expected: %s; got: %s", tc.expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func readImage(file string) []byte {
|
func readImage(file string) []byte {
|
||||||
img, _ := os.Open(path.Join("testdata", file))
|
img, _ := os.Open(path.Join("testdata", file))
|
||||||
buf, _ := ioutil.ReadAll(img)
|
buf, _ := ioutil.ReadAll(img)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue