diff options
| author | Pascal Temel <[email protected]> | 2018-11-30 22:58:42 +0100 |
|---|---|---|
| committer | Pascal Temel <[email protected]> | 2018-11-30 22:58:42 +0100 |
| commit | 05c17f2dc9fcc4fc912f83558ae821ca2277ba9f (patch) | |
| tree | da26c2c625d513be78888201d7fae87ad4995747 /controllers | |
| parent | Merge pull request #165 from calvinc64/patch-1 (diff) | |
| download | host.fuwn.me-05c17f2dc9fcc4fc912f83558ae821ca2277ba9f.tar.xz host.fuwn.me-05c17f2dc9fcc4fc912f83558ae821ca2277ba9f.zip | |
replace graphicsmagick with sharp
Diffstat (limited to 'controllers')
| -rw-r--r-- | controllers/utilsController.js | 26 |
1 files changed, 17 insertions, 9 deletions
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); + } }); } } |