aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/thumbnail.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-09-17 10:00:46 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commit1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb (patch)
tree8bb02f8dc2590e5071306fb311bdc53289e20336 /server/lib/thumbnail.ts
parentc6c0fa6cd8fe8f752463d8982c3dbcd448739c4e (diff)
downloadPeerTube-1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb.tar.gz
PeerTube-1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb.tar.zst
PeerTube-1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb.zip
Refactor video creation
Diffstat (limited to 'server/lib/thumbnail.ts')
-rw-r--r--server/lib/thumbnail.ts17
1 files changed, 10 insertions, 7 deletions
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts
index 78d2f69e3..dc86423f8 100644
--- a/server/lib/thumbnail.ts
+++ b/server/lib/thumbnail.ts
@@ -42,15 +42,18 @@ function createVideoMiniatureFromUrl (fileUrl: string, video: MVideoThumbnail, t
42 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) 42 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
43} 43}
44 44
45function createVideoMiniatureFromExisting ( 45function createVideoMiniatureFromExisting (options: {
46 inputPath: string, 46 inputPath: string
47 video: MVideoThumbnail, 47 video: MVideoThumbnail
48 type: ThumbnailType, 48 type: ThumbnailType
49 automaticallyGenerated: boolean, 49 automaticallyGenerated: boolean
50 size?: ImageSize 50 size?: ImageSize
51) { 51 keepOriginal?: boolean
52}) {
53 const { inputPath, video, type, automaticallyGenerated, size, keepOriginal } = options
54
52 const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) 55 const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size)
53 const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }) 56 const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal)
54 57
55 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, automaticallyGenerated, existingThumbnail }) 58 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, automaticallyGenerated, existingThumbnail })
56} 59}