From e6dfa58689e88633db8304a8541a75edd893c645 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sun, 31 May 2020 20:03:28 +0200 Subject: space optimizations for `node_modules` and client stats removal - replace sharp with lighter jimp alternative - remove stats in builds fixes #2807 --- server/helpers/image-utils.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'server/helpers/image-utils.ts') 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 @@ import 'multer' -import * as sharp from 'sharp' import { readFile, remove } from 'fs-extra' import { logger } from './logger' +const Jimp = require('jimp') async function processImage ( path: string, @@ -10,20 +10,21 @@ async function processImage ( keepOriginal = false ) { if (path === destination) { - throw new Error('Sharp needs an input path different that the output path.') + throw new Error('Jimp needs an input path different that the output path.') } logger.debug('Processing image %s to %s.', path, destination) // Avoid sharp cache const buf = await readFile(path) - const sharpInstance = sharp(buf) + const jimpInstance = await Jimp.read(buf) await remove(destination) - await sharpInstance + await jimpInstance .resize(newSize.width, newSize.height) - .toFile(destination) + .quality(80) + .writeAsync(destination) if (keepOriginal !== true) await remove(path) } -- cgit v1.2.3