Backtestshugorun-20261002-200313#15266

Issue #15266 Merged fix PR # Run 2 Oct 2026 · run-20261002-200313 gohugoio/hugo

Consider bumping mainImageVersionNumber

Better

Our patch was judged better than the merged fix.

In this judgment, Patch A = our agent, Patch B = the merged fix.

Patch A is the better fix: it bumps the version number the issue names and fixes the reason a bump alone would not reach filtered images.

**Correctness.** The issue asks to bump `mainImageVersionNumber` so cached output from two filter-related fixes is invalidated. Before either patch, `Filter()` set `confMain.Key = hashing.HashString(gfilters)` with no version number in it. So bumping `mainImageVersionNumber` by itself would not invalidate filtered images, which are exactly the ones affected by those fixes.
- Patch A handles this cleanly. It moves the version-number assembly into a `versionOptions()` helper and adds an `ImageConfig.FilterKey` method that folds those numbers into the filter cache key. It then bumps `mainImageVersionNumber` to 2. Every cached image, filtered or processed, is invalidated, which is what the issue asks for.
- Patch B also folds the version numbers into the filter key, so filtered images get new hashes. However, it does not bump `mainImageVersionNumber`. Instead it adds a `PNG: 1` format version, which invalidates PNG resizes in a fairly arbitrary way. Its main-version invalidation of filters is only a side effect of changing the hash input.

**Tests.** Patch A adds `TestImageConfigMainVersionNumber`. It checks directly that bumping the main version changes both the processing key and the filter key, a meaningful regression test for the root cause. Patch A also updates all the affected golden hashes and golden image files consistently. Patch B only updates hash expectations and adds no targeted test.

**Scope and craft.** Patch B exports two package-level mutable variables (`MainImageVersionNumber`, `FormatVersionNumbers`), widening the public API, so the filter-key logic can be built inline in `image.go`. That duplicates logic already in `DecodeImageConfig`. Its diff also carries a lot of unrelated reformatting of `AssertFileContent(` calls across test files, which obscures the actual change. Patch A keeps the logic encapsulated in the `images` package, keeps one source for the version options, and stays focused.

The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.

Solve

54m 41s

Wall-clock time in the container

Full test suite

No new failures

3,754 passed · 99 skipped · 3,855 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

143vs 102 merged

Changed lines, ours vs merged

Unless site owners flush their image cache, they will not see the result of these fixes:

9e7c978e6 resources/images: Preserve the source palette for geometric filter chains
77856683d resources/images: Fix filters on transparent colors and paletted images

Argument against doing this: I suspect very few sites are affected by the underlying issues.

I don't have a strong opinion either way.

The two patches

