Skip to content

heif: Unsupported feature: Unsupported codec (4.3000) #4050

@robbyemmert

Description

@robbyemmert

Possible bug

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

This is a bug with sharp at runtime. Installation happened fine. I am able to resize any type of image except for heic.

  • [x ] 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?

  • [ x] 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: Linux 5.19 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (2) x64 DO-Regular
Memory: 2.22 GB / 3.82 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 20.12.0 - /usr/local/bin/node
Yarn: 4.1.1 - /usr/local/bin/yarn
npm: 10.5.0 - /usr/local/bin/npm
npmPackages:
sharp: ^0.33.3 => 0.33.3

What are the steps to reproduce?

async writeVariation(url: string, variation: ImageVariation) {
        const meta = await sharp(url).metadata()
        const maxDimension = meta.height > meta.width ? 'height' : 'width'
        const secondDimension = maxDimension === 'height' ? 'width' : 'height'

        const urlParts = parse(url)
        const process = sharp(url).resize({
            position: 'center',
            fit: 'inside',
            width: variation.maxWidth,
            height: variation.maxHeight,
        })

        await process.toFile(resolve(urlParts.dir, `${variation.name}_${urlParts.base}`))

        return await process.metadata()
    }

The toFile function fails when processing heic files.

I tried using the bundled binary, enabling every os and cpu architecture involved (and more) in my yarn config (yarn 4)

I tried using a custom installed version
I can run heif-convert --list-decoders and verify that heic/heif codecs are in fact installed.
I can use the exact example image I provided below to heif-convert to a jpg.
But whenever I try to parse a heic file I get the error heif: Unsupported feature: Unsupported codec (4.3000)

I have tried configuring Alpine linux and Debian and Mac OS.

It appears to work on my mac, but I get the codec error as soon as I deploy to any linux variation.

I have also tried running this in Node 16, Node 18, and Node 20, with yarn 1 and 4. I get the EXACT same issue in every case.

This looks like a runtime bug with sharp.

What is the expected behaviour?

I want to support iPhone images—THE most common photo use case for my application.

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

see above

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

https://heic.digital/download-sample/sewing-threads.heic
or any heic file.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions