mirror of
https://github.com/immich-app/immich.git
synced 2026-08-02 00:48:08 -07:00
fix(web): use irot/imir tags for HEIF Orientation (#27820)
* fix(web): use irot/imir tags for HEIF Orientation * ignore Exif Orientation for HEIF images per MIAF standard compliance * add Rotation and Mirroring to exiftool numericTags * add isHeifBasedImage function to detect HEIF-based image extensions * add getHeifBasedOrientation method to map irot/imir tags to ExifOrientation * removed mirroring, simplified code * Removed "Based" in "heifBased" --------- Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
co-authored by
Jason Rasmussen
parent
12d344efe0
commit
164cda87a3
@@ -616,6 +616,17 @@ export class MetadataService extends BaseService {
|
||||
// never use duration from sidecar
|
||||
delete sidecarTags?.Duration;
|
||||
|
||||
// don't use Exif Orientation for HEIF based images, it's usually missing or invalid.
|
||||
// prefer irot (ExifTool QuickTime:Rotation) mapped to ExifOrientation.
|
||||
if (mimeTypes.isHeifImage(asset.originalPath)) {
|
||||
const orientation = this.getHeifOrientation(mediaTags);
|
||||
if (orientation === null) {
|
||||
delete mediaTags.Orientation;
|
||||
} else {
|
||||
mediaTags.Orientation = orientation;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
tags: { ...mediaTags, ...videoResult?.tags, ...sidecarTags },
|
||||
audio: videoResult?.audio,
|
||||
@@ -1110,4 +1121,24 @@ export class MetadataService extends BaseService {
|
||||
|
||||
return { tags, audio, video, packets, format };
|
||||
}
|
||||
|
||||
private getHeifOrientation(exifTags: ImmichTags): ExifOrientation | null {
|
||||
// https://exiftool.org/TagNames/QuickTime.html#ItemPropCont
|
||||
const rotation = typeof exifTags.Rotation === 'number' ? exifTags.Rotation : undefined;
|
||||
switch (rotation) {
|
||||
case 0: {
|
||||
return ExifOrientation.Horizontal;
|
||||
}
|
||||
case 1: {
|
||||
return ExifOrientation.Rotate270CW;
|
||||
}
|
||||
case 2: {
|
||||
return ExifOrientation.Rotate180;
|
||||
}
|
||||
case 3: {
|
||||
return ExifOrientation.Rotate90CW;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user