Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: downgrade exiftool-vendored to fix motion photo extraction #11145

Merged
merged 7 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions e2e/src/api/specs/asset.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1170,21 +1170,25 @@
// into the test here.
it.each([
{
filepath: 'formats/motionphoto/Samsung One UI 5.jpg',
filepath: 'formats/motionphoto/samsung-one-ui-5.jpg',
checksum: 'fr14niqCq6N20HB8rJYEvpsUVtI=',
},
{
filepath: 'formats/motionphoto/Samsung One UI 6.jpg',
filepath: 'formats/motionphoto/samsung-one-ui-6.jpg',
checksum: 'lT9Uviw/FFJYCjfIxAGPTjzAmmw=',
},
{
filepath: 'formats/motionphoto/Samsung One UI 6.heic',
filepath: 'formats/motionphoto/samsung-one-ui-6.heic',
checksum: '/ejgzywvgvzvVhUYVfvkLzFBAF0=',
},
{
filepath: 'formats/motionphoto/pixel-6-pro.jpg',
checksum: 'bFhLGbdK058PSk4FTfrSnoKWykc=',
},
])(`should extract motionphoto video from $filepath`, async ({ filepath, checksum }) => {
const response = await utils.createAsset(admin.accessToken, {
assetData: {
bytes: await readFile(join(testAssetDir, filepath)),

Check failure on line 1191 in e2e/src/api/specs/asset.e2e-spec.ts

View workflow job for this annotation

GitHub Actions / End-to-End Tests

src/api/specs/asset.e2e-spec.ts > /asset > POST /assets > should extract motionphoto video from 'formats/motionphoto/samsung-one-ui-5.…'

Error: ENOENT: no such file or directory, open '/home/runner/work/immich/immich/e2e/test-assets/formats/motionphoto/samsung-one-ui-5.jpg' ❯ src/api/specs/asset.e2e-spec.ts:1191:18 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -2, code: 'ENOENT', syscall: 'open', path: '/home/runner/work/immich/immich/e2e/test-assets/formats/motionphoto/samsung-one-ui-5.jpg' }

Check failure on line 1191 in e2e/src/api/specs/asset.e2e-spec.ts

View workflow job for this annotation

GitHub Actions / End-to-End Tests

src/api/specs/asset.e2e-spec.ts > /asset > POST /assets > should extract motionphoto video from 'formats/motionphoto/samsung-one-ui-6.…'

Error: ENOENT: no such file or directory, open '/home/runner/work/immich/immich/e2e/test-assets/formats/motionphoto/samsung-one-ui-6.jpg' ❯ src/api/specs/asset.e2e-spec.ts:1191:18 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -2, code: 'ENOENT', syscall: 'open', path: '/home/runner/work/immich/immich/e2e/test-assets/formats/motionphoto/samsung-one-ui-6.jpg' }

Check failure on line 1191 in e2e/src/api/specs/asset.e2e-spec.ts

View workflow job for this annotation

GitHub Actions / End-to-End Tests

src/api/specs/asset.e2e-spec.ts > /asset > POST /assets > should extract motionphoto video from 'formats/motionphoto/samsung-one-ui-6.…'

Error: ENOENT: no such file or directory, open '/home/runner/work/immich/immich/e2e/test-assets/formats/motionphoto/samsung-one-ui-6.heic' ❯ src/api/specs/asset.e2e-spec.ts:1191:18 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -2, code: 'ENOENT', syscall: 'open', path: '/home/runner/work/immich/immich/e2e/test-assets/formats/motionphoto/samsung-one-ui-6.heic' }

Check failure on line 1191 in e2e/src/api/specs/asset.e2e-spec.ts

View workflow job for this annotation

GitHub Actions / End-to-End Tests

src/api/specs/asset.e2e-spec.ts > /asset > POST /assets > should extract motionphoto video from 'formats/motionphoto/pixel-6-pro.jpg'

Error: ENOENT: no such file or directory, open '/home/runner/work/immich/immich/e2e/test-assets/formats/motionphoto/pixel-6-pro.jpg' ❯ src/api/specs/asset.e2e-spec.ts:1191:18 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -2, code: 'ENOENT', syscall: 'open', path: '/home/runner/work/immich/immich/e2e/test-assets/formats/motionphoto/pixel-6-pro.jpg' }
filename: basename(filepath),
},
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/test-assets
Submodule test-assets updated 4 files
+19 −0 .editorconfig
+134 −0 CODE_OF_CONDUCT.md
+620 −0 LICENSE
+5 −0 SECURITY.md
47 changes: 23 additions & 24 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"cookie-parser": "^1.4.6",
"exiftool-vendored": "~27.0.0",
"exiftool-vendored": "26.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep the ~ right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, although it doesn't really matter as renovate will ignore that and try to bump anyway

"fast-glob": "^3.3.2",
"fluent-ffmpeg": "^2.1.2",
"geo-tz": "^8.0.0",
Expand Down
43 changes: 22 additions & 21 deletions server/src/repositories/metadata.repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { DefaultReadTaskOptions, ExifTool, Tags } from 'exiftool-vendored';
import { DefaultReadTaskOptions, Tags, exiftool } from 'exiftool-vendored';
import geotz from 'geo-tz';
import { DummyValue, GenerateSql } from 'src/decorators';
import { ExifEntity } from 'src/entities/exif.entity';
Expand All @@ -17,39 +17,40 @@ export class MetadataRepository implements IMetadataRepository {
@Inject(ILoggerRepository) private logger: ILoggerRepository,
) {
this.logger.setContext(MetadataRepository.name);
this.exiftool = new ExifTool({
defaultVideosToUTC: true,
backfillTimezones: true,
inferTimezoneFromDatestamps: true,
useMWG: true,
numericTags: [...DefaultReadTaskOptions.numericTags, 'FocalLength'],
/* eslint unicorn/no-array-callback-reference: off, unicorn/no-array-method-this-argument: off */
geoTz: (lat, lon) => geotz.find(lat, lon)[0],
// Enable exiftool LFS to parse metadata for files larger than 2GB.
readArgs: ['-api', 'largefilesupport=1'],
writeArgs: ['-api', 'largefilesupport=1', '-overwrite_original'],
});
}
private exiftool: ExifTool;

async teardown() {
await this.exiftool.end();
await exiftool.end();
}

readTags(path: string): Promise<ImmichTags | null> {
return this.exiftool.read(path).catch((error) => {
this.logger.warn(`Error reading exif data (${path}): ${error}`, error?.stack);
return null;
}) as Promise<ImmichTags | null>;
return exiftool
.read(path, undefined, {
...DefaultReadTaskOptions,

// Enable exiftool LFS to parse metadata for files larger than 2GB.
optionalArgs: ['-api', 'largefilesupport=1'],
defaultVideosToUTC: true,
backfillTimezones: true,
inferTimezoneFromDatestamps: true,
useMWG: true,
numericTags: [...DefaultReadTaskOptions.numericTags, 'FocalLength'],
/* eslint unicorn/no-array-callback-reference: off, unicorn/no-array-method-this-argument: off */
geoTz: (lat, lon) => geotz.find(lat, lon)[0],
})
.catch((error) => {
this.logger.warn(`Error reading exif data (${path}): ${error}`, error?.stack);
return null;
}) as Promise<ImmichTags | null>;
}

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> {
try {
await this.exiftool.write(path, tags);
await exiftool.write(path, tags, ['-overwrite_original']);
} catch (error) {
this.logger.warn(`Error writing exif data (${path}): ${error}`);
}
Expand Down
Loading