]>
Commit | Line | Data |
---|---|---|
ac81d1a0 C |
1 | import 'multer' |
2 | import * as sharp from 'sharp' | |
3 | import { unlinkPromise } from './core-utils' | |
4 | ||
5 | async function processImage ( | |
02988fdc | 6 | physicalFile: { path: string }, |
ac81d1a0 C |
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 | ||
19 | export { | |
20 | processImage | |
21 | } |