feat(server/web): Initial support for RAF and SRW RAW formats.

This commit is contained in:
Skyler Mäntysaari
2023-01-25 01:30:01 +02:00
parent 8b7d7f1666
commit b00b5ebd8c
2 changed files with 23 additions and 12 deletions

View File

@@ -26,16 +26,18 @@ function fileFilter(req: Request, file: any, cb: any) {
if (!req.user) {
return cb(new UnauthorizedException());
}
if (
file.mimetype.match(
/\/(jpg|jpeg|png|gif|mp4|webm|x-msvideo|quicktime|heic|heif|dng|x-adobe-dng|webp|tiff|3gpp|nef|x-nikon-nef)$/,
)
) {
cb(null, true);
} else {
logger.error(`Unsupported file type ${extname(file.originalname)} file MIME type ${file.mimetype}`);
cb(new BadRequestException(`Unsupported file type ${extname(file.originalname)}`), false);
}
// TODO: Create new API endpoint for mimetypes and use that here.
cb(null, true);
//if (
// file.mimetype.match(
// /\/(jpg|jpeg|png|gif|mp4|webm|x-msvideo|quicktime|heic|heif|dng|x-adobe-dng|webp|tiff|3gpp|nef|x-nikon-nef)$/,
// )
//) {
// cb(null, true);
//} else {
// logger.error(`Unsupported file type ${extname(file.originalname)} file MIME type ${filetype}`);
// cb(new BadRequestException(`Unsupported file type ${extname(file.originalname)}`), false);
// }
}
function destination(req: Request, file: Express.Multer.File, cb: any) {

View File

@@ -14,6 +14,7 @@ import { Repository } from 'typeorm/repository/Repository';
import { join } from 'path';
import { CommunicationGateway } from 'apps/immich/src/api-v1/communication/communication.gateway';
import { IMachineLearningJob } from '@app/domain';
import { exiftool } from 'exiftool-vendored';
@Processor(QueueName.THUMBNAIL_GENERATION)
export class ThumbnailGeneratorProcessor {
@@ -49,11 +50,19 @@ export class ThumbnailGeneratorProcessor {
if (asset.type == AssetType.IMAGE) {
try {
await sharp(asset.originalPath, { failOnError: false })
await sharp(asset.originalPath, { failOnError: true })
.resize(1440, 2560, { fit: 'inside' })
.jpeg()
.rotate()
.toFile(jpegThumbnailPath);
.toFile(jpegThumbnailPath)
.catch(() => {
this.logger.warn(
'Failed to generate jpeg thumbnail for asset: ' +
asset.id +
' using sharp, failing over to exiftool-vendored',
);
exiftool.extractThumbnail(asset.originalPath, jpegThumbnailPath);
});
await this.assetRepository.update({ id: asset.id }, { resizePath: jpegThumbnailPath });
} catch (error: any) {
this.logger.error('Failed to generate jpeg thumbnail for asset: ' + asset.id, error.stack);