aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/thumbnail.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/thumbnail.ts')
-rw-r--r--server/lib/thumbnail.ts27
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 @@
1import { join } from 'path' 1import { join } from 'path'
2import { ThumbnailType } from '@shared/models' 2import { ThumbnailType } from '@shared/models'
3import { generateImageFilename, generateImageFromVideoFile, processImage } from '../helpers/image-utils' 3import { generateImageFilename, generateImageFromVideoFile } from '../helpers/image-utils'
4import { CONFIG } from '../initializers/config' 4import { CONFIG } from '../initializers/config'
5import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' 5import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants'
6import { ThumbnailModel } from '../models/video/thumbnail' 6import { ThumbnailModel } from '../models/video/thumbnail'
@@ -9,6 +9,7 @@ import { MThumbnail } from '../types/models/video/thumbnail'
9import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' 9import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist'
10import { downloadImageFromWorker } from './local-actor' 10import { downloadImageFromWorker } from './local-actor'
11import { VideoPathManager } from './video-path-manager' 11import { VideoPathManager } from './video-path-manager'
12import { processImageFromWorker } from './worker/parent-process'
12 13
13type ImageSize = { height?: number, width?: number } 14type 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,