aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/image-utils.ts
diff options
context:
space:
mode:
authorKimsible <1877318+kimsible@users.noreply.github.com>2020-11-25 09:26:31 +0100
committerGitHub <noreply@github.com>2020-11-25 09:26:31 +0100
commit123f61933611f326ea5a5e8c2ea253ee8720e4f0 (patch)
tree49ff0e98eaffc389f33fb57bd1b42735fe78bce8 /server/helpers/image-utils.ts
parentc07fac202dba3fed69aace74157589c21d732be6 (diff)
downloadPeerTube-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.ts10
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 @@
1import { extname } from 'path'
1import { remove, rename } from 'fs-extra' 2import { remove, rename } from 'fs-extra'
2import { convertWebPToJPG } from './ffmpeg-utils' 3import { convertWebPToJPG, processGIF } from './ffmpeg-utils'
3import { logger } from './logger' 4import { logger } from './logger'
4 5
5const Jimp = require('jimp') 6const 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 }