diff options
author | Kimsible <1877318+kimsible@users.noreply.github.com> | 2020-11-25 09:26:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 09:26:31 +0100 |
commit | 123f61933611f326ea5a5e8c2ea253ee8720e4f0 (patch) | |
tree | 49ff0e98eaffc389f33fb57bd1b42735fe78bce8 /server/helpers/image-utils.ts | |
parent | c07fac202dba3fed69aace74157589c21d732be6 (diff) | |
download | PeerTube-123f61933611f326ea5a5e8c2ea253ee8720e4f0.tar.gz PeerTube-123f61933611f326ea5a5e8c2ea253ee8720e4f0.tar.zst PeerTube-123f61933611f326ea5a5e8c2ea253ee8720e4f0.zip |
Add pixel size to tooltip and gif support with FFmpeg for avatar upload (#3329)
* Add avatar pixel size upload in tooltip
* Add gif support for avatar
* Add ffmpeg GIF process
Co-authored-by: kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'server/helpers/image-utils.ts')
-rw-r--r-- | server/helpers/image-utils.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts index 5f254a7aa..fdf06e848 100644 --- a/server/helpers/image-utils.ts +++ b/server/helpers/image-utils.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { extname } from 'path' | ||
1 | import { remove, rename } from 'fs-extra' | 2 | import { remove, rename } from 'fs-extra' |
2 | import { convertWebPToJPG } from './ffmpeg-utils' | 3 | import { convertWebPToJPG, processGIF } from './ffmpeg-utils' |
3 | import { logger } from './logger' | 4 | import { logger } from './logger' |
4 | 5 | ||
5 | const Jimp = require('jimp') | 6 | const Jimp = require('jimp') |
@@ -10,6 +11,13 @@ async function processImage ( | |||
10 | newSize: { width: number, height: number }, | 11 | newSize: { width: number, height: number }, |
11 | keepOriginal = false | 12 | keepOriginal = false |
12 | ) { | 13 | ) { |
14 | const extension = extname(path) | ||
15 | |||
16 | // Use FFmpeg to process GIF | ||
17 | if (extension === '.gif') { | ||
18 | return processGIF(path, destination, newSize, keepOriginal) | ||
19 | } | ||
20 | |||
13 | if (path === destination) { | 21 | if (path === destination) { |
14 | throw new Error('Jimp needs an input path different that the output path.') | 22 | throw new Error('Jimp needs an input path different that the output path.') |
15 | } | 23 | } |