diff options
| author | Pitu <[email protected]> | 2020-12-25 02:54:22 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2020-12-25 02:54:22 +0900 |
| commit | 047a6afce6abd9dac1879d9b531d671762ba14d7 (patch) | |
| tree | f4288ee4f4b0a3bf4405013e9f5a6606b782f9e8 /src/api/utils | |
| parent | Feat: add rotating logs when running in production env (diff) | |
| download | host.fuwn.me-047a6afce6abd9dac1879d9b531d671762ba14d7.tar.xz host.fuwn.me-047a6afce6abd9dac1879d9b531d671762ba14d7.zip | |
Fix: use webp for thumbnails
Diffstat (limited to 'src/api/utils')
| -rw-r--r-- | src/api/utils/ThumbUtil.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/api/utils/ThumbUtil.js b/src/api/utils/ThumbUtil.js index 8882b8c..925c09a 100644 --- a/src/api/utils/ThumbUtil.js +++ b/src/api/utils/ThumbUtil.js @@ -16,7 +16,7 @@ class ThumbUtil { static generateThumbnails(filename) { const ext = path.extname(filename).toLowerCase(); - const output = `${filename.slice(0, -ext.length)}.png`; + const output = `${filename.slice(0, -ext.length)}.webp`; const previewOutput = `${filename.slice(0, -ext.length)}.webm`; // eslint-disable-next-line max-len @@ -32,11 +32,11 @@ class ThumbUtil { const file = await jetpack.readAsync(filePath, 'buffer'); await sharp(file) .resize(64, 64) - .toFormat('png') + .toFormat('webp') .toFile(path.join(ThumbUtil.squareThumbPath, output)); await sharp(file) .resize(225, null) - .toFormat('png') + .toFormat('webp') .toFile(path.join(ThumbUtil.thumbPath, output)); } @@ -46,7 +46,7 @@ class ThumbUtil { ffmpeg(filePath) .thumbnail({ timestamps: [0], - filename: '%b.png', + filename: '%b.webp', folder: ThumbUtil.squareThumbPath, size: '64x64' }) @@ -55,7 +55,7 @@ class ThumbUtil { ffmpeg(filePath) .thumbnail({ timestamps: [0], - filename: '%b.png', + filename: '%b.webp', folder: ThumbUtil.thumbPath, size: '150x?' }) |