mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Add ability to set video thumbnail/preview
This commit is contained in:
parent
e883399fa6
commit
ac81d1a06d
22 changed files with 454 additions and 143 deletions
21
server/helpers/image-utils.ts
Normal file
21
server/helpers/image-utils.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import 'multer'
|
||||
import * as sharp from 'sharp'
|
||||
import { unlinkPromise } from './core-utils'
|
||||
|
||||
async function processImage (
|
||||
physicalFile: Express.Multer.File,
|
||||
destination: string,
|
||||
newSize: { width: number, height: number }
|
||||
) {
|
||||
await sharp(physicalFile.path)
|
||||
.resize(newSize.width, newSize.height)
|
||||
.toFile(destination)
|
||||
|
||||
await unlinkPromise(physicalFile.path)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
processImage
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue