diff --git a/src/attachments.js b/src/attachments.js
index 3b44bd9..ad8ce5e 100644
--- a/src/attachments.js
+++ b/src/attachments.js
@@ -6,7 +6,7 @@ export async function toAttach(file, opts) {
if (file instanceof File) {
const name = file.name || 'file', mime = (file.type || 'application/octet-stream').toLowerCase();
if (isVideo(name, mime)) return compressVideo(file, opts);
- if (/^image\//.test(mime) || /\.(png|jpe?g|webp|gif)$/i.test(name)) {
+ if (/^image\//.test(mime) || /\.(png|jpe?g|webp|gif|avif|jxl)$/i.test(name)) {
const data = await imgToWebp(file, 2048, 94, mime === 'image/webp' || /\.webp$/i.test(name));
return { type: 'image_url', image_url: { url: data } };
}
diff --git a/src/parts/footer.html b/src/parts/footer.html
index c05967e..fecdec4 100644
--- a/src/parts/footer.html
+++ b/src/parts/footer.html
@@ -6,7 +6,7 @@
-
+
diff --git a/src/utils.js b/src/utils.js
index 6747b8f..028fbe0 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -28,7 +28,8 @@ export const imgToWebp = (f, D = 96, q = 75, k) => new Promise((r, j) => {
r(c.toDataURL('image/webp', clamp(q, 0, 100) / 100));
URL.revokeObjectURL(i.src);
};
- i.onerror = j; i.src = URL.createObjectURL(f);
+ i.onerror = () => (URL.revokeObjectURL(i.src), j(new Error("this browser can't read this image format")));
+ i.src = URL.createObjectURL(f);
});
export const b64 = x => x.split(',')[1] || '';
export const utob = s => btoa(unescape(encodeURIComponent(s)));