diff --git a/config.sample.js b/config.sample.js index 90cc4c8..37403ab 100644 --- a/config.sample.js +++ b/config.sample.js @@ -79,8 +79,7 @@ module.exports = { /* NOTE: Thumbnails are only for the admin panel and they require you - to install a separate binary called graphicsmagick (http://www.graphicsmagick.org) - for images and ffmpeg (https://ffmpeg.org/) for video files + to install a separate binary called ffmpeg (https://ffmpeg.org/) for video files */ generateThumbnails: false, diff --git a/controllers/utilsController.js b/controllers/utilsController.js index bc182b7..e94c258 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -47,17 +47,25 @@ utilsController.generateThumbs = function(file, basedomain) { }) .on('error', error => console.log('Error - ', error.message)); } else { - let size = { + let resizeOptions = { width: 200, - height: 200 + height: 200, + fit: 'contain', + background: { + r: 0, + g: 0, + b: 0, + alpha: 0 + } }; - gm(path.join(__dirname, '..', config.uploads.folder, file.name)) - .resize(size.width, size.height + '>') - .gravity('Center') - .extent(size.width, size.height) - .background('transparent') - .write(thumbname, error => { - if (error) console.log('Error - ', error); + + sharp(path.join(__dirname, '..', config.uploads.folder, file.name)) + .resize(resizeOptions) + .toFile(thumbname) + .catch((error) => { + if (error) { + console.log('Error - ', error); + } }); } } diff --git a/package.json b/package.json index bbbb197..c85ed69 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,13 @@ "express-handlebars": "^3.0.0", "express-rate-limit": "^2.11.0", "fluent-ffmpeg": "^2.1.2", - "gm": "^1.23.1", "helmet": "^3.11.0", "jszip": "^3.1.5", "knex": "^0.14.4", "multer": "^1.3.0", + "npm": "^6.4.1", "randomstring": "^1.1.5", + "sharp": "^0.21.0", "sqlite3": "^3.1.13" }, "devDependencies": {