Switch EXIF library

Closes #10855
Closes #8586
Closes #8996
This commit is contained in:
Bjørn Erik Pedersen
2024-07-07 12:54:30 +02:00
parent a28bed0817
commit 72ff937e11
12 changed files with 297 additions and 194 deletions

View File

@@ -20,22 +20,28 @@ import (
"testing"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/htesting/hqt"
"github.com/gohugoio/hugo/media"
)
func TestImageResizeWebP(t *testing.T) {
c := qt.New(t)
_, image := fetchImage(c, "sunset.webp")
_, image := fetchImage(c, "sunrise.webp")
c.Assert(image.MediaType(), qt.Equals, media.Builtin.WEBPType)
c.Assert(image.RelPermalink(), qt.Equals, "/a/sunset.webp")
c.Assert(image.RelPermalink(), qt.Equals, "/a/sunrise.webp")
c.Assert(image.ResourceType(), qt.Equals, "image")
c.Assert(image.Exif(), qt.IsNil)
exif := image.Exif()
c.Assert(exif, qt.Not(qt.IsNil))
c.Assert(exif.Tags["Copyright"], qt.Equals, "Bjørn Erik Pedersen")
c.Assert(exif.Lat, hqt.IsSameFloat64, 36.59744166666667)
c.Assert(exif.Long, hqt.IsSameFloat64, -4.50846)
c.Assert(exif.Date.IsZero(), qt.Equals, false)
resized, err := image.Resize("123x")
c.Assert(err, qt.IsNil)
c.Assert(image.MediaType(), qt.Equals, media.Builtin.WEBPType)
c.Assert(resized.RelPermalink(), qt.Equals, "/a/sunset_hu36ee0b61ba924719ad36da960c273f96_59826_123x0_resize_q68_h2_linear_2.webp")
c.Assert(resized.RelPermalink(), qt.Equals, "/a/sunrise_hu6ad68bcbae1b79cbc2f6b451894deaf6_95652_123x0_resize_q68_h2_linear_2.webp")
c.Assert(resized.Width(), qt.Equals, 123)
}