aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/image-utils.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts
index bd81aa3ba..b1c7d3d47 100644
--- a/server/helpers/image-utils.ts
+++ b/server/helpers/image-utils.ts
@@ -1,7 +1,7 @@
1import 'multer' 1import 'multer'
2import * as sharp from 'sharp'
3import { readFile, remove } from 'fs-extra' 2import { readFile, remove } from 'fs-extra'
4import { logger } from './logger' 3import { logger } from './logger'
4const Jimp = require('jimp')
5 5
6async function processImage ( 6async function processImage (
7 path: string, 7 path: string,
@@ -10,20 +10,21 @@ async function processImage (
10 keepOriginal = false 10 keepOriginal = false
11) { 11) {
12 if (path === destination) { 12 if (path === destination) {
13 throw new Error('Sharp needs an input path different that the output path.') 13 throw new Error('Jimp needs an input path different that the output path.')
14 } 14 }
15 15
16 logger.debug('Processing image %s to %s.', path, destination) 16 logger.debug('Processing image %s to %s.', path, destination)
17 17
18 // Avoid sharp cache 18 // Avoid sharp cache
19 const buf = await readFile(path) 19 const buf = await readFile(path)
20 const sharpInstance = sharp(buf) 20 const jimpInstance = await Jimp.read(buf)
21 21
22 await remove(destination) 22 await remove(destination)
23 23
24 await sharpInstance 24 await jimpInstance
25 .resize(newSize.width, newSize.height) 25 .resize(newSize.width, newSize.height)
26 .toFile(destination) 26 .quality(80)
27 .writeAsync(destination)
27 28
28 if (keepOriginal !== true) await remove(path) 29 if (keepOriginal !== true) await remove(path)
29} 30}