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

heif: Error while loading plugin: No decoding plugin installed for this compression format #4204

Closed
5 tasks done
taylorhakes opened this issue Sep 2, 2024 · 11 comments
Closed
5 tasks done
Labels

Comments

@taylorhakes
Copy link

taylorhakes commented Sep 2, 2024

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

yes, version 0.33.5

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 7.63 GB / 64.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 20.11.0 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 10.2.4 - /usr/local/bin/npm
  npmPackages:
    sharp: ^0.33.5 => 0.33.5

Does this problem relate to file caching?

The default behaviour of libvips is to cache input files, which can lead to EBUSY or EPERM errors on Windows.
Use sharp.cache(false) to switch this feature off.

  • Adding sharp.cache(false) does not fix this problem.

Does this problem relate to images appearing to have been rotated by 90 degrees?

Images that contain EXIF Orientation metadata are not auto-oriented. By default, EXIF metadata is removed.

  • To auto-orient pixel values use the parameter-less rotate() operation.

  • To retain EXIF Orientation use keepExif().

  • Using rotate() or keepExif() does not fix this problem.

What are the steps to reproduce?

Installed sharp with node and installed libvips on OSX. I tried building from source as well.

I get the following when running the code:

import sharp from 'sharp';
const buffer = await sharp('<FILE_PATH>')
      .toFormat('png')
      .toBuffer();
Error: <FILE_NAME>.HEIC: bad seek to 1586768
heif: Error while loading plugin: No decoding plugin installed for this compression format (11.6003)

What is the expected behaviour?

Convert to PNG

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

Install sharp in OSX and try to convert HEIC files.

Please provide sample image(s) that help explain this problem

N/A

@lovell
Copy link
Owner

lovell commented Sep 3, 2024

installed libvips on OSX

What is the output of running vips copy input.heic output.png at the command line for your sample input image?

@divporter
Copy link

I have the same problem but with jpeg (tried png also to match above issue).

Running vips on the command line works for both png and jpeg for me.

@cryptofyre
Copy link

Experiencing the same as above, just on a Linux container environment.

vips copy works fine, but I get a seeking error like the OP.

@lovell
Copy link
Owner

lovell commented Sep 4, 2024

Please remember that reading HEIC images requires sharp to be built from source against a globally-installed libvips + libheif + libde265 combo - see https://sharp.pixelplumbing.com/install#building-from-source

For those using a custom, globally-installed libheif, my best guess would be that this relates to its plugin system, which can be switched off at compile time using the -DENABLE_PLUGIN_LOADING flag (set it to one of 0, NO or OFF) as others have been directed to do at strukturag/libheif#1250

@lukaspanni
Copy link

I have the same problem, using an ubuntu-based container that should contain all the required libraries.
This is the relevant snippet from my dockerfile:

RUN apt update && apt install -y libvips-dev libheif-dev
ENV SHARP_FORCE_GLOBAL_LIBVIPS=1

Using heif-convert from the heif-examples package works fine.
heif-convert --list-decoders output:

HEIC decoders:
- libde265 = libde265 HEVC decoder, version 1.0.15
AVIF decoders:
- aom = AOMedia Project AV1 Decoder v3.8.2
JPEG decoders:
JPEG 2000 decoders:
uncompressed: yes

I suppose sharp is not correctly building from source and does not use the globally installed libraries. How can I verify/debug this?

@lovell
Copy link
Owner

lovell commented Sep 15, 2024

I suppose sharp is not correctly building from source and does not use the globally installed libraries. How can I verify/debug this?

All decisions are logged at install time. You might need to add the npm install --foreground-scripts flag to display them.

https://sharp.pixelplumbing.com/install#building-from-source

@lukaspanni
Copy link

Thank you for the hint.
This revealed that the ubuntu packaged libvips has a version-mismatch with the latest version of sharp and is thus not building correctly.
Building the correct versions of the libraries should resolve the issue for me.

@lovell
Copy link
Owner

lovell commented Sep 23, 2024

I hope this information helped. Please feel free to re-open with more details if further assistance is required.

@lovell lovell closed this as completed Sep 23, 2024
@lovell lovell mentioned this issue Oct 4, 2024
11 tasks
@mattiLeBlanc
Copy link

mattiLeBlanc commented Oct 25, 2024

@lovell
I am getting this error on a JPEG file, that came from my iphone together with a couple of other photos.
Only this specific one is causing this error:

INFO	Error: source: bad seek to 2298319
heif: Error while loading plugin: No decoding plugin installed for this compression format (11.6003)
    at V.ro [as toBuffer] (/opt/nodejs/node_modules/sharp/lib/index.js:2:56542)
    at Runtime.handler (/var/task/index.js:29:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

IMG_4838 is causing the error.
IMG_4538

IMG_4537 is from the same group and works fine:

IMG_4537

When I run the resize on my mac, it works fine by the way. But on the Lambda using release-x64.zip version 0.35.
Any idea what to do about this?

It seems that IMG_4538.jpeg can also not be displayed in Github....but it works fine on my mac in Finder.

@lovell
Copy link
Owner

lovell commented Oct 27, 2024

@mattiLeBlanc IMG_4838 is an HEVC-encoded HEIC image rather than a JPEG.

$ file 380390049-c42700ad-920f-4862-ad39-0589518e835d.jpeg 
380390049-c42700ad-920f-4862-ad39-0589518e835d.jpeg: ISO Media, HEIF Image HEVC Main or Main Still Picture Profile
$ heif-info 380390049-c42700ad-920f-4862-ad39-0589518e835d.jpeg 
MIME type: image/heic
main brand: heic
compatible brands: mif1, miaf, MiHB, heic

image: 3024x4032 (id=49), primary
  tiles: 6x8, tile size: 512x512
  colorspace: YCbCr, 4:2:0
  bit depth: 8

@mattiLeBlanc
Copy link

@lovell Is there any support for that, to convert HEICs? Or should I create a new build for that?

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

6 participants