Skip to content

AVIF: "Error: source: bad seek to ..." with 0.28.1 #2688

Closed

Description

@alexjeffburke

What are the steps to reproduce?
Run the following script after unzipping the attached test image:

const fs = require('fs');
const sharp = require('sharp');

const inputStream = fs.createReadStream(
  'testimage.avif'
);

const sharpStream = sharp()
  .jpeg()
  .toFile('output.jpg', function (err) {
    console.log(err);
  });

inputStream.pipe(sharpStream);

What is the expected behaviour?
With sharp 0.27.2, an output image is correctly generated and null is logged to the console. With sharp 0.28.1, the bad seek error is logged. An output file is present but appears to be empty.

Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?
See above.

Are you able to provide a sample image that helps explain the problem?
See attached.

What is the output of running npx envinfo --binaries --system?

  System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 39.01 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.22.1 - ~/.nvm/versions/node/v12.22.1/bin/node
    npm: 6.14.12 - ~/.nvm/versions/node/v12.22.1/bin/npm

testimage.avif.zip

Activity

  1. lovell commented on May 2, 2021

    @lovell
    Owner

    This looks like a 10-bit AVIF image.

    $ heif-info -d testimage.avif | grep bit
    | | | bits_per_channel: 10,10,10
    | | | high_bitdepth: 1
    | | | twelve_bit: 0

    Please see the changelog for v0.28.0 at https://sharp.pixelplumbing.com/changelog#v0280---29th-march-2021

    • Prebuilt binaries limit AVIF support to the most common 8-bit depth.

    We should probably try to improve the error messaging, which is likely to involve a libvips or libheif change.

  2. alexjeffburke commented on May 2, 2021

    @alexjeffburke
    Author

    @lovell ahhh ok, thanks for checking this. My confusion was having a previously working test in a package that depends on sharp fail when I tried to drop the newer version in. Just for my own understanding, does it blow up the size of the libraries to have the additional bit depths?

    Definitely think a more specific error message wouold be really helpful, although I appreciate arranging something specific for this case could be a challenge. I was a little surprised that an empty file would be written, but I guess that is because the error actually comes out of the stream as it sees bytes that aren't understood (and as it happens the way it's used in the dependent module wouldn't result in this).

  3. lovell commented on May 2, 2021

    @lovell
    Owner

    Yes, not supporting higher bit depths reduces the binary size of the aom dependency by ~30%. Output AVIF images from sharp/libvips were and still are always 8-bit per channel.

    Please subscribe to lovell/sharp-libvips#97 for updates about a possible switch to smaller/faster alternatives for AVIF that might allow reading higher bit depth images again.

    It looks like libheif generates a "warning" for this image with the message Unspecified: Success (2.0) so that's probably the first thing to fix.

  4. added a commit that references this issue on May 5, 2021
  5. lovell commented on May 8, 2021

    @lovell
    Owner

    PR to improve the libheif error messaging at strukturag/libheif#497

  6. Zutatensuppe commented on Dec 21, 2023

    @Zutatensuppe

    any hope of getting images with bit depth 10 supported? (by default)

  7. lovell commented on Dec 21, 2023

    @lovell
    Owner

    @Zutatensuppe Please subscribe to lovell/sharp-libvips#97 for updates about a possible switch to smaller/faster alternatives for AVIF that might allow reading higher bit depth images again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions