diff --git a/server/src/services/metadata.service.ts b/server/src/services/metadata.service.ts index 9538130ee0626f..b4693e5e2dca42 100644 --- a/server/src/services/metadata.service.ts +++ b/server/src/services/metadata.service.ts @@ -336,25 +336,16 @@ export class MetadataService extends BaseService { return JobStatus.SUCCESS; } - private getImageDimensions(exifTags: ImmichTags): { width: number; height: number } { + private getImageDimensions(exifTags: ImmichTags): { width?: number; height?: number } { /* * The "true" values for width and height are a bit hidden, depending on the camera model and file format. * For RAW images in the CR2 or RAF format, the "ImageSize" value seems to be correct, * but ImageWidth and ImageHeight are not correct (they contain the dimensions of the preview image). */ - let width = Number.NaN; - let height = Number.NaN; - const imageSize = exifTags.ImageSize; - if (imageSize && imageSize.indexOf('x') > 0) { - // ImageSize is "width x height" (e.g. "100x200") - const split = imageSize.split('x'); - width = Number.parseInt(split[0]); - height = Number.parseInt(split[1]); - } + let [width, height] = exifTags.ImageSize?.split('x').map((dim) => Number.parseInt(dim) || undefined) || []; if (!width || !height) { - width = exifTags.ImageWidth ?? Number.NaN; - height = exifTags.ImageHeight ?? Number.NaN; + [width, height] = [exifTags.ImageWidth, exifTags.ImageHeight]; } return { width, height }; }