Our patch+94 −49
hugolib/hugo_sites_multihost_test.goindex 3ecfa7e9d..426c76fb9 100644@@ -207,9 +207,9 @@ title: mybundle-en 	b.AssertFileExists("public/de/mybundle/pixel.png", true) 	b.AssertFileExists("public/en/mybundle/pixel.png", true) -	b.AssertFileExists("public/de/mybundle/pixel_hu_c8522c65d73a0421.png", true)+	b.AssertFileExists("public/de/mybundle/pixel_hu_410c334bfbcb9912.png", true) 	// failing test below-	b.AssertFileExists("public/en/mybundle/pixel_hu_c8522c65d73a0421.png", true)+	b.AssertFileExists("public/en/mybundle/pixel_hu_410c334bfbcb9912.png", true) }  func TestMultihostResourceOneBaseURLWithSubPath(t *testing.T) {hugolib/pagesfromdata/pagesfromgotmpl_integration_test.goindex 4ed81c480..e7dfaad03 100644@@ -125,7 +125,7 @@ docs/p1/sub/mymixcasetext2.txt 		"RelPermalink: /docs/p1/sub/mymixcasetext2.txt|Name: sub/mymixcasetext2.txt|", 		"RelPermalink: /mydata.yaml|Name: sub/data1.yaml|Title: Sub data|Params: map[]|", 		"Featured Image: /a/pixel.png|featured.png|",-		"Resized Featured Image: /a/pixel_hu_a354833fd576551d.png|10|",+		"Resized Featured Image: /a/pixel_hu_bedb7691603c6b4d.png|10|", 		// Resource from string 		"RelPermalink: /docs/p1/mytext.txt|Name: textresource|Title: My Text Resource|Params: map[param1:param1v]|", 		// Datesinternal/warpc/avif_integration_test.goindex 9b3b68cb3..c44be07b7 100644@@ -83,9 +83,9 @@ text:{{ ($img.Process "avif text").RelPermalink }}| 	b := hugolib.Test(t, files) 	b.AssertFileContent("public/index.html", 		`-default:/logo_hu_72e150ce03376cfd.avif|-photo:/logo_hu_72e150ce03376cfd.avif|-text:/logo_hu_9de8f282912bc925.avif|+default:/logo_hu_72be6fac035caee7.avif|+photo:/logo_hu_72be6fac035caee7.avif|+text:/logo_hu_89614023638100ee.avif| `) } internal/warpc/webp_integration_test.goindex 857b1c3e8..cdd459372 100644@@ -38,12 +38,12 @@ ImageConfig: {{ printf "%d/%d" $ic.Width $ic.Height }}|  	b := hugolib.Test(t, files) -	b.ImageHelper("public/sunrise_hu_8dd1706a77fb35ce.webp").AssertFormat("webp").AssertIsAnimated(false)+	b.ImageHelper("public/sunrise_hu_3f86f07afd33f0cf.webp").AssertFormat("webp").AssertIsAnimated(false)  	b.AssertFileContent("public/index.html", 		"Original Width/Height: 1024/640|", 		"Resized Width:/Height 123/456|",-		"Resized RelPermalink: /sunrise_hu_8dd1706a77fb35ce.webp|",+		"Resized RelPermalink: /sunrise_hu_3f86f07afd33f0cf.webp|", 		"ImageConfig: 1024/640|", 	) }@@ -60,7 +60,7 @@ Resized RelPermalink: {{ $resized.RelPermalink }}|  	b := hugolib.Test(t, files) -	b.ImageHelper("public/gopher_hu_cc98ebaf742cba8e.webp").AssertFormat("webp")+	b.ImageHelper("public/gopher_hu_ea288bd5129549a4.webp").AssertFormat("webp") }  func TestWebPInvalid(t *testing.T) {@@ -112,13 +112,13 @@ sourcefilename: ../../resources/testdata/giphy.gif 	// Frame durations in ms. 	giphyFrameDurations := []int{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200} -	b.ImageHelper("public/giphy_hu_bb052284cc220165.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)-	b.ImageHelper("public/giphy_hu_c6b8060edf0363b1.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)+	b.ImageHelper("public/giphy_hu_be95bbbae6a8625a.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)+	b.ImageHelper("public/giphy_hu_5bb5701e38a6a79d.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)  	// Source animated webp: 	animFrameDurations := []int{80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80}-	b.ImageHelper("public/anim_hu_edc2f24aaad2cee6.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)-	b.ImageHelper("public/anim_hu_58eb49733894e7ce.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)+	b.ImageHelper("public/anim_hu_8a37856866ce0ae5.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)+	b.ImageHelper("public/anim_hu_7bee881b316e610f.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations) }  // See issue 14985.resources/image.goindex 10df3edda..190caa0be 100644@@ -321,8 +321,8 @@ func (i *imageResource) Filter(filters ...any) (images.ImageResource, error) { 		return nil, err 	} +	confMain.Key = confMain.FilterKey(gfilters) 	confMain.Action = images.ActionFilter-	confMain.Key = hashing.HashString(gfilters)  	// Geometric filters cannot introduce colors outside the source palette. 	for _, f := range gfilters {resources/image_test.goindex befb18cf2..0a3f8101a 100644@@ -113,28 +113,28 @@ func TestImageTransformBasic(t *testing.T) { 	assertWidthHeight(resizedAndRotated, 125, 200)  	assertWidthHeight(resized, 300, 200)-	c.Assert(resized.RelPermalink(), qt.Equals, "/a/sunset_hu_f4f15cdbaaca3b2d.jpg")+	c.Assert(resized.RelPermalink(), qt.Equals, "/a/sunset_hu_4253e92565fd4762.jpg")  	fitted, err := resized.Fit("50x50") 	c.Assert(err, qt.IsNil)-	c.Assert(fitted.RelPermalink(), qt.Equals, "/a/sunset_hu_c9781e950a09210.jpg")+	c.Assert(fitted.RelPermalink(), qt.Equals, "/a/sunset_hu_4178c144aac13fa5.jpg") 	assertWidthHeight(fitted, 50, 33)  	// Check the MD5 key threshold 	fittedAgain, _ := fitted.Fit("10x20") 	fittedAgain, err = fittedAgain.Fit("10x20") 	c.Assert(err, qt.IsNil)-	c.Assert(fittedAgain.RelPermalink(), qt.Equals, "/a/sunset_hu_78c1665fdce5ec4d.jpg")+	c.Assert(fittedAgain.RelPermalink(), qt.Equals, "/a/sunset_hu_2f7976e6f4b458be.jpg") 	assertWidthHeight(fittedAgain, 10, 7)  	filled, err := image.Fill("200x100 bottomLeft") 	c.Assert(err, qt.IsNil)-	c.Assert(filled.RelPermalink(), qt.Equals, "/a/sunset_hu_b3e01daae854e587.jpg")+	c.Assert(filled.RelPermalink(), qt.Equals, "/a/sunset_hu_53f1b268f6e519dc.jpg") 	assertWidthHeight(filled, 200, 100)  	smart, err := image.Fill("200x100 smart") 	c.Assert(err, qt.IsNil)-	c.Assert(smart.RelPermalink(), qt.Equals, "/a/sunset_hu_e548e0b0d6759ee7.jpg")+	c.Assert(smart.RelPermalink(), qt.Equals, "/a/sunset_hu_596ff1c1e90bc8d5.jpg") 	assertWidthHeight(smart, 200, 100)  	// Check cache@@ -144,12 +144,12 @@ func TestImageTransformBasic(t *testing.T) {  	cropped, err := image.Crop("300x300 topRight") 	c.Assert(err, qt.IsNil)-	c.Assert(cropped.RelPermalink(), qt.Equals, "/a/sunset_hu_9016246670a22728.jpg")+	c.Assert(cropped.RelPermalink(), qt.Equals, "/a/sunset_hu_ad8e3cbd7c52e97.jpg") 	assertWidthHeight(cropped, 300, 300)  	smartcropped, err := image.Crop("200x200 smart") 	c.Assert(err, qt.IsNil)-	c.Assert(smartcropped.RelPermalink(), qt.Equals, "/a/sunset_hu_2ffd7547f08a145d.jpg")+	c.Assert(smartcropped.RelPermalink(), qt.Equals, "/a/sunset_hu_c9028e212e68d1.jpg") 	assertWidthHeight(smartcropped, 200, 200)  	// Check cache@@ -216,7 +216,7 @@ func TestImageTransformFormat(t *testing.T) {  	imagePng, err := image.Resize("450x png") 	c.Assert(err, qt.IsNil)-	c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_63ccccb11ff4e285.png")+	c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_c0c4b885f5542da.png") 	c.Assert(imagePng.ResourceType(), qt.Equals, "image") 	assertExtWidthHeight(imagePng, ".png", 450, 281) 	c.Assert(imagePng.Name(), qt.Equals, "sunset.jpg")@@ -224,7 +224,7 @@ func TestImageTransformFormat(t *testing.T) {  	imageGif, err := image.Resize("225x gif") 	c.Assert(err, qt.IsNil)-	c.Assert(imageGif.RelPermalink(), qt.Equals, "/a/sunset_hu_6d1f23c09eddc748.gif")+	c.Assert(imageGif.RelPermalink(), qt.Equals, "/a/sunset_hu_599159c94ec6d6df.gif") 	c.Assert(imageGif.ResourceType(), qt.Equals, "image") 	assertExtWidthHeight(imageGif, ".gif", 225, 141) 	c.Assert(imageGif.Name(), qt.Equals, "sunset.jpg")@@ -247,7 +247,7 @@ func TestImagePermalinkPublishOrder(t *testing.T) { 			}()  			check1 := func(img images.ImageResource) {-				resizedLink := "/a/sunset_hu_3a097ae28aebc166.jpg"+				resizedLink := "/a/sunset_hu_dc0c41268a95f5d6.jpg" 				c.Assert(img.RelPermalink(), qt.Equals, resizedLink) 				assertImageFile(c, spec.PublishFs, resizedLink, 100, 50) 			}@@ -288,12 +288,12 @@ func TestImageBugs(t *testing.T) { 		c.Assert(err, qt.IsNil) 		c.Assert(resized, qt.Not(qt.IsNil)) 		c.Assert(resized.Width(), qt.Equals, 200)-		c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_a6f31c42e1afef07.jpg")+		c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_b6262524cc48e393.jpg") 		resized, err = resized.Resize("100x") 		c.Assert(err, qt.IsNil) 		c.Assert(resized, qt.Not(qt.IsNil)) 		c.Assert(resized.Width(), qt.Equals, 100)-		c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_14e106419fe28039.jpg")+		c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_c3bdac81d3d4d418.jpg") 	})  	// Issue #6137@@ -391,7 +391,7 @@ func TestImageResize8BitPNG(t *testing.T) { 	resized, err := image.Resize("800x") 	c.Assert(err, qt.IsNil) 	c.Assert(resized.MediaType().Type, qt.Equals, "image/png")-	c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_626cfc4db4222bfe.png")+	c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_f3671d30e944b55d.png") 	c.Assert(resized.Width(), qt.Equals, 800) } resources/images/config.goindex f7d5fc727..04e1c5cea 100644@@ -84,7 +84,8 @@ var (  	// Increment to mark all processed images as stale. Only use when absolutely needed. 	// See the finer grained smartCropVersionNumber.-	mainImageVersionNumber = 1+	// Last increment: after the filter fixes for transparent colors and paletted images (issues 12536, 12543).+	mainImageVersionNumber = 2  	// Increment a format's version number to mark all processed images targeting 	// that format as stale, e.g. after a change to its encoder. This is finer@@ -335,6 +336,17 @@ func DecodeImageConfig(options []string, defaults *config.ConfigNamespace[Imagin 		return c, err 	} +	options = append(options, c.versionOptions()...)++	c.Key = hashing.HashStringHex(options)++	return c, nil+}++// versionOptions returns the version numbers to include in the cache key.+func (c ImageConfig) versionOptions() []string {+	var options []string+ 	if mainImageVersionNumber > 0 { 		options = append(options, strconv.Itoa(mainImageVersionNumber)) 	}@@ -348,9 +360,13 @@ func DecodeImageConfig(options []string, defaults *config.ConfigNamespace[Imagin 		options = append(options, strconv.Itoa(smartCropVersionNumber)) 	} -	c.Key = hashing.HashStringHex(options)+	return options+} -	return c, nil+// FilterKey returns the cache key for the given filter chain applied using this config.+// It includes the image version numbers, so bumping them also invalidates filtered images.+func (c ImageConfig) FilterKey(filters []gift.Filter) string {+	return hashing.HashString(filters, c.versionOptions()) }  // ImageConfig holds configuration to create a new image from an existing one, resize etc.resources/images/config_test.goindex 2adc1fe37..fb0093c26 100644@@ -19,6 +19,7 @@ import ( 	"testing"  	qt "github.com/frankban/quicktest"+	"github.com/gohugoio/gift" )  func TestDecodeConfig(t *testing.T) {@@ -137,6 +138,34 @@ func TestImageConfigPerFormat(t *testing.T) { 	c.Assert(conf("jpeg").Compression, qt.Equals, "") } +func TestImageConfigMainVersionNumber(t *testing.T) {+	c := qt.New(t)++	cfg, err := DecodeConfig(map[string]any{})+	c.Assert(err, qt.IsNil)++	filters := []gift.Filter{gift.Grayscale()}++	keys := func() (string, string) {+		conf, err := DecodeImageConfig([]string{"resize", "100x"}, cfg, PNG)+		c.Assert(err, qt.IsNil)+		filterConf, err := DecodeImageConfig(nil, cfg, PNG)+		c.Assert(err, qt.IsNil)+		return conf.Key, filterConf.FilterKey(filters)+	}++	processBefore, filterBefore := keys()++	orig := mainImageVersionNumber+	defer func() { mainImageVersionNumber = orig }()+	mainImageVersionNumber = orig + 1++	// Bumping the main version invalidates both processed and filtered images.+	processAfter, filterAfter := keys()+	c.Assert(processAfter, qt.Not(qt.Equals), processBefore)+	c.Assert(filterAfter, qt.Not(qt.Equals), filterBefore)+}+ func TestDecodeImageConfig(t *testing.T) { 	c := qt.New(t) resources/images/imagetesting/testing.goindex 29c4ef4c4..a22b6b019 100644@@ -122,7 +122,7 @@ func RunGolden(opts GoldenImageTestOpts) *hugolib.IntegrationTestBuilder { 	shouldSkip := func(d fs.DirEntry) bool { 		if runtime.GOARCH == "arm64" { 			// TODO(bep) figure out why this fails on arm64. I have inspected the images, and they look identical.-			if d.Name() == "giphy_hu_bb052284cc220165.webp" {+			if d.Name() == "giphy_hu_be95bbbae6a8625a.webp" { 				c.Logf("skipping %s on %s", d.Name(), runtime.GOARCH) 				return true 			}resources/images/testdata/images_golden/webp/animation/anim_hu_7bee881b316e610f.gifnew file mode 100644index 000000000..eeabfc836Binary files /dev/null and b/resources/images/testdata/images_golden/webp/animation/anim_hu_7bee881b316e610f.gif differresources/images/testdata/images_golden/webp/animation/anim_hu_8a37856866ce0ae5.webpnew file mode 100644index 000000000..ac9052d4aBinary files /dev/null and b/resources/images/testdata/images_golden/webp/animation/anim_hu_8a37856866ce0ae5.webp differresources/images/testdata/images_golden/webp/animation/giphy_hu_5bb5701e38a6a79d.gifnew file mode 100644index 000000000..66a6b73deBinary files /dev/null and b/resources/images/testdata/images_golden/webp/animation/giphy_hu_5bb5701e38a6a79d.gif differresources/images/testdata/images_golden/webp/animation/giphy_hu_be95bbbae6a8625a.webpnew file mode 100644index 000000000..5b6e9453dBinary files /dev/null and b/resources/images/testdata/images_golden/webp/animation/giphy_hu_be95bbbae6a8625a.webp differresources/resources_integration_test.goindex 71216e304..d607edfad 100644@@ -56,9 +56,9 @@ anigif: {{ $anigif.RelPermalink }}|{{ $anigif.Width }}|{{ $anigif.Height }}|{{ $  	assertImages := func() { 		b.AssertFileContent("public/index.html", `-gif: /mybundle/pixel_hu_d6bad5e71f783c98.gif|}|1|2|image/gif|-bmp: /mybundle/pixel_hu_a8812c9bf8812b53.bmp|}|2|3|image/bmp|-anigif: /mybundle/giphy_hu_7f64f85f904209d4.gif|4|5|image/gif|+gif: /mybundle/pixel_hu_a1e8150a56cb86d6.gif|}|1|2|image/gif|+bmp: /mybundle/pixel_hu_bd3c9bd9bbbdf258.bmp|}|2|3|image/bmp|+anigif: /mybundle/giphy_hu_1d76e84bfc3d8be8.gif|4|5|image/gif| 		`) 	} @@ -143,9 +143,9 @@ resize 2|RelPermalink: {{ $image.RelPermalink }}|MediaType: {{ $image.MediaType 	b := hugolib.Test(t, files)  	b.AssertFileContent("public/index.html",-		"jpg|RelPermalink: /images/pixel_hu_38c3f257174fc757.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",-		"resize 1|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",-		"resize 2|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+		"jpg|RelPermalink: /images/pixel_hu_dcd1717ec1fcf2cf.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",+		"resize 1|RelPermalink: /images/pixel_hu_836c41a765f88a95.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+		"resize 2|RelPermalink: /images/pixel_hu_836c41a765f88a95.jpg|MediaType: image/jpeg|Width: 20|Height: 30|", 	) } resources/transform_test.goindex feae43e41..d1dce2118 100644@@ -386,15 +386,15 @@ func TestTransform(t *testing.T) { 		resizedPublished1, err := img.Resize("40x40") 		c.Assert(err, qt.IsNil) 		c.Assert(resizedPublished1.Height(), qt.Equals, 40)-		c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_6347c67500afc377.png")-		assertShouldExist(c, spec, "public/gopher.changed_hu_6347c67500afc377.png", true)+		c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_46ada7dd67960f21.png")+		assertShouldExist(c, spec, "public/gopher.changed_hu_46ada7dd67960f21.png", true)  		// Permalink called. 		resizedPublished2, err := img.Resize("30x30") 		c.Assert(err, qt.IsNil) 		c.Assert(resizedPublished2.Height(), qt.Equals, 30)-		c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_2d293650135f63d6.png")-		assertShouldExist(c, spec, "public/gopher.changed_hu_2d293650135f63d6.png", true)+		c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_5fcc3eee2f2f036b.png")+		assertShouldExist(c, spec, "public/gopher.changed_hu_5fcc3eee2f2f036b.png", true)  		assertNoDuplicateWrites(c, spec) 	})testscripts/commands/hugo_gc_mixed_case_cache_dir.txtindex 7c7af1373..68f4d219b 100644@@ -11,7 +11,7 @@ hugo  stdout 'Processed images │  1 ' tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_bedb7691603c6b4d.png'  # Simulate a cache created by an older Hugo version. mv resources/_gen/images/mybundle resources/_gen/images/MyBundle@@ -20,7 +20,7 @@ hugo --gc stdout 'Cleaned          │  0 '  tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_bedb7691603c6b4d.png'  -- hugo.toml -- disableKinds = ["term", "taxonomy", "home"]tpl/images/images_integration_test.goindex 55b541ff1..07fddf40d 100644@@ -161,8 +161,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } 	b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.png-Brightnes func: /qr_hu_d5f06fd7594d0594.png+Brightnes method: /qr_hu_d7c784084b06d42d.png+Brightnes func: /qr_hu_d7c784084b06d42d.png `) } @@ -184,8 +184,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } 	b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.webp-Brightnes func: /qr_hu_d5f06fd7594d0594.webp+Brightnes method: /qr_hu_d7c784084b06d42d.webp+Brightnes func: /qr_hu_d7c784084b06d42d.webp `) } @@ -214,7 +214,7 @@ Image: {{ $img.RelPermalink }} 			cfg.NeedsOsFS = true 			cfg.WorkingDir = tempDir 		}))-		b.AssertFileContent("public/index.html", `Image: /qr_hu_6b5f59be9c4d3b3a.webp`)+		b.AssertFileContent("public/index.html", `Image: /qr_hu_172a70d73ea40275.webp`)  	} }tpl/resources/resources_integration_test.goindex b5c611d52..43e3292ab 100644@@ -60,7 +60,7 @@ Copy3: {{ $copy3.RelPermalink}}|{{ $copy3.MediaType }}|{{ $copy3.Content | safeJ  	b.AssertFileContent("public/index.html", ` Image Orig:  /blog/images/pixel.png|image/png|1|1|-Image Copy1:  /blog/images/copy_hu_ef85c36d9b9eff0.png|image/png|3|4|+Image Copy1:  /blog/images/copy_hu_10bd41e3dfc8ade0.png|image/png|3|4| Image Copy2:  /blog/images/copy2.png|image/png|3|4| Image Copy3:  image/png|3|4| Orig: /blog/js/foo.js|text/javascript|let foo;| 
Merged fix · PR #+62 −40
hugolib/hugo_sites_multihost_test.goindex 3ecfa7e9d..5769fc64e 100644@@ -154,11 +154,13 @@ title: "Mybundle fr" ` 	b := Test(t, files) -	b.AssertFileContent("public/fr/section/mybundle/index.html",+	b.AssertFileContent(+		"public/fr/section/mybundle/index.html", 		"fr: .body{color:french}|/section/mybundle/styles.min.css|", 	) -	b.AssertFileContent("public/en/section/mybundle/index.html",+	b.AssertFileContent(+		"public/en/section/mybundle/index.html", 		"en: .body{color:english}|/section/mybundle/styles.min.css|", 	) @@ -207,9 +209,9 @@ title: mybundle-en 	b.AssertFileExists("public/de/mybundle/pixel.png", true) 	b.AssertFileExists("public/en/mybundle/pixel.png", true) -	b.AssertFileExists("public/de/mybundle/pixel_hu_c8522c65d73a0421.png", true)+	b.AssertFileExists("public/de/mybundle/pixel_hu_a25c5b589ae00856.png", true) 	// failing test below-	b.AssertFileExists("public/en/mybundle/pixel_hu_c8522c65d73a0421.png", true)+	b.AssertFileExists("public/en/mybundle/pixel_hu_a25c5b589ae00856.png", true) }  func TestMultihostResourceOneBaseURLWithSubPath(t *testing.T) {hugolib/pagesfromdata/pagesfromgotmpl_integration_test.goindex 4ed81c480..ee3569f29 100644@@ -112,7 +112,8 @@ docs/p1/sub/mymixcasetext2.txt 	// Page from markdown file. 	b.AssertFileContent("public/docs/pfile/index.html", "Dates: Date: 2023-03-01|Lastmod: 2023-03-01|PublishDate: 2023-03-01|ExpiryDate: 0001-01-01|") 	// Pages from gotmpl.-	b.AssertFileContent("public/docs/p1/index.html",+	b.AssertFileContent(+		"public/docs/p1/index.html", 		"Single: p1:p1|", 		"Path: /docs/p1|", 		"<strong>Hello World</strong>",@@ -125,7 +126,7 @@ docs/p1/sub/mymixcasetext2.txt 		"RelPermalink: /docs/p1/sub/mymixcasetext2.txt|Name: sub/mymixcasetext2.txt|", 		"RelPermalink: /mydata.yaml|Name: sub/data1.yaml|Title: Sub data|Params: map[]|", 		"Featured Image: /a/pixel.png|featured.png|",-		"Resized Featured Image: /a/pixel_hu_a354833fd576551d.png|10|",+		"Resized Featured Image: /a/pixel_hu_51638841a22bb583.png|10|", 		// Resource from string 		"RelPermalink: /docs/p1/mytext.txt|Name: textresource|Title: My Text Resource|Params: map[param1:param1v]|", 		// Dates@@ -174,25 +175,29 @@ allow = [%s] 	b := hugolib.Test(t, files)  	if supportsAsciiDoc {-		b.AssertFileContent("public/docs/asciidoc/index.html",+		b.AssertFileContent(+			"public/docs/asciidoc/index.html", 			"Mark my words, <mark>automation is essential</mark>", 			"Path: /docs/asciidoc|", 		) 	} 	if supportsPandoc {-		b.AssertFileContent("public/docs/pandoc/index.html",+		b.AssertFileContent(+			"public/docs/pandoc/index.html", 			"This <del>is deleted text.</del>", 			"Path: /docs/pandoc|", 		) 	} 	if supportsRst {-		b.AssertFileContent("public/docs/rst/index.html",+		b.AssertFileContent(+			"public/docs/rst/index.html", 			"This is <em>bold</em>", 			"Path: /docs/rst|", 		) 	} -	b.AssertFileContent("public/docs/org/index.html",+	b.AssertFileContent(+		"public/docs/org/index.html", 		"the ability to use <del>strikethrough</del> is a plus", 		"Path: /docs/org|", 	)@@ -305,14 +310,16 @@ func TestPagesFromGoTmplMovePage(t *testing.T) { func TestPagesFromGoTmplRemoveGoTmpl(t *testing.T) { 	t.Parallel() 	b := hugolib.TestRunning(t, filesPagesFromDataTempleBasic)-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		"RegularPagesRecursive: p1:p1:/docs/p1|p2title:/docs/p2|p3title:/docs/p3|p4title:/docs/p4|pfile:/docs/pfile|$", 		"Sections: Docs:/docs|", 	) 	b.AssertFileContent("public/docs/index.html", "RegularPagesRecursive: p1:p1:/docs/p1|p2title:/docs/p2|p3title:/docs/p3|p4title:/docs/p4|pfile:/docs/pfile|$") 	b.RemoveFiles("content/docs/_content.gotmpl").Build() 	// One regular page left.-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		"RegularPagesRecursive: pfile:/docs/pfile|$", 		"Sections: Docs:/docs|", 	)@@ -596,7 +603,8 @@ disableKinds = ['home','section','rss','sitemap','taxonomy','term']  	b := hugolib.Test(t, files) -	b.AssertFileContent("public/p1/index.html",+	b.AssertFileContent(+		"public/p1/index.html", 		"p1|param1v", 		"data1.yaml|param1v", 	)@@ -651,7 +659,8 @@ Footer: {{ range index site.Menus.footer }}{{ .Name }}|{{ end }}| ` 	b := hugolib.Test(t, files) -	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		"Main: Main|p1|p2||", 		"Footer: Footer|p2||", 	)@@ -706,7 +715,8 @@ summary: {{ .Summary }}|content: {{ .Content}}  	b := hugolib.Test(t, files) -	b.AssertFileContent("public/s1/p1/index.html",+	b.AssertFileContent(+		"public/s1/p1/index.html", 		"<p>aaa</p>|content: <p>aaa</p>\n<p>bbb</p>", 	) }resources/image.goindex 10df3edda..7058eebb8 100644@@ -322,7 +322,14 @@ func (i *imageResource) Filter(filters ...any) (images.ImageResource, error) { 	}  	confMain.Action = images.ActionFilter-	confMain.Key = hashing.HashString(gfilters)+	opts := []any{gfilters}+	if images.MainImageVersionNumber > 0 {+		opts = append(opts, images.MainImageVersionNumber)+	}+	if v := images.FormatVersionNumbers[confMain.TargetFormat]; v > 0 {+		opts = append(opts, v)+	}+	confMain.Key = hashing.HashString(opts...)  	// Geometric filters cannot introduce colors outside the source palette. 	for _, f := range gfilters {resources/image_test.goindex befb18cf2..c01d8ad35 100644@@ -216,7 +216,7 @@ func TestImageTransformFormat(t *testing.T) {  	imagePng, err := image.Resize("450x png") 	c.Assert(err, qt.IsNil)-	c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_63ccccb11ff4e285.png")+	c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_ae7e4a663628f945.png") 	c.Assert(imagePng.ResourceType(), qt.Equals, "image") 	assertExtWidthHeight(imagePng, ".png", 450, 281) 	c.Assert(imagePng.Name(), qt.Equals, "sunset.jpg")@@ -391,7 +391,7 @@ func TestImageResize8BitPNG(t *testing.T) { 	resized, err := image.Resize("800x") 	c.Assert(err, qt.IsNil) 	c.Assert(resized.MediaType().Type, qt.Equals, "image/png")-	c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_626cfc4db4222bfe.png")+	c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_3ddd57bfb01f7376.png") 	c.Assert(resized.Width(), qt.Equals, 800) } resources/images/config.goindex f7d5fc727..4dd859036 100644@@ -84,13 +84,14 @@ var (  	// Increment to mark all processed images as stale. Only use when absolutely needed. 	// See the finer grained smartCropVersionNumber.-	mainImageVersionNumber = 1+	MainImageVersionNumber = 1  	// Increment a format's version number to mark all processed images targeting 	// that format as stale, e.g. after a change to its encoder. This is finer 	// grained than mainImageVersionNumber, which invalidates every format.-	formatVersionNumbers = map[Format]int{+	FormatVersionNumbers = map[Format]int{ 		AVIF: 1,+		PNG:  1, // See issue 12543, 12536 	} ) @@ -335,11 +336,11 @@ func DecodeImageConfig(options []string, defaults *config.ConfigNamespace[Imagin 		return c, err 	} -	if mainImageVersionNumber > 0 {-		options = append(options, strconv.Itoa(mainImageVersionNumber))+	if MainImageVersionNumber > 0 {+		options = append(options, strconv.Itoa(MainImageVersionNumber)) 	} -	if v := formatVersionNumbers[c.TargetFormat]; v > 0 {+	if v := FormatVersionNumbers[c.TargetFormat]; v > 0 { 		options = append(options, "tfv"+strconv.Itoa(v)) 	} resources/resources_integration_test.goindex 71216e304..69863eaf2 100644@@ -143,9 +143,9 @@ resize 2|RelPermalink: {{ $image.RelPermalink }}|MediaType: {{ $image.MediaType 	b := hugolib.Test(t, files)  	b.AssertFileContent("public/index.html",-		"jpg|RelPermalink: /images/pixel_hu_38c3f257174fc757.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",-		"resize 1|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",-		"resize 2|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+		"jpg|RelPermalink: /images/pixel_hu_43e529ee1951bebf.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",+		"resize 1|RelPermalink: /images/pixel_hu_81fc53effe4c3cf6.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+		"resize 2|RelPermalink: /images/pixel_hu_81fc53effe4c3cf6.jpg|MediaType: image/jpeg|Width: 20|Height: 30|", 	) } resources/transform_test.goindex feae43e41..7f5869ab0 100644@@ -386,15 +386,15 @@ func TestTransform(t *testing.T) { 		resizedPublished1, err := img.Resize("40x40") 		c.Assert(err, qt.IsNil) 		c.Assert(resizedPublished1.Height(), qt.Equals, 40)-		c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_6347c67500afc377.png")-		assertShouldExist(c, spec, "public/gopher.changed_hu_6347c67500afc377.png", true)+		c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_dbaf8010a3fe3487.png")+		assertShouldExist(c, spec, "public/gopher.changed_hu_dbaf8010a3fe3487.png", true)  		// Permalink called. 		resizedPublished2, err := img.Resize("30x30") 		c.Assert(err, qt.IsNil) 		c.Assert(resizedPublished2.Height(), qt.Equals, 30)-		c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_2d293650135f63d6.png")-		assertShouldExist(c, spec, "public/gopher.changed_hu_2d293650135f63d6.png", true)+		c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_83657b4754113fc4.png")+		assertShouldExist(c, spec, "public/gopher.changed_hu_83657b4754113fc4.png", true)  		assertNoDuplicateWrites(c, spec) 	})testscripts/commands/hugo_gc_mixed_case_cache_dir.txtindex 7c7af1373..b548ccedd 100644@@ -11,7 +11,7 @@ hugo  stdout 'Processed images │  1 ' tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_51638841a22bb583.png'  # Simulate a cache created by an older Hugo version. mv resources/_gen/images/mybundle resources/_gen/images/MyBundle@@ -20,7 +20,7 @@ hugo --gc stdout 'Cleaned          │  0 '  tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_51638841a22bb583.png'  -- hugo.toml -- disableKinds = ["term", "taxonomy", "home"]tpl/images/images_integration_test.goindex 55b541ff1..0969d5972 100644@@ -79,7 +79,8 @@ disableKinds = ['page','rss','section','sitemap','taxonomy','term'] `  	b := hugolib.Test(t, files)-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		`<img data-id="0" data-img-hash="6ccacf8056c41475" data-level="" data-scale="" data-targetDir="" src="/qr_924bf7d80a564b23.png">`, 		`<img data-id="1" data-img-hash="6ccacf8056c41475" data-level="medium" data-scale="" data-targetDir="" src="/qr_924bf7d80a564b23.png">`, 		`<img data-id="2" data-img-hash="6ccacf8056c41475" data-level="medium" data-scale="4" data-targetDir="" src="/qr_924bf7d80a564b23.png">`,@@ -161,8 +162,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } 	b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.png-Brightnes func: /qr_hu_d5f06fd7594d0594.png+Brightnes method: /qr_hu_e82a6802e23c740e.png+Brightnes func: /qr_hu_e82a6802e23c740e.png `) } @@ -184,8 +185,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } 	b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.webp-Brightnes func: /qr_hu_d5f06fd7594d0594.webp+Brightnes method: /qr_hu_61e637d0f762ec78.webp+Brightnes func: /qr_hu_61e637d0f762ec78.webp `) } @@ -214,7 +215,7 @@ Image: {{ $img.RelPermalink }} 			cfg.NeedsOsFS = true 			cfg.WorkingDir = tempDir 		}))-		b.AssertFileContent("public/index.html", `Image: /qr_hu_6b5f59be9c4d3b3a.webp`)+		b.AssertFileContent("public/index.html", `Image: /qr_hu_7178b50f0d0a9def.webp`)  	} }tpl/resources/resources_integration_test.goindex b5c611d52..736aee337 100644@@ -60,7 +60,7 @@ Copy3: {{ $copy3.RelPermalink}}|{{ $copy3.MediaType }}|{{ $copy3.Content | safeJ  	b.AssertFileContent("public/index.html", ` Image Orig:  /blog/images/pixel.png|image/png|1|1|-Image Copy1:  /blog/images/copy_hu_ef85c36d9b9eff0.png|image/png|3|4|+Image Copy1:  /blog/images/copy_hu_e592d810de530dee.png|image/png|3|4| Image Copy2:  /blog/images/copy2.png|image/png|3|4| Image Copy3:  image/png|3|4| Orig: /blog/js/foo.js|text/javascript|let foo;|@@ -271,7 +271,8 @@ disableKinds = ['page','section','rss','sitemap','taxonomy','term']  	b := hugolib.Test(t, files, hugolib.TestOptWarn()) -	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		".dartsass{color:red}", 		".libsass{color:blue}", 	)