more performance improvements to social preview generation

This commit is contained in:
James Fenn
2023-04-04 21:33:45 -04:00
parent f95dc983d1
commit 20e69a93db
7 changed files with 70 additions and 79 deletions

View File

@@ -17,10 +17,10 @@ const extTypeMap = {
};
export function readFileAsBase64(file: string) {
const image = fs.readFileSync(file);
const image = fs.readFileSync(file, { encoding: "base64" });
const contentType =
extTypeMap[path.extname(file) as keyof typeof extTypeMap] || "image/jpeg";
return `data:${contentType};base64,${image.toString("base64")}`;
return `data:${contentType};base64,${image}`;
}
export function ensureDirectoryExistence(filePath: string) {