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

NEW HEIC/HEIF files are not supported #63

Open
vahe-martirosyan-qp opened this issue Oct 28, 2024 · 7 comments
Open

NEW HEIC/HEIF files are not supported #63

vahe-martirosyan-qp opened this issue Oct 28, 2024 · 7 comments

Comments

@vahe-martirosyan-qp
Copy link

when I'm trying to convert HEIC files that was taken by the new Iphone models I'm getting this error
Screenshot 2024-10-28 at 13 10 59

@vinwiz
Copy link

vinwiz commented Nov 6, 2024

I'm facing the same issue
Screenshot 2024-11-06 at 2 51 31 PM

@wikiwikiki
Copy link

same issue
image

@wikiwikiki
Copy link

same issue image

file format like
image

@DavidRojasCR
Copy link

Same issue here.

"heic2any": "^0.0.4"

@DavidRojasCR
Copy link

I just switched my code from heic2any to heic-to, and now everything's working! It's the quickest and simplest fix I could find.

@CanadianN1nj4
Copy link

CanadianN1nj4 commented Dec 4, 2024

I believe I have found the solution to the issue, the only thing is I don't have the necessary skills to create the fix. The issue is with the libheif library, there is however a newer version of the libheif library that fixes this issue, my only issue is that I am not sure how to get the correct libheif.js as when install the node module it doesn't seem to have the same format as the current file in src/libheif.js

@alexcorvi sorry to bug you, but if you know how to do this, it might be a quick fix for this issue

@colleeno
Copy link

colleeno commented Dec 5, 2024

Experiencing this issue as well, libheif has fixed it but definitely looks like it needs to be rebuilt here @alexcorvi if you are able to update. As a workaround for now I had to directly bring in libheif to handle the heic2any fails

          try {
            // Convert file to Uint8Array
            const arrayBuffer = await file.arrayBuffer();
            const uint8Array = new Uint8Array(arrayBuffer);
             // Initialize the HeifDecoder
            const decoder = new libheif.HeifDecoder();
            const data = decoder.decode(uint8Array);
            // Extract the first image from the HEIF container
            const image = data[0];
            const width = image.get_width();
            const height = image.get_height();
            // Create a canvas element
            const canvas = document.createElement('canvas');
            canvas.width = width;
            canvas.height = height;
            const context = canvas.getContext('2d');
            const imageData = context.createImageData(width, height);
            // Display the image on the canvas
            await new Promise((resolve, reject) => {
              image.display(imageData, (displayData) => {
                if (!displayData) {
                  return reject(new Error('HEIF processing error'));
                }
                resolve();
              });
            });
            context.putImageData(imageData, 0, 0);
            // Convert canvas to Blob
            blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/jpeg', 1));
          } 

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

6 participants