Skip to content

Commit

Permalink
fix: raise error if image file is corrupted / cannot be loaded #194
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaldcwl committed May 29, 2023
1 parent f6250a5 commit 9e298c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 2.0.3 (TBC 2023)
* fixed: skip copy Exif metadata when fails [#187](https://github.com/Donaldcwl/browser-image-compression/issues/187)
* fixed: raise error if image file is corrupted / cannot be loaded [#194](https://github.com/Donaldcwl/browser-image-compression/issues/194)

## 2.0.2 (6 Mar 2023)
* fixed: node version restriction [#185](https://github.com/Donaldcwl/browser-image-compression/issues/185)
Expand Down
3 changes: 3 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ export async function drawFileInCanvas(file, options = {}) {
if (process.env.BUILD === 'development') {
console.error(e);
}
if (e instanceof DOMException) { // DOMException: The source image could not be decoded.
throw e;
}
try {
const dataUrl = await getDataUrlFromFile(file);
img = await loadImage(dataUrl);
Expand Down

0 comments on commit 9e298c9

Please sign in to comment.