Closed ekobayu closed 2 years ago
This is a bug with Android Chrome, please refer to: https://bugs.chromium.org/p/chromium/issues/detail?id=1063576 A workable solution is to reconstruct the File object:
<body>
<input type="file" accept="image/*" onchange="compressImage(event);" />
</body>
<script>
async function compressImage(event) {
const originalFile = event.target.files[0];
const buffer = await originalFile.arrayBuffer();
const imageFile= new File([buffer], file.name, { type: file.type });
const compressedFile = await imageCompression(imageFile, options);
// ...
}
</script>
This is a bug with Android Chrome, please refer to: https://bugs.chromium.org/p/chromium/issues/detail?id=1063576 A workable solution is to reconstruct the File object:
<body> <input type="file" accept="image/*" onchange="compressImage(event);" /> </body> <script> async function compressImage(event) { const originalFile = event.target.files[0]; const buffer = await originalFile.arrayBuffer(); const imageFile= new File([buffer], file.name, { type: file.type }); const compressedFile = await imageCompression(imageFile, options); // ... } </script>
Thanks bro, it's works!
Hello, I try select image from google drive in my phone but the browser-image-compression plugin cannot compress the file. I try using png, jpg and jpeg but all it's failed. Any suggestion ? Thanks