mirror of
https://github.com/immich-app/immich.git
synced 2025-06-03 05:34:32 -04:00
fix(server): Handle exposure time correctly (#1432)
This commit is contained in:
parent
bcb0056b55
commit
8b73c2bf8a
@ -188,7 +188,7 @@ class ExifBottomSheet extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
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} ",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
2
mobile/openapi/doc/ExifResponseDto.md
generated
2
mobile/openapi/doc/ExifResponseDto.md
generated
@ -22,7 +22,7 @@ Name | Type | Description | Notes
|
|||||||
**fNumber** | **num** | | [optional]
|
**fNumber** | **num** | | [optional]
|
||||||
**focalLength** | **num** | | [optional]
|
**focalLength** | **num** | | [optional]
|
||||||
**iso** | **num** | | [optional]
|
**iso** | **num** | | [optional]
|
||||||
**exposureTime** | **num** | | [optional]
|
**exposureTime** | **String** | | [optional]
|
||||||
**latitude** | **num** | | [optional]
|
**latitude** | **num** | | [optional]
|
||||||
**longitude** | **num** | | [optional]
|
**longitude** | **num** | | [optional]
|
||||||
**city** | **String** | | [optional]
|
**city** | **String** | | [optional]
|
||||||
|
6
mobile/openapi/lib/model/exif_response_dto.dart
generated
6
mobile/openapi/lib/model/exif_response_dto.dart
generated
@ -63,7 +63,7 @@ class ExifResponseDto {
|
|||||||
|
|
||||||
num? iso;
|
num? iso;
|
||||||
|
|
||||||
num? exposureTime;
|
String? exposureTime;
|
||||||
|
|
||||||
num? latitude;
|
num? latitude;
|
||||||
|
|
||||||
@ -273,9 +273,7 @@ class ExifResponseDto {
|
|||||||
iso: json[r'iso'] == null
|
iso: json[r'iso'] == null
|
||||||
? null
|
? null
|
||||||
: num.parse(json[r'iso'].toString()),
|
: num.parse(json[r'iso'].toString()),
|
||||||
exposureTime: json[r'exposureTime'] == null
|
exposureTime: mapValueOfType<String>(json, r'exposureTime'),
|
||||||
? null
|
|
||||||
: num.parse(json[r'exposureTime'].toString()),
|
|
||||||
latitude: json[r'latitude'] == null
|
latitude: json[r'latitude'] == null
|
||||||
? null
|
? null
|
||||||
: num.parse(json[r'latitude'].toString()),
|
: num.parse(json[r'latitude'].toString()),
|
||||||
|
2
mobile/openapi/test/exif_response_dto_test.dart
generated
2
mobile/openapi/test/exif_response_dto_test.dart
generated
@ -86,7 +86,7 @@ void main() {
|
|||||||
// TODO
|
// TODO
|
||||||
});
|
});
|
||||||
|
|
||||||
// num exposureTime
|
// String exposureTime
|
||||||
test('to test the property `exposureTime`', () async {
|
test('to test the property `exposureTime`', () async {
|
||||||
// TODO
|
// TODO
|
||||||
});
|
});
|
||||||
|
@ -154,13 +154,6 @@ export class MetadataExtractionProcessor {
|
|||||||
return exifDate.toDate();
|
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 createdAt = exifToDate(exifData?.DateTimeOriginal ?? exifData?.CreateDate ?? asset.createdAt);
|
||||||
const modifyDate = exifToDate(exifData?.ModifyDate ?? asset.modifiedAt);
|
const modifyDate = exifToDate(exifData?.ModifyDate ?? asset.modifiedAt);
|
||||||
const fileStats = fs.statSync(asset.originalPath);
|
const fileStats = fs.statSync(asset.originalPath);
|
||||||
@ -174,7 +167,7 @@ export class MetadataExtractionProcessor {
|
|||||||
newExif.model = exifData?.Model || null;
|
newExif.model = exifData?.Model || null;
|
||||||
newExif.exifImageHeight = exifData?.ExifImageHeight || exifData?.ImageHeight || null;
|
newExif.exifImageHeight = exifData?.ExifImageHeight || exifData?.ImageHeight || null;
|
||||||
newExif.exifImageWidth = exifData?.ExifImageWidth || exifData?.ImageWidth || 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.orientation = exifData?.Orientation?.toString() || null;
|
||||||
newExif.dateTimeOriginal = createdAt;
|
newExif.dateTimeOriginal = createdAt;
|
||||||
newExif.modifyDate = modifyDate;
|
newExif.modifyDate = modifyDate;
|
||||||
|
@ -3207,7 +3207,7 @@
|
|||||||
"default": null
|
"default": null
|
||||||
},
|
},
|
||||||
"exposureTime": {
|
"exposureTime": {
|
||||||
"type": "number",
|
"type": "string",
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
"default": null
|
"default": null
|
||||||
},
|
},
|
||||||
|
@ -19,7 +19,7 @@ export class ExifResponseDto {
|
|||||||
fNumber?: number | null = null;
|
fNumber?: number | null = null;
|
||||||
focalLength?: number | null = null;
|
focalLength?: number | null = null;
|
||||||
iso?: number | null = null;
|
iso?: number | null = null;
|
||||||
exposureTime?: number | null = null;
|
exposureTime?: string | null = null;
|
||||||
latitude?: number | null = null;
|
latitude?: number | null = null;
|
||||||
longitude?: number | null = null;
|
longitude?: number | null = null;
|
||||||
city?: string | null = null;
|
city?: string | null = null;
|
||||||
|
@ -22,7 +22,7 @@ const assetInfo: ExifResponseDto = {
|
|||||||
fNumber: 100,
|
fNumber: 100,
|
||||||
focalLength: 100,
|
focalLength: 100,
|
||||||
iso: 100,
|
iso: 100,
|
||||||
exposureTime: 100,
|
exposureTime: '1/16',
|
||||||
latitude: 100,
|
latitude: 100,
|
||||||
longitude: 100,
|
longitude: 100,
|
||||||
city: 'city',
|
city: 'city',
|
||||||
@ -349,7 +349,7 @@ export const sharedLinkStub = {
|
|||||||
fNumber: 100,
|
fNumber: 100,
|
||||||
focalLength: 100,
|
focalLength: 100,
|
||||||
iso: 100,
|
iso: 100,
|
||||||
exposureTime: 100,
|
exposureTime: '1/16',
|
||||||
fps: 100,
|
fps: 100,
|
||||||
asset: null as any,
|
asset: null as any,
|
||||||
exifTextSearchableColumn: '',
|
exifTextSearchableColumn: '',
|
||||||
|
@ -72,8 +72,8 @@ export class ExifEntity {
|
|||||||
@Column({ type: 'integer', nullable: true })
|
@Column({ type: 'integer', nullable: true })
|
||||||
iso!: number | null;
|
iso!: number | null;
|
||||||
|
|
||||||
@Column({ type: 'float', nullable: true })
|
@Column({ type: 'varchar', nullable: true })
|
||||||
exposureTime!: number | null;
|
exposureTime!: string | null;
|
||||||
|
|
||||||
/* Video info */
|
/* Video info */
|
||||||
@Column({ type: 'float8', nullable: true })
|
@Column({ type: 'float8', nullable: true })
|
||||||
|
@ -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`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
4
web/src/api/open-api/api.ts
generated
4
web/src/api/open-api/api.ts
generated
@ -1116,10 +1116,10 @@ export interface ExifResponseDto {
|
|||||||
'iso'?: number | null;
|
'iso'?: number | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {number}
|
* @type {string}
|
||||||
* @memberof ExifResponseDto
|
* @memberof ExifResponseDto
|
||||||
*/
|
*/
|
||||||
'exposureTime'?: number | null;
|
'exposureTime'?: string | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
@ -152,7 +152,7 @@
|
|||||||
<p>{`ƒ/${asset.exifInfo.fNumber.toLocaleString(locale)}` || ''}</p>
|
<p>{`ƒ/${asset.exifInfo.fNumber.toLocaleString(locale)}` || ''}</p>
|
||||||
|
|
||||||
{#if asset.exifInfo.exposureTime}
|
{#if asset.exifInfo.exposureTime}
|
||||||
<p>{`1/${asset.exifInfo.exposureTime}`}</p>
|
<p>{`${asset.exifInfo.exposureTime}`}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if asset.exifInfo.focalLength}
|
{#if asset.exifInfo.focalLength}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user