aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/image-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-13 18:17:05 +0100
committerChocobozzz <me@florianbigard.com>2018-02-14 16:03:09 +0100
commitac81d1a06d57b9ae86663831e7f5edcef57b0fa4 (patch)
treeda31775c9533d3e270f68f921e146f086bf7c0b8 /server/helpers/image-utils.ts
parente883399fa6caa56bb8519c9a2e22d88001f26661 (diff)
downloadPeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.tar.gz
PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.tar.zst
PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.zip
Add ability to set video thumbnail/preview
Diffstat (limited to 'server/helpers/image-utils.ts')
-rw-r--r--server/helpers/image-utils.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts
new file mode 100644
index 000000000..ba57b5812
--- /dev/null
+++ b/server/helpers/image-utils.ts
@@ -0,0 +1,21 @@
1import 'multer'
2import * as sharp from 'sharp'
3import { unlinkPromise } from './core-utils'
4
5async function processImage (
6 physicalFile: Express.Multer.File,
7 destination: string,
8 newSize: { width: number, height: number }
9) {
10 await sharp(physicalFile.path)
11 .resize(newSize.width, newSize.height)
12 .toFile(destination)
13
14 await unlinkPromise(physicalFile.path)
15}
16
17// ---------------------------------------------------------------------------
18
19export {
20 processImage
21}