Next.js Discord

Discord Forum

How on earth do you convert a .heif/.heic to a .png?

Unanswered
Atlantic mackerel posted this in #help-forum
Open in Discord
Atlantic mackerelOP
Hi all!

I am using react-dropzone to load image files in my NextJS app. I am then sending the files as base64 strings to /api/documents/extract. Unfortunately, I need .heic and .heif files to be converted to .png or .jpeg. I've tried using "sharp" but running into the error:
error - [Error: source: bad seek to 3279602
[1] heif: Unsupported feature: Unsupported codec (4.3000)]


Apparently this is due to libvips not being included in sharp binaries. I have also tried heic-convert and heic2any but also ran into issues.

Could someone show me how I can convert a .heif/.heic to a .png? Thanks!

10 Replies

There are npm packages for this
Just google those heic to png
What’s the issue with the first two you tried?
You may have to copy/paste and hack what you want into their source code if something is broken
Not a really popular problem sadly
I do have a workaround for you though
Render your image in an invisible canvas in the browser
Then save that canvas as png or jpeg
And send that file to your api