mirror of
https://github.com/immich-app/immich.git
synced 2025-01-09 05:16:47 +01:00
a972dd4060
* Fix extraction of samsung motionphoto videos * Refactor binary tag extraction to the repository to consolidate exiftool usage * format * fix linting and swap argument orders * Fix tag name and conditional order * Add unit test * Update server test assets submodule * Remove old motion photo video assets when a new one is extracted * delete first, then write * Include motion photo asset uuid's in the filename If the filenames are not uniquified, then we can't delete old/corrupt ones * Fix formatting and fix/add tests * chore: only use new uuid --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
109 lines
3.9 KiB
TypeScript
109 lines
3.9 KiB
TypeScript
import { AssetResponseDto, LoginResponseDto } from '@app/domain';
|
|
import { AssetController } from '@app/immich';
|
|
import { INestApplication } from '@nestjs/common';
|
|
import { exiftool } from 'exiftool-vendored';
|
|
import * as fs from 'fs';
|
|
import { api } from '../client';
|
|
import {
|
|
IMMICH_TEST_ASSET_PATH,
|
|
IMMICH_TEST_ASSET_TEMP_PATH,
|
|
db,
|
|
itif,
|
|
restoreTempFolder,
|
|
runAllTests,
|
|
testApp,
|
|
} from '../utils';
|
|
|
|
describe(`${AssetController.name} (e2e)`, () => {
|
|
let app: INestApplication;
|
|
let server: any;
|
|
let admin: LoginResponseDto;
|
|
|
|
beforeAll(async () => {
|
|
app = await testApp.create({ jobs: true });
|
|
server = app.getHttpServer();
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
await db.reset();
|
|
await restoreTempFolder();
|
|
await api.authApi.adminSignUp(server);
|
|
admin = await api.authApi.adminLogin(server);
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await testApp.teardown();
|
|
await restoreTempFolder();
|
|
});
|
|
|
|
describe('should strip metadata of', () => {
|
|
let assetWithLocation: AssetResponseDto;
|
|
|
|
beforeEach(async () => {
|
|
const fileContent = await fs.promises.readFile(
|
|
`${IMMICH_TEST_ASSET_PATH}/metadata/gps-position/thompson-springs.jpg`,
|
|
);
|
|
|
|
await api.assetApi.upload(server, admin.accessToken, 'test-asset-id', { content: fileContent });
|
|
|
|
const assets = await api.assetApi.getAllAssets(server, admin.accessToken);
|
|
|
|
expect(assets).toHaveLength(1);
|
|
assetWithLocation = assets[0];
|
|
|
|
expect(assetWithLocation).toEqual(
|
|
expect.objectContaining({
|
|
exifInfo: expect.objectContaining({ latitude: 39.115, longitude: -108.400968333333 }),
|
|
}),
|
|
);
|
|
});
|
|
|
|
itif(runAllTests)('small webp thumbnails', async () => {
|
|
const assetId = assetWithLocation.id;
|
|
|
|
const thumbnail = await api.assetApi.getWebpThumbnail(server, admin.accessToken, assetId);
|
|
|
|
await fs.promises.writeFile(`${IMMICH_TEST_ASSET_TEMP_PATH}/thumbnail.webp`, thumbnail);
|
|
|
|
const exifData = await exiftool.read(`${IMMICH_TEST_ASSET_TEMP_PATH}/thumbnail.webp`);
|
|
|
|
expect(exifData).not.toHaveProperty('GPSLongitude');
|
|
expect(exifData).not.toHaveProperty('GPSLatitude');
|
|
});
|
|
|
|
itif(runAllTests)('large jpeg thumbnails', async () => {
|
|
const assetId = assetWithLocation.id;
|
|
|
|
const thumbnail = await api.assetApi.getJpegThumbnail(server, admin.accessToken, assetId);
|
|
|
|
await fs.promises.writeFile(`${IMMICH_TEST_ASSET_TEMP_PATH}/thumbnail.jpg`, thumbnail);
|
|
|
|
const exifData = await exiftool.read(`${IMMICH_TEST_ASSET_TEMP_PATH}/thumbnail.jpg`);
|
|
|
|
expect(exifData).not.toHaveProperty('GPSLongitude');
|
|
expect(exifData).not.toHaveProperty('GPSLatitude');
|
|
});
|
|
});
|
|
|
|
describe.each([
|
|
// These hashes were created by copying the image files to a Samsung phone,
|
|
// exporting the video from Samsung's stock Gallery app, and hashing them locally.
|
|
// This ensures that immich+exiftool are extracting the videos the same way Samsung does.
|
|
// DO NOT assume immich+exiftool are doing things correctly and just copy whatever hash it gives
|
|
// into the test here.
|
|
['Samsung One UI 5.jpg', 'fr14niqCq6N20HB8rJYEvpsUVtI='],
|
|
['Samsung One UI 6.jpg', 'lT9Uviw/FFJYCjfIxAGPTjzAmmw='],
|
|
['Samsung One UI 6.heic', '/ejgzywvgvzvVhUYVfvkLzFBAF0='],
|
|
])('should extract motionphoto video', (file, checksum) => {
|
|
itif(runAllTests)(`with checksum ${checksum} from ${file}`, async () => {
|
|
const fileContent = await fs.promises.readFile(`${IMMICH_TEST_ASSET_PATH}/formats/motionphoto/${file}`);
|
|
|
|
const response = await api.assetApi.upload(server, admin.accessToken, 'test-asset-id', { content: fileContent });
|
|
const asset = await api.assetApi.get(server, admin.accessToken, response.id);
|
|
expect(asset).toHaveProperty('livePhotoVideoId');
|
|
const video = await api.assetApi.get(server, admin.accessToken, asset.livePhotoVideoId as string);
|
|
|
|
expect(video.checksum).toStrictEqual(checksum);
|
|
});
|
|
});
|
|
});
|