Skip to content

Commit

Permalink
Fix issue where some AVIF files cannot be opened
Browse files Browse the repository at this point in the history
  • Loading branch information
hbl917070 committed Nov 6, 2024
1 parent 1c37993 commit 6a51f75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Www/ts/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export class Config {
{ ext: "ico", type: "web" },

// 優先使用 vips 處理圖片,失敗則直接在瀏覽器用 canvase 處理成 base64
{ ext: "avif", type: "vips", vipsType: "avif", vipsType2: "base64" },
{ ext: "avif", type: "vips", vipsType: "magick", vipsType2: "base64" },
{ ext: "avifs", type: "web" },

{ ext: "tif", type: "vips", vipsType: "tif" },
Expand Down
8 changes: 4 additions & 4 deletions Www/ts/MainWindow/Script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ export class ScriptImg {
// 如果處理失敗,且 vipsType2 = base64,則先用 canvas 處理成 base64 再上傳到暫存資料夾
if (imgInitInfo.code != "1" && configItem.vipsType2 === "base64") {
// console.log("處理失敗,改用 canvas 來處理");
let url = Lib.pathToUrl(path);
const url = await WebAPI.getFile(fileInfo2); // 取得圖片網址
await this.preloadImg(url);
let can = this.urlToCanvas(url);
let blob = await this.getCanvasBlob(can, 1, "medium", "png", 0.9);
const can = this.urlToCanvas(url);
const blob = await this.getCanvasBlob(can, 1, "medium", "png", 0.9);

if (blob === null) {
isFail = true;
} else {
let base64 = await this.blobToBase64(blob);
const base64 = await this.blobToBase64(blob);
if (base64 !== null) {
await WV_Image.Base64ToTempImg(path, base64 as string);
imgInitInfo = await WebAPI.Img.vipsInit("base64", fileInfo2);
Expand Down

0 comments on commit 6a51f75

Please sign in to comment.