mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 09:49:20 +02:00
Add ability to customize instance logo
This commit is contained in:
parent
f5fd593976
commit
c0f4de6077
96 changed files with 1910 additions and 532 deletions
|
@ -52,6 +52,21 @@ export async function getImageSize (path: string) {
|
|||
}
|
||||
}
|
||||
|
||||
// Build new size if height or width is missing, to keep the aspect ratio
|
||||
export async function buildImageSize (imagePath: string, sizeArg: { width?: number, height?: number }) {
|
||||
if (sizeArg.width && sizeArg.height) {
|
||||
return sizeArg as { width: number, height: number }
|
||||
}
|
||||
|
||||
const size = await getImageSize(imagePath)
|
||||
const ratio = size.width / size.height
|
||||
|
||||
return {
|
||||
width: sizeArg.width ?? Math.round(sizeArg.height * ratio),
|
||||
height: sizeArg.height ?? Math.round(sizeArg.width / ratio)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Private
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue