/
githubmirror
/
bootstrap
Обзор
Документация
Войти
/
githubmirror
/
bootstrap
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
site/src/libs/image.ts
16 строк
530 B
Julien Déramond
Bump `image-size` from 1.0.2 to 2.0.2 (#41384)
15 апр 2025, 22:18
Не верифицирован
15 апр 2025, 22:18
ed36faa
Код
Авторство
О чём код?
import path from 'node:path' import { promises as fs } from 'node:fs' import sizeOf from 'image-size' import { getDocsStaticFsPath } from './path' export async function getStaticImageSize(imagePath: string) { const fullPath = path.join(getDocsStaticFsPath(), imagePath) const buffer = await fs.readFile(fullPath) const size = await sizeOf(buffer) if (!size?.height || !size?.width) { throw new Error(`Failed to get size of static image at '${imagePath}'.`) } return { height: size.height, width: size.width } }