Merge pull request #169 from PascalTemel/master

Replace graphicsmagick with sharp
This commit is contained in:
Kana 2018-12-04 14:57:57 -03:00 committed by GitHub
commit ea575898f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 12 deletions

View File

@ -79,8 +79,7 @@ module.exports = {
/* /*
NOTE: Thumbnails are only for the admin panel and they require you NOTE: Thumbnails are only for the admin panel and they require you
to install a separate binary called graphicsmagick (http://www.graphicsmagick.org) to install a separate binary called ffmpeg (https://ffmpeg.org/) for video files
for images and ffmpeg (https://ffmpeg.org/) for video files
*/ */
generateThumbnails: false, generateThumbnails: false,

View File

@ -47,17 +47,25 @@ utilsController.generateThumbs = function(file, basedomain) {
}) })
.on('error', error => console.log('Error - ', error.message)); .on('error', error => console.log('Error - ', error.message));
} else { } else {
let size = { let resizeOptions = {
width: 200, 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 + '>') sharp(path.join(__dirname, '..', config.uploads.folder, file.name))
.gravity('Center') .resize(resizeOptions)
.extent(size.width, size.height) .toFile(thumbname)
.background('transparent') .catch((error) => {
.write(thumbname, error => { if (error) {
if (error) console.log('Error - ', error); console.log('Error - ', error);
}
}); });
} }
} }

View File

@ -21,12 +21,12 @@
"express-handlebars": "^3.0.0", "express-handlebars": "^3.0.0",
"express-rate-limit": "^2.11.0", "express-rate-limit": "^2.11.0",
"fluent-ffmpeg": "^2.1.2", "fluent-ffmpeg": "^2.1.2",
"gm": "^1.23.1",
"helmet": "^3.11.0", "helmet": "^3.11.0",
"jszip": "^3.1.5", "jszip": "^3.1.5",
"knex": "^0.14.4", "knex": "^0.14.4",
"multer": "^1.3.0", "multer": "^1.3.0",
"randomstring": "^1.1.5", "randomstring": "^1.1.5",
"sharp": "^0.21.0",
"sqlite3": "^3.1.13" "sqlite3": "^3.1.13"
}, },
"devDependencies": { "devDependencies": {