mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
fix(server): exiftool largefilesupport only set for the first call (#10167)
* Revert "feat(server): enable exiftool largefilesupport (#9894)"
This reverts commit afa10ebcb2
.
* feat(server): enable exiftool largefilesupport by passing options to read
This commit is contained in:
parent
cdc98de848
commit
216cca4383
1 changed files with 7 additions and 12 deletions
|
@ -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 { DefaultExiftoolArgs, DefaultReadTaskOptions, ExifTool, Tags } from 'exiftool-vendored';
|
import { DefaultReadTaskOptions, Tags, exiftool } 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,23 +21,18 @@ 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 this.exiftool.end();
|
await 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 this.exiftool
|
return exiftool
|
||||||
.read(path, undefined, {
|
.read(path, undefined, {
|
||||||
...DefaultReadTaskOptions,
|
...DefaultReadTaskOptions,
|
||||||
|
|
||||||
|
// Enable exiftool LFS to parse metadata for files larger than 2GB.
|
||||||
|
optionalArgs: ['-api', 'largefilesupport=1'],
|
||||||
defaultVideosToUTC: true,
|
defaultVideosToUTC: true,
|
||||||
backfillTimezones: true,
|
backfillTimezones: true,
|
||||||
inferTimezoneFromDatestamps: true,
|
inferTimezoneFromDatestamps: true,
|
||||||
|
@ -53,12 +48,12 @@ export class MetadataRepository implements IMetadataRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
extractBinaryTag(path: string, tagName: string): Promise<Buffer> {
|
extractBinaryTag(path: string, tagName: string): Promise<Buffer> {
|
||||||
return this.exiftool.extractBinaryTagToBuffer(tagName, path);
|
return 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 this.exiftool.write(path, tags, ['-overwrite_original']);
|
await 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…
Reference in a new issue