From 1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 17 Sep 2020 10:00:46 +0200 Subject: Refactor video creation --- server/lib/thumbnail.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'server/lib/thumbnail.ts') 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 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) } -function createVideoMiniatureFromExisting ( - inputPath: string, - video: MVideoThumbnail, - type: ThumbnailType, - automaticallyGenerated: boolean, +function createVideoMiniatureFromExisting (options: { + inputPath: string + video: MVideoThumbnail + type: ThumbnailType + automaticallyGenerated: boolean size?: ImageSize -) { + keepOriginal?: boolean +}) { + const { inputPath, video, type, automaticallyGenerated, size, keepOriginal } = options + const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) - const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }) + const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, automaticallyGenerated, existingThumbnail }) } -- cgit v1.2.3