diff options
author | Chocobozzz <me@florianbigard.com> | 2020-09-17 10:00:46 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | 1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb (patch) | |
tree | 8bb02f8dc2590e5071306fb311bdc53289e20336 /server/lib/thumbnail.ts | |
parent | c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e (diff) | |
download | PeerTube-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.ts | 17 |
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 | ||
45 | function createVideoMiniatureFromExisting ( | 45 | function 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 | } |