diff options
| author | Kana <[email protected]> | 2018-12-04 14:57:57 -0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-12-04 14:57:57 -0300 |
| commit | ea575898f3bcd78581f81129cdda20725890d057 (patch) | |
| tree | 63d3e04167f5d0e829842a8794a2d4bed7c32efd /controllers/utilsController.js | |
| parent | Merge pull request #165 from calvinc64/patch-1 (diff) | |
| parent | remove npm from package.json (diff) | |
| download | host.fuwn.me-ea575898f3bcd78581f81129cdda20725890d057.tar.xz host.fuwn.me-ea575898f3bcd78581f81129cdda20725890d057.zip | |
Merge pull request #169 from PascalTemel/master
Replace graphicsmagick with sharp
Diffstat (limited to 'controllers/utilsController.js')
| -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); + } }); } } |