mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(server): enhanced thumbnails generation code (#2147)
* Add size parameter to extractVideoThumbnail * Ensure minimum dimension of webp thumbnail
This commit is contained in:
@@ -11,7 +11,11 @@ export class MediaRepository implements IMediaRepository {
|
||||
async resize(input: string, output: string, options: ResizeOptions): Promise<void> {
|
||||
switch (options.format) {
|
||||
case 'webp':
|
||||
await sharp(input, { failOnError: false }).resize(250).webp().rotate().toFile(output);
|
||||
await sharp(input, { failOnError: false })
|
||||
.resize(options.size, options.size, { fit: 'outside', withoutEnlargement: true })
|
||||
.webp()
|
||||
.rotate()
|
||||
.toFile(output);
|
||||
return;
|
||||
|
||||
case 'jpeg':
|
||||
@@ -24,10 +28,14 @@ export class MediaRepository implements IMediaRepository {
|
||||
}
|
||||
}
|
||||
|
||||
extractVideoThumbnail(input: string, output: string) {
|
||||
extractVideoThumbnail(input: string, output: string, size: number) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
ffmpeg(input)
|
||||
.outputOptions(['-ss 00:00:00.000', '-frames:v 1'])
|
||||
.outputOptions([
|
||||
'-ss 00:00:00.000',
|
||||
'-frames:v 1',
|
||||
`-vf scale='min(${size},iw)':'min(${size},ih)':force_original_aspect_ratio=increase`,
|
||||
])
|
||||
.output(output)
|
||||
.on('error', reject)
|
||||
.on('end', resolve)
|
||||
|
||||
Reference in New Issue
Block a user