Skip to content

Commit 9e298c9

Browse files
committed
fix: raise error if image file is corrupted / cannot be loaded #194
1 parent f6250a5 commit 9e298c9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 2.0.3 (TBC 2023)
22
* fixed: skip copy Exif metadata when fails [#187](https://github.com/Donaldcwl/browser-image-compression/issues/187)
3+
* fixed: raise error if image file is corrupted / cannot be loaded [#194](https://github.com/Donaldcwl/browser-image-compression/issues/194)
34

45
## 2.0.2 (6 Mar 2023)
56
* fixed: node version restriction [#185](https://github.com/Donaldcwl/browser-image-compression/issues/185)

lib/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ export async function drawFileInCanvas(file, options = {}) {
229229
if (process.env.BUILD === 'development') {
230230
console.error(e);
231231
}
232+
if (e instanceof DOMException) { // DOMException: The source image could not be decoded.
233+
throw e;
234+
}
232235
try {
233236
const dataUrl = await getDataUrlFromFile(file);
234237
img = await loadImage(dataUrl);

0 commit comments

Comments
 (0)