fix(server): thumbnail rotation when using embedded previews (#13948)

This commit is contained in:
Terry Zhao
2024-11-08 01:30:59 -05:00
committed by GitHub
parent 7534098596
commit c8b46802d6
7 changed files with 50 additions and 22 deletions

View File

@@ -5,6 +5,7 @@ import { Duration } from 'luxon';
import fs from 'node:fs/promises';
import { Writable } from 'node:stream';
import sharp from 'sharp';
import { ORIENTATION_TO_SHARP_ROTATION } from 'src/constants';
import { Colorspace, LogLevel } from 'src/enum';
import { ILoggerRepository } from 'src/interfaces/logger.interface';
import {
@@ -82,7 +83,15 @@ export class MediaRepository implements IMediaRepository {
.withIccProfile(options.colorspace);
if (!options.raw) {
pipeline = pipeline.rotate();
const { angle, flip, flop } = options.orientation ? ORIENTATION_TO_SHARP_ROTATION[options.orientation] : {};
pipeline = pipeline.rotate(angle);
if (flip) {
pipeline = pipeline.flip();
}
if (flop) {
pipeline = pipeline.flop();
}
}
if (options.crop) {