diff --git a/backend/model/threading/DiskMangerWorker.ts b/backend/model/threading/DiskMangerWorker.ts index 7a327ba5..819407bf 100644 --- a/backend/model/threading/DiskMangerWorker.ts +++ b/backend/model/threading/DiskMangerWorker.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; import {DirectoryDTO} from '../../../common/entities/DirectoryDTO'; -import {CameraMetadata, GPSMetadata, PhotoDTO, PhotoMetadata} from '../../../common/entities/PhotoDTO'; +import {PhotoDTO, PhotoMetadata} from '../../../common/entities/PhotoDTO'; import {Logger} from '../../Logger'; import {IptcParser} from 'ts-node-iptc'; import {ExifParserFactory, OrientationTypes} from 'ts-exif-parser'; @@ -9,9 +9,9 @@ import {FfprobeData} from 'fluent-ffmpeg'; import {ProjectPath} from '../../ProjectPath'; import {Config} from '../../../common/config/private/Config'; import {VideoDTO, VideoMetadata} from '../../../common/entities/VideoDTO'; -import {MediaDimension} from '../../../common/entities/MediaDTO'; import {FFmpegFactory} from '../FFmpegFactory'; import {FileDTO} from '../../../common/entities/FileDTO'; +import * as sizeOf from 'image-size'; const LOG_TAG = '[DiskManagerTask]'; @@ -240,11 +240,17 @@ export class DiskMangerWorker { } else if (exif.tags.RelatedImageWidth && exif.tags.RelatedImageHeight) { metadata.size = {width: exif.tags.RelatedImageWidth, height: exif.tags.RelatedImageHeight}; } else { - metadata.size = {width: 1, height: 1}; + const info = sizeOf(fullPath); + metadata.size = {width: info.width, height: info.height}; } } catch (err) { Logger.debug(LOG_TAG, 'Error parsing exif', fullPath, err); - metadata.size = {width: 1, height: 1}; + try { + const info = sizeOf(fullPath); + metadata.size = {width: info.width, height: info.height}; + } catch (e) { + metadata.size = {width: 1, height: 1}; + } } try { diff --git a/frontend/app/gallery/FixOrientationPipe.ts b/frontend/app/gallery/FixOrientationPipe.ts index d6545724..59cfd9c9 100644 --- a/frontend/app/gallery/FixOrientationPipe.ts +++ b/frontend/app/gallery/FixOrientationPipe.ts @@ -24,7 +24,7 @@ export class FixOrientationPipe implements PipeTransform { // set proper canvas dimensions before transform & export if (OrientationTypes.BOTTOM_LEFT < orientation && - orientation < OrientationTypes.LEFT_BOTTOM) { + orientation <= OrientationTypes.LEFT_BOTTOM) { // noinspection JSSuspiciousNameCombination canvas.width = height; // noinspection JSSuspiciousNameCombination diff --git a/package.json b/package.json index 492f5871..2115dd9c 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "ejs": "2.6.1", "express": "4.16.4", "fluent-ffmpeg": "2.1.2", + "image-size": "0.6.3", "jimp": "0.6.0", "locale": "0.1.0", "reflect-metadata": "0.1.12", @@ -69,6 +70,7 @@ "@types/express": "4.16.0", "@types/fluent-ffmpeg": "2.1.8", "@types/gm": "1.18.2", + "@types/image-size": "0.0.29", "@types/jasmine": "3.3.0", "@types/node": "10.12.12", "@types/sharp": "0.21.0",