mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	fix(server): Handle exposure time correctly (#1432)
This commit is contained in:
		| @@ -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} ", | ||||
|                           ), | ||||
|                         ), | ||||
|                     ], | ||||
|   | ||||
							
								
								
									
										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]  | ||||
| **focalLength** | **num** |  | [optional]  | ||||
| **iso** | **num** |  | [optional]  | ||||
| **exposureTime** | **num** |  | [optional]  | ||||
| **exposureTime** | **String** |  | [optional]  | ||||
| **latitude** | **num** |  | [optional]  | ||||
| **longitude** | **num** |  | [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? 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()), | ||||
|   | ||||
							
								
								
									
										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 | ||||
|     }); | ||||
| 
 | ||||
|     // num exposureTime | ||||
|     // String exposureTime | ||||
|     test('to test the property `exposureTime`', () async { | ||||
|       // TODO | ||||
|     }); | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -3207,7 +3207,7 @@ | ||||
|             "default": null | ||||
|           }, | ||||
|           "exposureTime": { | ||||
|             "type": "number", | ||||
|             "type": "string", | ||||
|             "nullable": true, | ||||
|             "default": null | ||||
|           }, | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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: '', | ||||
|   | ||||
| @@ -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 }) | ||||
|   | ||||
| @@ -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; | ||||
|     /** | ||||
|      *  | ||||
|      * @type {number} | ||||
|      * @type {string} | ||||
|      * @memberof ExifResponseDto | ||||
|      */ | ||||
|     'exposureTime'?: number | null; | ||||
|     'exposureTime'?: string | null; | ||||
|     /** | ||||
|      *  | ||||
|      * @type {number} | ||||
|   | ||||
| @@ -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} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user