diff options
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); + } }); } } |