diff options
Diffstat (limited to 'server/lib/thumbnail.ts')
-rw-r--r-- | server/lib/thumbnail.ts | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts index f00c87623..02b867a91 100644 --- a/server/lib/thumbnail.ts +++ b/server/lib/thumbnail.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { ThumbnailType } from '@shared/models' | 2 | import { ThumbnailType } from '@shared/models' |
3 | import { generateImageFilename, generateImageFromVideoFile, processImage } from '../helpers/image-utils' | 3 | import { generateImageFilename, generateImageFromVideoFile } from '../helpers/image-utils' |
4 | import { CONFIG } from '../initializers/config' | 4 | import { CONFIG } from '../initializers/config' |
5 | import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' | 5 | import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' |
6 | import { ThumbnailModel } from '../models/video/thumbnail' | 6 | import { ThumbnailModel } from '../models/video/thumbnail' |
@@ -9,6 +9,7 @@ import { MThumbnail } from '../types/models/video/thumbnail' | |||
9 | import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' | 9 | import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' |
10 | import { downloadImageFromWorker } from './local-actor' | 10 | import { downloadImageFromWorker } from './local-actor' |
11 | import { VideoPathManager } from './video-path-manager' | 11 | import { VideoPathManager } from './video-path-manager' |
12 | import { processImageFromWorker } from './worker/parent-process' | ||
12 | 13 | ||
13 | type ImageSize = { height?: number, width?: number } | 14 | type ImageSize = { height?: number, width?: number } |
14 | 15 | ||
@@ -23,7 +24,10 @@ function updatePlaylistMiniatureFromExisting (options: { | |||
23 | const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromPlaylist(playlist, size) | 24 | const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromPlaylist(playlist, size) |
24 | const type = ThumbnailType.MINIATURE | 25 | const type = ThumbnailType.MINIATURE |
25 | 26 | ||
26 | const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) | 27 | const thumbnailCreator = () => { |
28 | return processImageFromWorker({ path: inputPath, destination: outputPath, newSize: { width, height }, keepOriginal }) | ||
29 | } | ||
30 | |||
27 | return updateThumbnailFromFunction({ | 31 | return updateThumbnailFromFunction({ |
28 | thumbnailCreator, | 32 | thumbnailCreator, |
29 | filename, | 33 | filename, |
@@ -99,7 +103,10 @@ function updateVideoMiniatureFromExisting (options: { | |||
99 | const { inputPath, video, type, automaticallyGenerated, size, keepOriginal = false } = options | 103 | const { inputPath, video, type, automaticallyGenerated, size, keepOriginal = false } = options |
100 | 104 | ||
101 | const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) | 105 | const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) |
102 | const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) | 106 | |
107 | const thumbnailCreator = () => { | ||
108 | return processImageFromWorker({ path: inputPath, destination: outputPath, newSize: { width, height }, keepOriginal }) | ||
109 | } | ||
103 | 110 | ||
104 | return updateThumbnailFromFunction({ | 111 | return updateThumbnailFromFunction({ |
105 | thumbnailCreator, | 112 | thumbnailCreator, |
@@ -123,8 +130,18 @@ function generateVideoMiniature (options: { | |||
123 | const { filename, basePath, height, width, existingThumbnail, outputPath } = buildMetadataFromVideo(video, type) | 130 | const { filename, basePath, height, width, existingThumbnail, outputPath } = buildMetadataFromVideo(video, type) |
124 | 131 | ||
125 | const thumbnailCreator = videoFile.isAudio() | 132 | const thumbnailCreator = videoFile.isAudio() |
126 | ? () => processImage(ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true) | 133 | ? () => processImageFromWorker({ |
127 | : () => generateImageFromVideoFile(input, basePath, filename, { height, width }) | 134 | path: ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, |
135 | destination: outputPath, | ||
136 | newSize: { width, height }, | ||
137 | keepOriginal: true | ||
138 | }) | ||
139 | : () => generateImageFromVideoFile({ | ||
140 | fromPath: input, | ||
141 | folder: basePath, | ||
142 | imageName: filename, | ||
143 | size: { height, width } | ||
144 | }) | ||
128 | 145 | ||
129 | return updateThumbnailFromFunction({ | 146 | return updateThumbnailFromFunction({ |
130 | thumbnailCreator, | 147 | thumbnailCreator, |