mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 10:37:11 -04:00 
			
		
		
		
	feat(server): enable exiftool largefilesupport (#9894)
This commit is contained in:
		
							parent
							
								
									5ef2553bca
								
							
						
					
					
						commit
						afa10ebcb2
					
				| @ -1,6 +1,6 @@ | |||||||
| import { Inject, Injectable } from '@nestjs/common'; | import { Inject, Injectable } from '@nestjs/common'; | ||||||
| import { InjectDataSource, InjectRepository } from '@nestjs/typeorm'; | import { InjectDataSource, InjectRepository } from '@nestjs/typeorm'; | ||||||
| import { DefaultReadTaskOptions, Tags, exiftool } from 'exiftool-vendored'; | import { DefaultExiftoolArgs, DefaultReadTaskOptions, ExifTool, Tags } from 'exiftool-vendored'; | ||||||
| import geotz from 'geo-tz'; | import geotz from 'geo-tz'; | ||||||
| import { DummyValue, GenerateSql } from 'src/decorators'; | import { DummyValue, GenerateSql } from 'src/decorators'; | ||||||
| import { ExifEntity } from 'src/entities/exif.entity'; | import { ExifEntity } from 'src/entities/exif.entity'; | ||||||
| @ -21,13 +21,20 @@ export class MetadataRepository implements IMetadataRepository { | |||||||
|   ) { |   ) { | ||||||
|     this.logger.setContext(MetadataRepository.name); |     this.logger.setContext(MetadataRepository.name); | ||||||
|   } |   } | ||||||
|  |   private exiftool: ExifTool = this.initExiftool(); | ||||||
| 
 | 
 | ||||||
|   async teardown() { |   async teardown() { | ||||||
|     await exiftool.end(); |     await this.exiftool.end(); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   private initExiftool() { | ||||||
|  |     // Enable exiftool LFS to parse metadata for files larger than 2GB.
 | ||||||
|  |     const exiftoolArgs = ['-api', 'largefilesupport=1', ...DefaultExiftoolArgs]; | ||||||
|  |     return new ExifTool({ exiftoolArgs }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   readTags(path: string): Promise<ImmichTags | null> { |   readTags(path: string): Promise<ImmichTags | null> { | ||||||
|     return exiftool |     return this.exiftool | ||||||
|       .read(path, undefined, { |       .read(path, undefined, { | ||||||
|         ...DefaultReadTaskOptions, |         ...DefaultReadTaskOptions, | ||||||
| 
 | 
 | ||||||
| @ -46,12 +53,12 @@ export class MetadataRepository implements IMetadataRepository { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   extractBinaryTag(path: string, tagName: string): Promise<Buffer> { |   extractBinaryTag(path: string, tagName: string): Promise<Buffer> { | ||||||
|     return exiftool.extractBinaryTagToBuffer(tagName, path); |     return this.exiftool.extractBinaryTagToBuffer(tagName, path); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async writeTags(path: string, tags: Partial<Tags>): Promise<void> { |   async writeTags(path: string, tags: Partial<Tags>): Promise<void> { | ||||||
|     try { |     try { | ||||||
|       await exiftool.write(path, tags, ['-overwrite_original']); |       await this.exiftool.write(path, tags, ['-overwrite_original']); | ||||||
|     } catch (error) { |     } catch (error) { | ||||||
|       this.logger.warn(`Error writing exif data (${path}): ${error}`); |       this.logger.warn(`Error writing exif data (${path}): ${error}`); | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user