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 support missing #9

Open
Arvoreen opened this issue Jun 6, 2024 · 10 comments
Open

HEIF support missing #9

Arvoreen opened this issue Jun 6, 2024 · 10 comments

Comments

@Arvoreen
Copy link

Arvoreen commented Jun 6, 2024

So I set up initially on Debian Bookworm. This version has an older 'libvips' installation, and when sharps gets installed, it uses its prebuilt binaries, which do not include support for HEIF. I managed to solve this myself by upgrading to trixie, then modifying the install.sh script to add '--build-from-source' to the npm install command line for sharp.

I suppose other option would be to manually update or install libvips on Bookworm, then use the same change to the install command above.

This is not really a 'bug report' per-se, but more of a note for anyone else that runs into this problem.

The symptom of this is errors like this in the microservices log file (and missing thumbnails for any photos from an iPhone)

[Nest] 14529  - 06/06/2024, 1:38:52 PM   ERROR [ImmichMicroservices] [JobService] Unable to run job handler (thumbnailGeneration/generate-preview): Error: Input file contains unsupported image format
[Nest] 14529  - 06/06/2024, 1:38:52 PM   ERROR [ImmichMicroservices] [JobService] Error: Input file contains unsupported image format
    at Sharp.toFile (/data/app/node_modules/sharp/lib/output.js:89:19)
    at MediaRepository.generateThumbnail (/data/app/dist/repositories/media.repository.js:69:14)
    at MediaService.generateThumbnail (/data/app/dist/services/media.service.js:158:48)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MediaService.handleGeneratePreview (/data/app/dist/services/media.service.js:135:29)
    at async /data/app/dist/services/job.service.js:145:36
    at async Worker.processJob (/data/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    at async Worker.retryIfFailed (/data/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
[Nest] 14529  - 06/06/2024, 1:38:52 PM   ERROR [ImmichMicroservices] [JobService] Object:
{
  "id": "09c08053-2f1c-4650-ae49-7554bf2deaaa"
}
@arter97
Copy link
Owner

arter97 commented Jun 12, 2024

Thanks for the note.

Is "sharp" the only dependency needed for HEIF? The upstream Docker's base image also builds ImageMagick on its own, I figured it's needed for HEIF or RAW support.

Also, if Trixie's libvips supports HEIF, why is "--build-from-source" needed? Shouldn't it automatically pick up libvips support and use it?

Thanks.

@LazyFunker
Copy link

I have the same problem. But I can't seem to be able to fix it. I've tried both on trixie and ubuntu 22.04, building my own version of libvips with heif support.
Do you have any pointers of how I can fix this?

@4v3ngR
Copy link

4v3ngR commented Jun 16, 2024

It appears that the sharp package request libvips to be installed globally (https://www.libvips.org/).

@relax-a-bit
Copy link

relax-a-bit commented Jul 1, 2024

I have installed the libvips according to
https://github.com/immich-app/base-images/blob/main/server/bin/build-libvips.sh but immich still lacks support for heif. Do I have to rebuild the installation?

@TransRapid
Copy link
Contributor

He says he does not include it for copyright reasons.

@TransRapid
Copy link
Contributor

TransRapid commented Jul 26, 2024

Install libde265 lbx265, then libheif, then webm, then libvips, then in your script

npm install sharp --build-from-source --verbose --foreground-scripts.

@TransRapid
Copy link
Contributor

TransRapid commented Dec 4, 2024

What happens when you are in your Immich users shell and type:

heif-convert

@pes502
Copy link
Contributor

pes502 commented Dec 4, 2024

Sorry, I accidentally deleted my comment. I finally fixed the problem (now I can try to do a new "clean" run and provide detailed guide how to fix this issue for others - I will add it to this comment)

EDIT 04.12.2024 // 11:06

  1. Install Debian Trixie
  2. Install everything from this repo (step by step). With Trixie, you can just install ffmpeg directly (no need Jellyfin version)
    apt install ffmpeg
  3. apt install libvips-dev (should be this: https://packages.debian.org/trixie/amd64/libvips-dev/download)
  4. cd /var/lib/immich/app/
  5. npm uninstall sharp
  6. npm install nan node-addon-api node-gyp
  7. npm install sharp --build-from-source --verbose --foreground-scripts
  8. chown -R immich:immich *
  9. Reboot or restart services

!!! When you install a new version of Immich in the future, you will probably need to repeat steps 4-10.

@arter97

Thanks for the note.

Is "sharp" the only dependency needed for HEIF? The upstream Docker's base image also builds ImageMagick on its own, I figured it's needed for HEIF or RAW support.

Also, if Trixie's libvips supports HEIF, why is "--build-from-source" needed? Shouldn't it automatically pick up libvips support and use it?

Thanks.

I tried it but it's not working (for me atleast)

@TransRapid
Copy link
Contributor

I have done this as well, I compiled libvips myself, but as far as sharp that is the same process. I actually added it to a script that i have as a branch of this. - Not (Yet) Publicly Shared.

@loeeeee
Copy link
Contributor

loeeeee commented Dec 6, 2024

Also, if Trixie's libvips supports HEIF, why is "--build-from-source" needed? Shouldn't it automatically pick up libvips support and use it?

After some digging in sharp, I found that after one compiled the libvips and installed sharp, one needs to delete something inside node_modules to make sharp use the system library.

Here is my solution copied from Immich in LXC

# Remove sharp dependency so that it use system library
rm -rf $INSTALL_DIR_app/node_modules/@img/sharp-libvips*
rm -rf $INSTALL_DIR_app/node_modules/@img/sharp-linuxmusl-x64

The $INSTALL_DIR_app is where the immich app locates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants