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
29.24k stars 1.3k forks source link

Need a guide how to convert from heic in docker/macos #3785

Closed loremru closed 1 year ago

loremru commented 1 year ago

Question about an existing feature

What are you trying to achieve?

Convert from .heic to .webp

When you searched for similar issues, what did you find that might be related?

I already install libheif on macos, but I have an error. And I haven't any idea how to do it with docker

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

sharp(buffer).webp()

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

a random .heic image

lovell commented 1 year ago

I already install libheif on macos, but I have an error.

If you're using macOS and Homebrew, you can try brew install vips, which will install libvips, libheif and x265. You can then (re)install sharp and the globally-installed libvips should then be detected and used.

loremru commented 1 year ago

I already install libheif on macos, but I have an error.

If you're using macOS and Homebrew, you can try brew install vips, which will install libvips, libheif and x265. You can then (re)install sharp and the globally-installed libvips should then be detected and used.

That actually doesn't work

msageryd commented 1 year ago

Did you get this to work? I have just installed another library for HEIC conversion, because I didn't find anything about HEIC support in sharp.

Incidentally I found out that libvips has support for HEIC. Does this mean that Sharp also has HEIC support, but undocumented?

loremru commented 1 year ago

@msageryd I installed another library too. But I think problem was in yarn cache. Try to clean package cache. Sharp has heic support, but libvis connection has no docs

lovell commented 1 year ago

https://sharp.pixelplumbing.com/api-output#heif

Support for patent-encumbered HEIC images using hevc compression requires the use of a globally-installed libvips compiled with support for libheif, libde265 and x265.

msageryd commented 1 year ago

Thanks. I simply missed that because the menu said "heif".

I'll try to install libvips in my Alpine Docker container.


edit: Oh, that was a mouthful. Not an of-the-shelf solution for handling heic files. I need to set aside some time for this some day, but it seems way too complicated (to me) to solve now.

I noticed that PDFium and Poppler also are optional dependencies. Does this mean that I could use Sharp for rendering PDF pages to PNG? I'm currently using pdf2cairo from poppler-utils for this.

lovell commented 1 year ago

@msageryd If a globally-installed libvips is compiled to use pdfium or poppler, and sharp is compiled to use that libvips, then yes, you can render PDF documents as PNG. Watch out for licensing concerns around these e.g. poppler is AGPL.