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

HEIC conversion #2004

Closed
orkc opened this issue Dec 9, 2019 · 6 comments
Closed

HEIC conversion #2004

orkc opened this issue Dec 9, 2019 · 6 comments
Labels

Comments

@orkc
Copy link

orkc commented Dec 9, 2019

What are you trying to achieve?

Convert range of image types including HEIC to JPEG. After reading the historical trail I can find I am confused as to if Sharp can be used for converting HEIC to JPEG and if so then how to achieve that. I think that the current situation is that the answer is yes for input and experimental for output but not with the standard install. However, I do not understand the steps required to complete an installation that will support HEIC conversion. Can anyone confirm my understanding and if accurate provide the correct steps?

@lovell
Copy link
Owner

lovell commented Dec 10, 2019

At npm install time, sharp will always look for and, if found, compile itself again a globally-installed copy of libvips.

This means you'll need to compile and install libvips with support for libheif before installing sharp.

Please see #1105 (comment)

@ghost
Copy link

ghost commented Dec 13, 2019

At npm install time, sharp will always look for and, if found, compile itself again a globally-installed copy of libvips.

This means you'll need to compile and install libvips with support for libheif before installing sharp.

Please see #1105 (comment)

I install vips (brew install vips)
(brew info vips) command --------
vips: stable 8.8.4 (bottled)
Image processing library
https://github.com/libvips/libvips
/usr/local/Cellar/vips/8.8.4 (166 files, 11.5MB) *
Poured from bottle on 2019-12-13 at 14:10:10
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/vips.rb
==> Dependencies
Build: pkg-config ✔
Required: cfitsio ✔, fftw ✔, fontconfig ✔, gettext ✔, giflib ✔, glib ✔, imagemagick ✔, libexif ✔, libgsf ✔, libheif ✔, libmatio ✔, libpng ✔, librsvg ✔, libtiff ✔, little-cms2 ✔, mozjpeg ✔, openexr ✔, openslide ✔, orc ✔, pango ✔, poppler ✔, webp ✔
==> Analytics
install: 2,531 (30 days), 6,027 (90 days), 19,448 (365 days)
install-on-request: 2,403 (30 days), 5,774 (90 days), 18,362 (365 days)
build-error: 0 (30 days)

I install sharp in my local lambda function folder.
(npm install --no-cache --arch=x64 --platform=linux --target=10.15.0 sharp)
However it is not work (Error: Input buffer contains unsupported image format) , When Lambda was excuted.

How to compile globally-installed copy of libvips??

@lovell
Copy link
Owner

lovell commented Dec 13, 2019

@vdongbin I notice you opened #2006 so let's continue your question there.

@orkc
Copy link
Author

orkc commented Dec 14, 2019

just in case it is helpful to others... With the pointer given by Lovell (thanks) I got things working by installing in the following order:

libheif
libvips
sharp

@orkc orkc closed this as completed Dec 14, 2019
josephfrazier added a commit to josephfrazier/reported-web that referenced this issue Feb 11, 2021
…nalpr (#264)

This adds about 6 seconds of latency since `heic-convert` is written in
JS, but it's better than nothing. Maybe I can get `sharp` working at
some point.

Fixes #263:

> Here's a test image [share.icloud.com/photos/0-5_Dy6WhkGw_7G-mlzadci-w#New_York](https://share.icloud.com/photos/0-5_Dy6WhkGw_7G-mlzadci-w#New_York)
> 
> I suspect openalpr doesn't support HEIC, and we might need to convert to JPG on the server before sending to openalpr, see [lovell/sharp#2004](lovell/sharp#2004)
> 
> If we can't get sharp working, try [npmjs.com/package/heic-convert](https://www.npmjs.com/package/heic-convert)
@josephfrazier
Copy link

Thanks for posting this @orkc, I just got it working!

brew install libheif
brew install libvips
yarn remove sharp && yarn add sharp

josephfrazier added a commit to josephfrazier/reported-web that referenced this issue Feb 11, 2021
This drops the latency from 6 seconds down to 1. However, it requires
libheif and libvips to be installed, so I need to figure out how to do
that on Heroku before this can be merged. On MacOS, this made it work
(see lovell/sharp#2004 (comment)):

```
brew install libheif
brew install libvips
yarn remove sharp && yarn add sharp
```

Fixes #265:

> See #264:
>
> > This adds about 6 seconds of latency since `heic-convert` is written in
> > JS, but it's better than nothing. Maybe I can get `sharp` working at
> > some point.
> > Fixes #263:
> > > Here's a test image [share.icloud.com/photos/0-5_Dy6WhkGw_7G-mlzadci-w#New_York](https://share.icloud.com/photos/0-5_Dy6WhkGw_7G-mlzadci-w#New_York)
> > > I suspect openalpr doesn't support HEIC, and we might need to convert to JPG on the server before sending to openalpr, see [lovell/sharp#2004](lovell/sharp#2004)
> > > If we can't get sharp working, try [npmjs.com/package/heic-convert](https://www.npmjs.com/package/heic-convert)
@studentIvan
Copy link

Thanks for posting this @orkc, I just got it working!

brew install libheif
brew install libvips
yarn remove sharp && yarn add sharp

thanks, it works on my mac, but still doesn't work on the ubuntu server :(
looking for the solution

I've installed the libvips42, libvips-dev, libvips-tools, libheif and rebuilt sharp

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

4 participants