"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "resources/image_test.go" between
hugo-0.85.0.tar.gz and hugo-0.86.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

image_test.go  (hugo-0.85.0):image_test.go  (hugo-0.86.0)
skipping to change at line 31 skipping to change at line 31
"math/rand" "math/rand"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strconv" "strconv"
"sync" "sync"
"testing" "testing"
"time" "time"
"github.com/gohugoio/hugo/resources/images/webp"
"github.com/gohugoio/hugo/common/paths" "github.com/gohugoio/hugo/common/paths"
"github.com/spf13/afero" "github.com/spf13/afero"
"github.com/disintegration/gift" "github.com/disintegration/gift"
"github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/media" "github.com/gohugoio/hugo/media"
"github.com/gohugoio/hugo/resources/images" "github.com/gohugoio/hugo/resources/images"
skipping to change at line 365 skipping to change at line 367
image := fetchImage(c, "gohugoio.png") image := fetchImage(c, "gohugoio.png")
c.Assert(image.MediaType().Type(), qt.Equals, "image/png") c.Assert(image.MediaType().Type(), qt.Equals, "image/png")
c.Assert(image.RelPermalink(), qt.Equals, "/a/gohugoio.png") c.Assert(image.RelPermalink(), qt.Equals, "/a/gohugoio.png")
c.Assert(image.ResourceType(), qt.Equals, "image") c.Assert(image.ResourceType(), qt.Equals, "image")
c.Assert(image.Exif(), qt.IsNil) c.Assert(image.Exif(), qt.IsNil)
resized, err := image.Resize("800x") resized, err := image.Resize("800x")
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(resized.MediaType().Type(), qt.Equals, "image/png") c.Assert(resized.MediaType().Type(), qt.Equals, "image/png")
c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu0e1b9e4a4be4d6 f86c7b37b9ccce3fbc_73886_800x0_resize_linear_2.png") c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu0e1b9e4a4be4d6 f86c7b37b9ccce3fbc_73886_800x0_resize_linear_3.png")
c.Assert(resized.Width(), qt.Equals, 800) c.Assert(resized.Width(), qt.Equals, 800)
} }
func TestImageResizeInSubPath(t *testing.T) { func TestImageResizeInSubPath(t *testing.T) {
c := qt.New(t) c := qt.New(t)
image := fetchImage(c, "sub/gohugoio2.png") image := fetchImage(c, "sub/gohugoio2.png")
c.Assert(image.MediaType(), eq, media.PNGType) c.Assert(image.MediaType(), eq, media.PNGType)
c.Assert(image.RelPermalink(), qt.Equals, "/a/sub/gohugoio2.png") c.Assert(image.RelPermalink(), qt.Equals, "/a/sub/gohugoio2.png")
c.Assert(image.ResourceType(), qt.Equals, "image") c.Assert(image.ResourceType(), qt.Equals, "image")
c.Assert(image.Exif(), qt.IsNil) c.Assert(image.Exif(), qt.IsNil)
resized, err := image.Resize("101x101") resized, err := image.Resize("101x101")
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(resized.MediaType().Type(), qt.Equals, "image/png") c.Assert(resized.MediaType().Type(), qt.Equals, "image/png")
c.Assert(resized.RelPermalink(), qt.Equals, "/a/sub/gohugoio2_hu0e1b9e4a4 be4d6f86c7b37b9ccce3fbc_73886_101x101_resize_linear_2.png") c.Assert(resized.RelPermalink(), qt.Equals, "/a/sub/gohugoio2_hu0e1b9e4a4 be4d6f86c7b37b9ccce3fbc_73886_101x101_resize_linear_3.png")
c.Assert(resized.Width(), qt.Equals, 101) c.Assert(resized.Width(), qt.Equals, 101)
c.Assert(resized.Exif(), qt.IsNil) c.Assert(resized.Exif(), qt.IsNil)
publishedImageFilename := filepath.Clean(resized.RelPermalink()) publishedImageFilename := filepath.Clean(resized.RelPermalink())
spec := image.(specProvider).getSpec() spec := image.(specProvider).getSpec()
assertImageFile(c, spec.BaseFs.PublishFs, publishedImageFilename, 101, 10 1) assertImageFile(c, spec.BaseFs.PublishFs, publishedImageFilename, 101, 10 1)
c.Assert(spec.BaseFs.PublishFs.Remove(publishedImageFilename), qt.IsNil) c.Assert(spec.BaseFs.PublishFs.Remove(publishedImageFilename), qt.IsNil)
// Clear mem cache to simulate reading from the file cache. // Clear mem cache to simulate reading from the file cache.
spec.imageCache.clear() spec.imageCache.clear()
resizedAgain, err := image.Resize("101x101") resizedAgain, err := image.Resize("101x101")
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(resizedAgain.RelPermalink(), qt.Equals, "/a/sub/gohugoio2_hu0e1b 9e4a4be4d6f86c7b37b9ccce3fbc_73886_101x101_resize_linear_2.png") c.Assert(resizedAgain.RelPermalink(), qt.Equals, "/a/sub/gohugoio2_hu0e1b 9e4a4be4d6f86c7b37b9ccce3fbc_73886_101x101_resize_linear_3.png")
c.Assert(resizedAgain.Width(), qt.Equals, 101) c.Assert(resizedAgain.Width(), qt.Equals, 101)
assertImageFile(c, image.(specProvider).getSpec().BaseFs.PublishFs, publi shedImageFilename, 101, 101) assertImageFile(c, image.(specProvider).getSpec().BaseFs.PublishFs, publi shedImageFilename, 101, 101)
} }
func TestSVGImage(t *testing.T) { func TestSVGImage(t *testing.T) {
c := qt.New(t) c := qt.New(t)
spec := newTestResourceSpec(specDescriptor{c: c}) spec := newTestResourceSpec(specDescriptor{c: c})
svg := fetchResourceForSpec(spec, c, "circle.svg") svg := fetchResourceForSpec(spec, c, "circle.svg")
c.Assert(svg, qt.Not(qt.IsNil)) c.Assert(svg, qt.Not(qt.IsNil))
} }
skipping to change at line 553 skipping to change at line 555
if diff < 0 { if diff < 0 {
diff = -diff diff = -diff
} }
if diff > maxDiff { if diff > maxDiff {
return false return false
} }
} }
return true return true
} }
// Issue #8729
func TestImageOperationsGoldenWebp(t *testing.T) {
if !webp.Supports() {
t.Skip("skip webp test")
}
c := qt.New(t)
c.Parallel()
devMode := false
testImages := []string{"fuzzy-cirlcle.png"}
spec, workDir := newTestResourceOsFs(c)
defer func() {
if !devMode {
os.Remove(workDir)
}
}()
if devMode {
fmt.Println(workDir)
}
for _, imageName := range testImages {
image := fetchImageForSpec(spec, c, imageName)
imageWebp, err := image.Resize("200x webp")
c.Assert(err, qt.IsNil)
c.Assert(imageWebp.Width(), qt.Equals, 200)
}
if devMode {
return
}
dir1 := filepath.Join(workDir, "resources/_gen/images")
dir2 := filepath.FromSlash("testdata/golden_webp")
assetGoldenDirs(c, dir1, dir2)
}
func TestImageOperationsGolden(t *testing.T) { func TestImageOperationsGolden(t *testing.T) {
c := qt.New(t) c := qt.New(t)
c.Parallel() c.Parallel()
devMode := false devMode := false
testImages := []string{"sunset.jpg", "gohugoio8.png", "gohugoio24.png"} testImages := []string{"sunset.jpg", "gohugoio8.png", "gohugoio24.png"}
spec, workDir := newTestResourceOsFs(c) spec, workDir := newTestResourceOsFs(c)
defer func() { defer func() {
skipping to change at line 661 skipping to change at line 704
c.Assert(rel, qt.Not(qt.Equals), "") c.Assert(rel, qt.Not(qt.Equals), "")
} }
if devMode { if devMode {
return return
} }
dir1 := filepath.Join(workDir, "resources/_gen/images") dir1 := filepath.Join(workDir, "resources/_gen/images")
dir2 := filepath.FromSlash("testdata/golden") dir2 := filepath.FromSlash("testdata/golden")
assetGoldenDirs(c, dir1, dir2)
}
func assetGoldenDirs(c *qt.C, dir1, dir2 string) {
// The two dirs above should now be the same. // The two dirs above should now be the same.
dirinfos1, err := ioutil.ReadDir(dir1) dirinfos1, err := ioutil.ReadDir(dir1)
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
dirinfos2, err := ioutil.ReadDir(dir2) dirinfos2, err := ioutil.ReadDir(dir2)
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(len(dirinfos1), qt.Equals, len(dirinfos2)) c.Assert(len(dirinfos1), qt.Equals, len(dirinfos2))
for i, fi1 := range dirinfos1 { for i, fi1 := range dirinfos1 {
fi2 := dirinfos2[i] fi2 := dirinfos2[i]
c.Assert(fi1.Name(), qt.Equals, fi2.Name()) c.Assert(fi1.Name(), qt.Equals, fi2.Name())
skipping to change at line 695 skipping to change at line 744
gift.New().Draw(nrgba2, img2) gift.New().Draw(nrgba2, img2)
if !goldenEqual(nrgba1, nrgba2) { if !goldenEqual(nrgba1, nrgba2) {
switch fi1.Name() { switch fi1.Name() {
case "gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_73538_ 4c320010919da2d8b63ed24818b4d8e1.png", case "gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_73538_ 4c320010919da2d8b63ed24818b4d8e1.png",
"gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_735 38_9d4c2220235b3c2d9fa6506be571560f.png", "gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_735 38_9d4c2220235b3c2d9fa6506be571560f.png",
"gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_735 38_c74bb417b961e09cf1aac2130b7b9b85.png", "gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_735 38_c74bb417b961e09cf1aac2130b7b9b85.png",
"gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_735 38_300x200_fill_gaussian_smart1_2.png": "gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_735 38_300x200_fill_gaussian_smart1_2.png":
c.Log("expectedly differs from golden due to dith ering:", fi1.Name()) c.Log("expectedly differs from golden due to dith ering:", fi1.Name())
default: default:
t.Errorf("resulting image differs from golden: %s ", fi1.Name()) c.Errorf("resulting image differs from golden: %s ", fi1.Name())
} }
} }
if !usesFMA { if !usesFMA {
c.Assert(fi1, eq, fi2) c.Assert(fi1, eq, fi2)
_, err = f1.Seek(0, 0) _, err = f1.Seek(0, 0)
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
_, err = f2.Seek(0, 0) _, err = f2.Seek(0, 0)
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
 End of changes. 7 change blocks. 
4 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)