Refactor image.ts to use checkImageType instead of isAPNG

This commit is contained in:
kwaroran
2024-01-10 07:08:13 +09:00
parent fd0de264e9
commit 264211fdfd

View File

@@ -3,7 +3,7 @@ import { selectSingleFile } from "./util";
import { v4 } from "uuid"; import { v4 } from "uuid";
import { DataBase } from "./storage/database"; import { DataBase } from "./storage/database";
import { get } from "svelte/store"; import { get } from "svelte/store";
import { isAPNG } from "./parser"; import { checkImageType, isAPNG } from "./parser";
import { PngChunk } from "./pngChunk"; import { PngChunk } from "./pngChunk";
const inlayStorage = localforage.createInstance({ const inlayStorage = localforage.createInstance({
@@ -100,8 +100,8 @@ export function supportsInlayImage(){
} }
export async function reencodeImage(img:Uint8Array){ export async function reencodeImage(img:Uint8Array){
if(isAPNG(img)){ if(checkImageType(img) === 'PNG'){
return PngChunk.write(img, {}) as Promise<Buffer> return img
} }
const canvas = document.createElement('canvas') const canvas = document.createElement('canvas')
const imgObj = new Image() const imgObj = new Image()