mirror of
https://github.com/immich-app/immich.git
synced 2025-12-22 17:24:56 +03:00
fix: asset thumbnail gen speedup
This commit is contained in:
@@ -42,6 +42,7 @@ import { getAssetFiles, getDimensions } from 'src/utils/asset.util';
|
||||
import { BaseConfig, ThumbnailConfig } from 'src/utils/media';
|
||||
import { mimeTypes } from 'src/utils/mime-types';
|
||||
import { clamp, isFaceImportEnabled, isFacialRecognitionEnabled } from 'src/utils/misc';
|
||||
import { getOutputDimensions } from 'src/utils/transform';
|
||||
interface UpsertFileOptions {
|
||||
assetId: string;
|
||||
type: AssetFileType;
|
||||
@@ -422,9 +423,10 @@ export class MediaService extends BaseService {
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
const dims = await this.mediaRepository.getImageDimensions(fullsizePath ?? asset.originalPath);
|
||||
const decodedDimensions = { width: info.width, height: info.height };
|
||||
const fullsizeDimensions = useEdits ? getOutputDimensions(asset.edits, decodedDimensions) : decodedDimensions;
|
||||
|
||||
return { previewPath, thumbnailPath, fullsizePath, thumbhash: outputs[0] as Buffer, fullsizeDimensions: dims };
|
||||
return { previewPath, thumbnailPath, fullsizePath, thumbhash: outputs[0] as Buffer, fullsizeDimensions };
|
||||
}
|
||||
|
||||
@OnJob({ name: JobName.PersonGenerateThumbnail, queue: QueueName.ThumbnailGeneration })
|
||||
|
||||
@@ -3,6 +3,27 @@ import { AssetOcrResponseDto } from 'src/dtos/ocr.dto';
|
||||
import { ImageDimensions } from 'src/types';
|
||||
import { applyToPoint, compose, flipX, flipY, identity, Matrix, rotate, scale, translate } from 'transformation-matrix';
|
||||
|
||||
export const getOutputDimensions = (edits: EditActionItem[], startingDimensions: ImageDimensions): ImageDimensions => {
|
||||
let { width, height } = startingDimensions;
|
||||
|
||||
const crop = edits.find((edit) => edit.action === EditAction.Crop);
|
||||
if (crop) {
|
||||
width = crop.parameters.width;
|
||||
height = crop.parameters.height;
|
||||
}
|
||||
|
||||
for (const edit of edits) {
|
||||
if (edit.action === EditAction.Rotate) {
|
||||
const angleDegrees = edit.parameters.angle;
|
||||
if (angleDegrees === 90 || angleDegrees === 270) {
|
||||
[width, height] = [height, width];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { width, height };
|
||||
};
|
||||
|
||||
export const createAffineMatrix = (
|
||||
edits: EditActionItem[],
|
||||
scalingParameters?: {
|
||||
|
||||
Reference in New Issue
Block a user