Improved thumbnail generation parameters

pull/22/head
tycrek 3 years ago
parent 8694259be7
commit 0e67b5c5c2
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -6,8 +6,11 @@ const { path } = require('./utils');
const { diskFilePath } = require('./config.json');
// Thumbnail parameters
const THUMBNAIL_QUALITY = 50;
const THUMBNAIL_SIZE = 512;
const THUMBNAIL = {
QUALITY: 75,
WIDTH: 200 * 2,
HEIGHT: 140 * 2,
}
/**
* Builds a safe escaped ffmpeg command
@ -22,7 +25,7 @@ function getCommand(src, dest) {
'-i', src, // Input file
'-ss', '00:00:01.000', // Timestamp of frame to grab
'-frames:v', '1', // Number of frames to grab
'-s', `${THUMBNAIL_SIZE}x${THUMBNAIL_SIZE}`, // Dimensions of output file
'-s', `${THUMBNAIL.WIDTH}x${THUMBNAIL.HEIGHT}`, // Dimensions of output file
dest // Output file
]);
}
@ -64,8 +67,8 @@ function getImageThumbnail(file) {
return new Promise((resolve, reject) =>
Jimp.read(file.path)
.then((image) => image
.quality(THUMBNAIL_QUALITY)
.resize(THUMBNAIL_SIZE, THUMBNAIL_SIZE, Jimp.RESIZE_BICUBIC)
.quality(THUMBNAIL.QUALITY)
.resize(THUMBNAIL.WIDTH, THUMBNAIL.HEIGHT, Jimp.RESIZE_BICUBIC)
.write(getNewNamePath(file.originalname)))
.then(resolve)
.catch(reject));

Loading…
Cancel
Save