Resized images (some) truncated to 0 bytes

I have a website that uses a lot of images.

Recently I observed a strange behaviour: as I generate the website, some resized files are truncated to 0 bytes.

The log files do not show any errors. Resizing basically works but the number of files truncated raises from release to release.

I switched to 0.59.1 from (0.56.x) but both releases truncate the same set of images…

What may cause this problem?

Are you saying that if you delee /resources/gen/_images and do a new build the same set of images gets truncated?

Seems that we at least have a bug in the error handling department, and I’m a little surprised that you see no indication of any error – if we fail to decode/resize the image we should also fail to encode it…

But this is guessing. If this is reproducable with 1 image, it would be great if you could somehow share that image with me so I could look at it.

Thank you for this advice. I was completely unaware of that directory containing generated files. At first this was an explanation, why every time the same image was truncated…

I’ve deleted the resources and public folder and generated the website another time. Due to the content, I’ve ran into the following message:

Gwenfrewi:avd_infopoint ralf$ /usr/local/bin/hugo --verbose --verboseLog

Total in 31773 ms

Error: Error building site: **"/Users/ralf/git/avd_infopoint/content/posts/2017-07-29-juicy-beats/index.md:1:1"** : timed out initializing value. This is most likely a circular loop in a shortcode

The second attempt was much faster and succeeded. But one image was truncated…

I’ve deleted this very same image and started again. Now only that missing image gets generated and all’s well :slight_smile:

Obviously as the time-out thingy raises, hugo leaves empty files around.

Is there any chance to increase the time-out value?

Set timeout in your config (it’s in milliseconds, so 10000 = 10 seconds).

OK, I will create an issue on GitHub to track this, which I suspect is two issues:

  • The truncation of images. I suspect this happens when it times out, but it should be handled more gracefully.
  • The error handling when reading these from cache. Hugo should have detected that the image was invalid and re-generated it.

I’ve been hitting this too - lots of image derivatives in a shortcode for image srcset attribute - I was looking for a way to increase the timeout in the docs. Thanks bep!

I’ve also had an issue when building my site with --ignoreCache. A single resized image will always end up with 0 Bytes (only used in one location).

It works just fine without --ignoreCache. I’ve had it enabled on my build server so my workaround is just turning it off for now.

There is no error even when building with the --verbose flag. I’ve also tired to increase the timeout value with no change.

I’m getting the same issue - images being rendered to 0 bytes size. Somehow, it depends on the exact size and the format (jpg/png). Removing --ignoreCache flags helped me as well.
Vrsion: hugo v0.105.0+extended darwin/amd64 BuildDate=unknown

This is a known issue.

https://github.com/gohugoio/hugo/issues/8025