Skip to content

Commit 7a9e278

Browse files
committed
Safari does not support exporting a canvas to blob as image/webp
See https://www.woltlab.com/community/thread/314222/
1 parent 46293fb commit 7a9e278

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

ts/WoltLabSuite/Core/Image/Resizer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ class ImageResizer {
8484
const basename = /(.+)(\..+?)$/.exec(fileName);
8585

8686
let blob = await pica.toBlob(data.image, fileType, quality);
87+
// Safari does not support image/webp for canvas.toBlob()
88+
if (fileType === "image/webp" && blob.type === "image/png") {
89+
fileType = "image/jpeg";
90+
blob = await pica.toBlob(data.image, fileType, quality);
91+
}
8792

8893
if (fileType === "image/jpeg" && typeof data.exif !== "undefined") {
8994
blob = await ExifUtil.setExifData(blob, data.exif);

wcfsetup/install/files/js/WoltLabSuite/Core/Image/Resizer.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)