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

sharp 0.27.0 - heif: Unsupported feature: Unsupported codec #2518

Closed
repl-sean-heintz opened this issue Jan 5, 2021 · 5 comments
Closed
Labels

Comments

@repl-sean-heintz
Copy link

repl-sean-heintz commented Jan 5, 2021

I'm attempting to upgrade our version of sharp from 0.25.3 to 0.27.0. We used to compile our own version of libvips to build in support for HEIC/HEIF images, but per #1105 (comment) we have removed this step.

That being said, I'm now getting issues when I attempt to do any processing on an HEIC image. This used to work when we had 0.25.3.

Node Version: 14.14.0 as well as 14.15.3
Sharp Version: 0.27.0
Operating System: Windows 10 64bit as well as Debian Buster

Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?

Using sharp 0.27.0

What are the steps to reproduce?

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

const outputParameters = {
  width: 128,
  height: 128,
};

const doTheThing = async () => {
  const data = fs.readFileSync('./sample1.heic');

  const image = sharp(data).clone();

  image.resize(outputParameters.width, outputParameters.height, {
    fit: sharp.fit.cover,
    position: sharp.strategy.entropy,
  });

  image.jpeg();

  const outputImage = await image.toBuffer();
};

doTheThing();

Run the above code in nodejs, and observe the following:

(node:9092) UnhandledPromiseRejectionWarning: Error: source: bad seek to 2994402
heif: Unsupported feature: Unsupported codec (4.3000)
heif: Unsupported feature: Unsupported codec (4.3000)
heif: Unsupported feature: Unsupported codec (4.3000)
heif: Unsupported feature: Unsupported codec (4.3000)
... repeats 124 more times ...

This is occurring with ALL heic format images that I am able to find.

What is the expected behaviour?

We are able to perform operations on the loaded image data, and write it out as a JPEG.

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?

sample1.zip

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

  System:
    OS: Windows 10 10.0.18363
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 6.64 GB / 23.86 GB
  Binaries:
    Node: 14.14.0 - C:\dev\share\nodejs\node.EXE
    Yarn: 1.22.5 - ~\.yarn\bin\yarn.CMD
    npm: 6.14.8 - C:\dev\share\nodejs\npm.CMD
    Watchman: 4.9.4 - C:\dev\share\watchman\watchman.EXE
    ```

Thanks for looking, and for your work on this project! Cheers.
@lovell
Copy link
Owner

lovell commented Jan 6, 2021

We used to compile our own version of libvips to build in support for HEIC/HEIF images, but per #1105 (comment) we have removed this step.

Support in sharp for HEIC images that use the patent-encumbered HEVC codec has only ever been via a globally-installed libvips so you will need to retain this step.

@lovell lovell added question and removed triage labels Jan 6, 2021
@repl-sean-heintz
Copy link
Author

@lovell

Strange, I had used the custom compiled libvips 8.10.5/sharp 0.27.0 with my project and was receiving basically the same errors. However, I'm not able to reproduce it in my minimal sample. I guess there's something slightly more sinister going on with my build.

Thanks again for the eyes, and for your hard work on this project. It's phenomenal!

@repl-sean-heintz
Copy link
Author

Small note for those who may dig this up later. The issue I was having when I compiled in libvips was this:

Error: source: bad seek to 293616
heifsave: Unsupported compression

This was after calling

const d = fs.readFileSync('./input.heic');
const img = sharp(d);
const b = sharp(await img.toBuffer());

I'm not entirely sure why we were doing sharp(await img.toBuffer()), so I changed it to img.clone().

This resolved the issue.

@david-taggun
Copy link

@lovell hey mate - I know this is a closed issue - but I've run into the exact error being raised when using the latest sharp module ^0.28.2.

We're rolling our own libvips using brew https://formulae.brew.sh/formula/vips vips-8.10.5-Fri Dec 18 10:14:09 UTC 2020 and I can see the heif codec version is set when looking at the debug symbols for sharp(buffer[]); heif: 1.11.0 so everything looks all good - but when we pass in ANY heic buffer we get this error bad seek etc. etc.

I rolled the version back to sharp ^0.26.2 and the image was processed without any issues. Not sure where to go from here?

@lovell
Copy link
Owner

lovell commented May 12, 2021

@david-taggun Please make sure the heif-convert command line tool can process the image.

Repository owner locked and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants