fix(server): Handle exposure time correctly (#1432)

This commit is contained in:
Alex 2023-01-26 13:14:05 -06:00 committed by GitHub
parent bcb0056b55
commit 8b73c2bf8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 31 additions and 24 deletions

View File

@ -188,7 +188,7 @@ class ExifBottomSheet extends HookConsumerWidget {
),
),
subtitle: Text(
"ƒ/${exifInfo.fNumber} 1/${(1 / (exifInfo.exposureTime ?? 1)).toStringAsFixed(0)} ${exifInfo.focalLength} mm ISO${exifInfo.iso} ",
"ƒ/${exifInfo.fNumber} ${exifInfo.exposureTime} ${exifInfo.focalLength} mm ISO${exifInfo.iso} ",
),
),
],

View File

@ -22,7 +22,7 @@ Name | Type | Description | Notes
**fNumber** | **num** | | [optional]
**focalLength** | **num** | | [optional]
**iso** | **num** | | [optional]
**exposureTime** | **num** | | [optional]
**exposureTime** | **String** | | [optional]
**latitude** | **num** | | [optional]
**longitude** | **num** | | [optional]
**city** | **String** | | [optional]

View File

@ -63,7 +63,7 @@ class ExifResponseDto {
num? iso;
num? exposureTime;
String? exposureTime;
num? latitude;
@ -273,9 +273,7 @@ class ExifResponseDto {
iso: json[r'iso'] == null
? null
: num.parse(json[r'iso'].toString()),
exposureTime: json[r'exposureTime'] == null
? null
: num.parse(json[r'exposureTime'].toString()),
exposureTime: mapValueOfType<String>(json, r'exposureTime'),
latitude: json[r'latitude'] == null
? null
: num.parse(json[r'latitude'].toString()),

View File

@ -86,7 +86,7 @@ void main() {
// TODO
});
// num exposureTime
// String exposureTime
test('to test the property `exposureTime`', () async {
// TODO
});

View File

@ -154,13 +154,6 @@ export class MetadataExtractionProcessor {
return exifDate.toDate();
};
const getExposureTimeDenominator = (exposureTime: string | undefined) => {
if (!exposureTime) return null;
const exposureTimeSplit = exposureTime.split('/');
return exposureTimeSplit.length === 2 ? parseInt(exposureTimeSplit[1]) : null;
};
const createdAt = exifToDate(exifData?.DateTimeOriginal ?? exifData?.CreateDate ?? asset.createdAt);
const modifyDate = exifToDate(exifData?.ModifyDate ?? asset.modifiedAt);
const fileStats = fs.statSync(asset.originalPath);
@ -174,7 +167,7 @@ export class MetadataExtractionProcessor {
newExif.model = exifData?.Model || null;
newExif.exifImageHeight = exifData?.ExifImageHeight || exifData?.ImageHeight || null;
newExif.exifImageWidth = exifData?.ExifImageWidth || exifData?.ImageWidth || null;
newExif.exposureTime = getExposureTimeDenominator(exifData?.ExposureTime);
newExif.exposureTime = exifData?.ExposureTime || null;
newExif.orientation = exifData?.Orientation?.toString() || null;
newExif.dateTimeOriginal = createdAt;
newExif.modifyDate = modifyDate;

View File

@ -3207,7 +3207,7 @@
"default": null
},
"exposureTime": {
"type": "number",
"type": "string",
"nullable": true,
"default": null
},

View File

@ -19,7 +19,7 @@ export class ExifResponseDto {
fNumber?: number | null = null;
focalLength?: number | null = null;
iso?: number | null = null;
exposureTime?: number | null = null;
exposureTime?: string | null = null;
latitude?: number | null = null;
longitude?: number | null = null;
city?: string | null = null;

View File

@ -22,7 +22,7 @@ const assetInfo: ExifResponseDto = {
fNumber: 100,
focalLength: 100,
iso: 100,
exposureTime: 100,
exposureTime: '1/16',
latitude: 100,
longitude: 100,
city: 'city',
@ -349,7 +349,7 @@ export const sharedLinkStub = {
fNumber: 100,
focalLength: 100,
iso: 100,
exposureTime: 100,
exposureTime: '1/16',
fps: 100,
asset: null as any,
exifTextSearchableColumn: '',

View File

@ -72,8 +72,8 @@ export class ExifEntity {
@Column({ type: 'integer', nullable: true })
iso!: number | null;
@Column({ type: 'float', nullable: true })
exposureTime!: number | null;
@Column({ type: 'varchar', nullable: true })
exposureTime!: string | null;
/* Video info */
@Column({ type: 'float8', nullable: true })

View File

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AlterExifExposureTimeToString1674757936889 implements MigrationInterface {
name = 'AlterExifExposureTimeToString1674757936889'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "exif" DROP COLUMN "exposureTime"`);
await queryRunner.query(`ALTER TABLE "exif" ADD "exposureTime" character varying`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "exif" DROP COLUMN "exposureTime"`);
await queryRunner.query(`ALTER TABLE "exif" ADD "exposureTime" double precision`);
}
}

View File

@ -1116,10 +1116,10 @@ export interface ExifResponseDto {
'iso'?: number | null;
/**
*
* @type {number}
* @type {string}
* @memberof ExifResponseDto
*/
'exposureTime'?: number | null;
'exposureTime'?: string | null;
/**
*
* @type {number}

View File

@ -152,7 +152,7 @@
<p>{`ƒ/${asset.exifInfo.fNumber.toLocaleString(locale)}` || ''}</p>
{#if asset.exifInfo.exposureTime}
<p>{`1/${asset.exifInfo.exposureTime}`}</p>
<p>{`${asset.exifInfo.exposureTime}`}</p>
{/if}
{#if asset.exifInfo.focalLength}