Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alexjeffburke opened this issue May 2, 2021 · 6 comments
Closed

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

alexjeffburke opened this issue May 2, 2021 · 6 comments
Labels

Comments

@alexjeffburke
Copy link

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

@lovell
Copy link
Owner

lovell commented May 2, 2021

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.

@lovell lovell added question and removed triage labels May 2, 2021
@alexjeffburke
Copy link
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).

@lovell
Copy link
Owner

lovell commented May 2, 2021

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.

alexjeffburke added a commit to papandreou/impro that referenced this issue May 5, 2021
@lovell
Copy link
Owner

lovell commented May 8, 2021

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

@Zutatensuppe
Copy link

Zutatensuppe commented Dec 21, 2023

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

@lovell
Copy link
Owner

lovell commented Dec 21, 2023

@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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants