-
Notifications
You must be signed in to change notification settings - Fork 90
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
ERR_LIBHEIF format not supported #50
Comments
same issue |
Getting the same issue here |
same issue |
also seeing this |
Is there any solution found to this problem? |
same issue |
same here |
I struggled with this issue. Turns out I was feeding My issue is that I had source image data in a base64 data thing like Things to keep an eye on:
If you're in the same spot, actual working code looks like: import heic2any from "heic2any";
export async function convertHEICToPNG(base64Data: string) {
const uint8Array = convertBase64ToUInt8Array(base64Data);
const blob = new Blob([uint8Array], { type: "image/heic" });
let pngBlob = await heic2any({
blob: blob,
toType: "image/png",
});
// get single png blob if heic2any returns an array
if (Array.isArray(pngBlob)) {
pngBlob = pngBlob[0];
}
// return base 64 data
return extractBase64FromBlob(pngBlob);
}
export function convertBase64ToUInt8Array(base64: string): Uint8Array {
// this is basically a node buffer
// can get an array buffer with bytes.buffer
// remove data:image/jpeg;base64, from base64 string if present
if (base64.startsWith("data:")) {
base64 = base64.split(",")[1];
}
const binary_string = window.atob(base64);
const len = binary_string.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes;
}
export async function extractBase64FromBlob(blob: Blob): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(String(reader.result));
reader.onerror = reject;
reader.readAsDataURL(blob);
});
} If you want to see "proof that it works", you can visit where I am using this code: https://byroni.us/client-image-ops/ Relevant code pulled from: https://github.com/byronwall/client-image-ops/blob/bb5f2ba1694333c0ff7f532cd8bb6ee9885d00a4/src/utils/heic.ts#L5 |
Didn't work for me. Is there any other solution to convert every heic images to jpeg? |
I fell into this issue earlier. Please feel free to check my comment above. I found a solution that I want to share...
I needed to convert it to a BTW, I used |
anyone has a workaround for this? |
we use heic2any to change heic to jpeg in Android 13, but get an error: ERR_LIBHEIF format not supported.
in our test, heic image is validate.
we have no idea about which type of heic image will get this error.
is there any unsupported heic image with heic2any?
The text was updated successfully, but these errors were encountered: