Resizing a particular image with webp extension throws invalid format error

I have a strange reaction with a webp image. Nearly all of my images are of this format, but this one

config: brand = "/Images/history/favicons/brand_symbol2.webp"

{{with resources.Get .Site.Params.brand}}
{{- $smallest := "" -}}
{{ if gt .Width 200 }}
	{{ $smallest = .Resize "200x" }} <----- *go Bbbbrrrrr*
{{ else }}
	{{ $smallest = . }}
{{ end }}


Error: error building site: render: failed to render pages: render of "page" failed: "WEBSITE/layouts/_default/baseof.html:11:3": execute of template failed: template: _default/single.html:11:3: executing "_default/single.html" at <partialCached "docs/brand" .>: error calling partialCached: "WEBSITE/layouts/partials/docs/brand.html:4:16": execute of template failed: template: partials/docs/brand.html:4:16: executing "partials/docs/brand.html" at <.Resize>: error calling Resize: image "/Images/history/favicons/brand_symbol2.webp": resize /Images/history/favicons/brand_symbol2.webp: webp: invalid format

I used the same picture in an article with ![sdsd](/Images/history/favicons/brand_symbol2.webp), causing the same error, so it’s likely not the partial’s syntax. What does it say ? given that it looks for the format, I assume it does try to create
brand_symbol2_hue891e6a90f675cf2ed19dc7091cda160_176196_200x0_resize_q100_h2_box_2.webp but it’s 0-sized.

It’s either an animated WebP image, or it’s some other image type with a webp extension.

Use exiftool to analyze the image.

exiftool brand_symbol2.webp

ExifTool Version Number : 12.60
File Name : brand_symbol2.webp
Directory : .
File Size : 176 kB
File Modification Date/Time : 2023:05:25 00:50:10+02:00
File Access Date/Time : 2023:05:25 00:50:10+02:00
File Inode Change Date/Time : 2023:05:25 00:50:10+02:00
File Permissions : -rw-r–r–
File Type : Extended WEBP
File Type Extension : webp
MIME Type : image/webp
WebP Flags : Alpha, ICC Profile
Image Width : 676
Image Height : 313
Profile CMM Type : Little CMS
Profile Version : 4.4.0
Profile Class : Display Device Profile
Color Space Data : RGB
Profile Connection Space : XYZ
Profile Date Time : 2023:05:24 22:49:46
Profile File Signature : acsp
Primary Platform : Apple Computer Inc.
CMM Flags : Not Embedded, Independent
Device Manufacturer :
Device Model :
Device Attributes : Reflective, Glossy, Positive, Color
Rendering Intent : Perceptual
Connection Space Illuminant : 0.9642 1 0.82491
Profile Creator : Little CMS
Profile ID : 0
Profile Description : GIMP built-in sRGB
Profile Copyright : Public Domain
Media White Point : 0.9642 1 0.82491
Chromatic Adaptation : 1.04788 0.02292 -0.05022 0.02959 0.99048 -0.01707 -0.00925 0.01508 0.75168
Red Matrix Column : 0.43604 0.22249 0.01392
Blue Matrix Column : 0.14305 0.06061 0.71393
Green Matrix Column : 0.38512 0.7169 0.09706
Red Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Blue Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Chromaticity Channels : 3
Chromaticity Colorant : Unknown
Chromaticity Channel 1 : 0.64 0.33002
Chromaticity Channel 2 : 0.3 0.60001
Chromaticity Channel 3 : 0.15001 0.06
Device Mfg Desc : GIMP
Device Model Desc : sRGB
Image Size : 676x313
Megapixels : 0.212

File Type : Extended WEBP
File Type Extension : webp
MIME Type : image/webp
WebP Flags : Alpha, ICC Profile

What part of that looks abnormal ?

If you want help, you need to share a link to the original image.

I thought copying would suffice, my bad. here

Exported from GIMP? If yes, are you using the latest version?

If I take your image through an ImageMagick roundtrip it loads fine. So there’s something about the file that Go’s image decoder doesn’t like.

I also tested with previous Hugo versions—this isn’t anything new.

Simple reproducible example:

git clone --single-branch -b hugo-forum-topic-44540 hugo-forum-topic-44540
cd hugo-forum-topic-44540

Is it the alpha transparency causing the problem?

Exported from GIMP? If yes, are you using the latest version?

yes, very last stable version, 2.10.34-1.

Are you having problems with all WebP images exported from gimp or just this one?

Oh, interesting, I forgot that all those exported are in static, as css backgrounds !
Yes, all exported webp (not jpg) files produce that error. So the issue in gimp… Trying the development version.

Well, that’s the file creator, but Go’s image package should be able to decode these without error. You can drag/drop your file into a browser window—it works fine. Exiftool doesn’t barf. ImageMagick doesn’t barf.

Do I have your permission to share the example file with the Go team?

by all means. Glad to contribute in any way I can.

1 Like

If the dev version of GIMP doesn’t help, you can use cwebp to reprocess your files from WebP to WebP.


This might be a good idea regardless, because the WebP images from GIMP seem a bit bloated.

Perfect, cwebp does it. No difference in size though when it comes to the lossless mode, over 6Mo it barely removed 20ko. So it’s a bit of an incompatibility between go and gimp I suppose.

Would you mind creating a 100 pixel by 100 pixel simple image that behaves the same way? That would be a better example for the go team. And then post it somewhere so that I may download the original. Thanks.

I correct myself. Not all exported images.

  • it is specific to pictures with actual transparency in them. Just having an empty alpha channel does not trigger anything.
  • the issue breaks down below a 210 px width/height (a square, as you asked), regardless of interpolation method or lack thereof.

Here it is: essai2.webp - Google Drive

This one is working fine for me.

oh sh$t, imgBB alters picture a lot, I didn’t know. Link corrected and tested.



This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.