aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/image-utils.ts
diff options
context:
space:
mode:
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}