lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
28.93k stars 1.29k forks source link

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

Open taylorhakes opened 2 weeks ago

taylorhakes commented 2 weeks ago

Possible bug

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

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

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.

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.

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 https://github.com/strukturag/libheif/issues/1250

lukaspanni commented 5 days ago

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 commented 5 days ago

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 commented 5 days ago

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.