
| Current Path : /var/www/html/12park/vendor/twbs/bootstrap/site/src/libs/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/12park/vendor/twbs/bootstrap/site/src/libs/image.ts |
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 }
}