X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fthumbnail.ts;h=02b867a91e6b9fd833514aa82093595925520aba;hb=5e47f6ab984a7d00782e4c7030afffa1ba480add;hp=f00c876238d245686426dfeb8c9efb046256fab8;hpb=e722fb5923ddf11d72e48cec9788abc64327c22f;p=github%2FChocobozzz%2FPeerTube.git 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 @@ import { join } from 'path' import { ThumbnailType } from '@shared/models' -import { generateImageFilename, generateImageFromVideoFile, processImage } from '../helpers/image-utils' +import { generateImageFilename, generateImageFromVideoFile } from '../helpers/image-utils' import { CONFIG } from '../initializers/config' import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' import { ThumbnailModel } from '../models/video/thumbnail' @@ -9,6 +9,7 @@ import { MThumbnail } from '../types/models/video/thumbnail' import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' import { downloadImageFromWorker } from './local-actor' import { VideoPathManager } from './video-path-manager' +import { processImageFromWorker } from './worker/parent-process' type ImageSize = { height?: number, width?: number } @@ -23,7 +24,10 @@ function updatePlaylistMiniatureFromExisting (options: { const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromPlaylist(playlist, size) const type = ThumbnailType.MINIATURE - const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) + const thumbnailCreator = () => { + return processImageFromWorker({ path: inputPath, destination: outputPath, newSize: { width, height }, keepOriginal }) + } + return updateThumbnailFromFunction({ thumbnailCreator, filename, @@ -99,7 +103,10 @@ function updateVideoMiniatureFromExisting (options: { const { inputPath, video, type, automaticallyGenerated, size, keepOriginal = false } = options const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) - const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) + + const thumbnailCreator = () => { + return processImageFromWorker({ path: inputPath, destination: outputPath, newSize: { width, height }, keepOriginal }) + } return updateThumbnailFromFunction({ thumbnailCreator, @@ -123,8 +130,18 @@ function generateVideoMiniature (options: { const { filename, basePath, height, width, existingThumbnail, outputPath } = buildMetadataFromVideo(video, type) const thumbnailCreator = videoFile.isAudio() - ? () => processImage(ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true) - : () => generateImageFromVideoFile(input, basePath, filename, { height, width }) + ? () => processImageFromWorker({ + path: ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, + destination: outputPath, + newSize: { width, height }, + keepOriginal: true + }) + : () => generateImageFromVideoFile({ + fromPath: input, + folder: basePath, + imageName: filename, + size: { height, width } + }) return updateThumbnailFromFunction({ thumbnailCreator,