From 205f98e6541a2e6d656cc893da7ee264f041c2a1 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Fri, 2 Nov 2018 11:44:13 +0100 Subject: [PATCH] fixing exif orientation bug on map --- backend/model/sql/enitites/PhotoEntity.ts | 2 +- backend/model/threading/DiskMangerWorker.ts | 3 ++- .../gallery/map/lightbox/lightbox.map.gallery.component.ts | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/model/sql/enitites/PhotoEntity.ts b/backend/model/sql/enitites/PhotoEntity.ts index c1326183..9d510058 100644 --- a/backend/model/sql/enitites/PhotoEntity.ts +++ b/backend/model/sql/enitites/PhotoEntity.ts @@ -80,7 +80,7 @@ export class PhotoMetadataEntity implements PhotoMetadata { @Column(type => PositionMetaDataEntity) positionData: PositionMetaDataEntity; - @Column('tinyint', {default: 1}) + @Column('tinyint', {default: OrientationTypes.TOP_LEFT}) orientation: OrientationTypes; @Column(type => ImageSizeEntity) diff --git a/backend/model/threading/DiskMangerWorker.ts b/backend/model/threading/DiskMangerWorker.ts index 2b930020..06a01c7c 100644 --- a/backend/model/threading/DiskMangerWorker.ts +++ b/backend/model/threading/DiskMangerWorker.ts @@ -93,7 +93,7 @@ export class DiskMangerWorker { cameraData: {}, positionData: null, size: {}, - orientation: OrientationTypes.TOP_RIGHT, + orientation: OrientationTypes.TOP_LEFT, creationDate: 0, fileSize: 0 }; @@ -133,6 +133,7 @@ export class DiskMangerWorker { metadata.orientation = exif.tags.Orientation; } + if (exif.imageSize) { metadata.size = {width: exif.imageSize.width, height: exif.imageSize.height}; } else if (exif.tags.RelatedImageWidth && exif.tags.RelatedImageHeight) { diff --git a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts index fe1791e2..aabcfb14 100644 --- a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts +++ b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts @@ -108,10 +108,11 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { }).map(p => { let width = 500; let height = 500; - if (p.metadata.size.width > p.metadata.size.height) { - height = width * (p.metadata.size.height / p.metadata.size.width); + const rotatedSize = PhotoDTO.getRotatedSize(p); + if (rotatedSize.width > rotatedSize.height) { + height = width * (rotatedSize.height / rotatedSize.width); } else { - width = height * (p.metadata.size.width / p.metadata.size.height); + width = height * (rotatedSize.width / rotatedSize.height); } const iconTh = this.thumbnailService.getIcon(new IconPhoto(p)); iconTh.Visible = true;