Skip to content

Thumbnail generation fails in some AVIF images #6277

@z9gccs4zkw-ship-it

Description

@z9gccs4zkw-ship-it

Describe the bug

Hi,

I've been recently getting the following error in my logs:

Error   
image encoder error when running command </usr/bin/vips thumbnail_source [descriptor=0] .jpg[Q=70,strip] 640 --size down>: 
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 0
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 1
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 2
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 3
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 4
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 5
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 6
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 7
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 8
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 9
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 0
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 10
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 20
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 30
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 0
(vips:580): VIPS-WARNING **: 14:47:03.419: error in tile 0 x 10
source: bad seek to 250

This used to work in the previous version and only happens to some images, after some investigation it seems the VIPS-libheif library deprecated a "partial read fallback" so is now unable to process an avif/heic file if it requires a seek() to another part of the file.

Some .avif files require to seek other parts of the file to correctly decode the image, for example:

  • images with EXIF blocks at the end
  • tiled HEIF images
  • grid images
  • HEVC chunks that reference offsets backward in the stream

It seems the problem arises because the command uses [descriptor=0] which means it's reading linearly from STDIN and cannot randomly seek the file and it fails on all the avif files that require to seek to another part of the file.

I'm definitely not qualified to make a fix in the /pkg/image/vips.go file but could someone make a fix to not tu use STDIN and instead read directly from the file or maybe create a temporary file to RAM or somewhere else so the thumbnail generation doesn't fail?

If i use the same command manually pointing to the file directly instead of using [descriptor=0] it works but I'm not sure what removing that would entail.

Steps to reproduce

  1. Scan a bunch of .avif photos
  2. If the avif picture requires a seek to another part of the file it will fail and not generate it.

Expected behaviour

The thumbnail generation should create thumbnails of the avif files and write them in jpg format

Screenshots or additional context

No response

Stash version

v0.29.3

I've attached a test SFW image that fails the thumbnail generation process

file_example_JPG_2500kB.avif.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug reportBug reports that are not yet verified

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions