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

feat (web/server) 360 degrees Web panoramas #3098

Closed
Closed
Show file tree
Hide file tree
Changes from 6 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
4 changes: 4 additions & 0 deletions docker/docker-compose.dev.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file from your PR

Copy link
Contributor Author

@dmitry-brazhenko dmitry-brazhenko Jul 9, 2023

Choose a reason for hiding this comment

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

Why not to keep it?
Once I started running Immich, it was failing as containers just stopped. Adding this restart;always helped me to get started.

btw, I removed it for now, but I can create a separate PR and merge it there

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
- redis
- database
- typesense
restart: always

immich-machine-learning:
container_name: immich_machine_learning
Expand Down Expand Up @@ -67,6 +68,7 @@ services:
- database
- immich-server
- typesense
restart: always

immich-web:
container_name: immich_web
Expand Down Expand Up @@ -102,6 +104,7 @@ services:
driver: none
volumes:
- tsdata:/data
restart: always

redis:
container_name: immich_redis
Expand All @@ -121,6 +124,7 @@ services:
- pgdata:/var/lib/postgresql/data
ports:
- 5432:5432
restart: always

immich-proxy:
container_name: immich_proxy
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/developer/database-migrations.md
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file from your PR

Copy link
Contributor Author

@dmitry-brazhenko dmitry-brazhenko Jul 9, 2023

Choose a reason for hiding this comment

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

Why remove it? I fixed the path?
https://github.com/immich-app/immich/tree/main/server/src/infra/entities

btw, I reverted it, but I can create a separate PR and merge it there

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Database Migrations

After making any changes in the `server/src/infra/database/entities`, a database migration need to run in order to register the changes in the database. Follow the steps below to create a new migration.
After making any changes in the `server/src/infra/entities`, a database migration need to run in order to register the changes in the database. Follow the steps below to create a new migration.

1. Run the command

Expand All @@ -9,6 +9,6 @@ npm run typeorm:migrations:generate ./src/infra/<migration-name>
```

2. Check if the migration file makes sense.
3. Move the migration file to folder `./src/infra/database/migrations` in your code editor.
3. Move the migration file to folder `./src/infra/migrations` in your code editor.

The server will automatically detect `*.ts` file changes and restart. Part of the server start-up process includes running any new migrations, so it will be applied immediately.
18 changes: 15 additions & 3 deletions server/immich-openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4892,6 +4892,9 @@
"checksum": {
"type": "string",
"description": "base64 encoded sha1 hash"
},
"isPanorama": {
"type": "boolean"
}
},
"required": [
Expand All @@ -4911,7 +4914,8 @@
"isArchived",
"mimeType",
"duration",
"checksum"
"checksum",
"isPanorama"
]
},
"AssetTypeEnum": {
Expand Down Expand Up @@ -5099,6 +5103,9 @@
"isFavorite": {
"type": "boolean"
},
"isPanorama": {
"type": "boolean"
},
"isArchived": {
"type": "boolean"
},
Expand All @@ -5117,7 +5124,8 @@
"deviceId",
"fileCreatedAt",
"fileModifiedAt",
"isFavorite"
"isFavorite",
"isPanorama"
]
},
"CreateProfileImageDto": {
Expand Down Expand Up @@ -5513,6 +5521,9 @@
"isFavorite": {
"type": "boolean"
},
"isPanorama": {
"type": "boolean"
},
"isArchived": {
"type": "boolean"
},
Expand All @@ -5530,7 +5541,8 @@
"deviceId",
"fileCreatedAt",
"fileModifiedAt",
"isFavorite"
"isFavorite",
"isPanorama"
]
},
"JobCommand": {
Expand Down
3 changes: 3 additions & 0 deletions server/src/domain/asset/response-dto/asset-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class AssetResponseDto {
people?: PersonResponseDto[];
/**base64 encoded sha1 hash */
checksum!: string;
isPanorama!: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer projectionType field with the enum type

}

export function mapAsset(entity: AssetEntity): AssetResponseDto {
Expand All @@ -58,6 +59,7 @@ export function mapAsset(entity: AssetEntity): AssetResponseDto {
tags: entity.tags?.map(mapTag),
people: entity.faces?.map(mapFace),
checksum: entity.checksum.toString('base64'),
isPanorama: entity.isPanorama,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer projectionType field with the enum type

};
}

Expand Down Expand Up @@ -85,5 +87,6 @@ export function mapAssetWithoutExif(entity: AssetEntity): AssetResponseDto {
tags: entity.tags?.map(mapTag),
people: entity.faces?.map(mapFace),
checksum: entity.checksum.toString('base64'),
isPanorama: entity.isPanorama,
};
}
1 change: 1 addition & 0 deletions server/src/immich/api-v1/asset/asset.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class AssetCore {

type: dto.assetType,
isFavorite: dto.isFavorite,
isPanorama: false,
isArchived: dto.isArchived ?? false,
duration: dto.duration || null,
isVisible: dto.isVisible ?? true,
Expand Down
3 changes: 3 additions & 0 deletions server/src/immich/api-v1/asset/asset.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const _getCreateAssetDto = (): CreateAssetDto => {
createAssetDto.fileCreatedAt = new Date('2022-06-19T23:41:36.910Z');
createAssetDto.fileModifiedAt = new Date('2022-06-19T23:41:36.910Z');
createAssetDto.isFavorite = false;
createAssetDto.isPanorama = false;
createAssetDto.isArchived = false;
createAssetDto.duration = '0:00:00.000000';

Expand All @@ -49,6 +50,7 @@ const _getAsset_1 = () => {
asset_1.fileCreatedAt = new Date('2022-06-19T23:41:36.910Z');
asset_1.updatedAt = new Date('2022-06-19T23:41:36.910Z');
asset_1.isFavorite = false;
asset_1.isPanorama = false;
asset_1.isArchived = false;
asset_1.mimeType = 'image/jpeg';
asset_1.webpPath = '';
Expand All @@ -74,6 +76,7 @@ const _getAsset_2 = () => {
asset_2.fileCreatedAt = new Date('2022-06-19T23:41:36.910Z');
asset_2.updatedAt = new Date('2022-06-19T23:41:36.910Z');
asset_2.isFavorite = false;
asset_2.isPanorama = false;
asset_2.isArchived = false;
asset_2.mimeType = 'image/jpeg';
asset_2.webpPath = '';
Expand Down
3 changes: 3 additions & 0 deletions server/src/infra/entities/asset.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export class AssetEntity {
@Index()
checksum!: Buffer; // sha1 checksum

@Column({ type: 'boolean', default: false })
isPanorama!: boolean;

@Column({ type: 'varchar', nullable: true })
duration!: string | null;

Expand Down
13 changes: 13 additions & 0 deletions server/src/infra/migrations/1688380066207-PanoramaViewer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class PanoramaViewer1688380066207 implements MigrationInterface {
name = '1688379818PanoramaViewer1688380066207';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "assets" ADD "isPanorama" boolean NOT NULL DEFAULT false`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "assets" DROP COLUMN "isPanorama"`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,19 @@ export class MetadataExtractionProcessor {
}
}

// Determine if the image is a panorama
let isPanorama = false;
if (newExif.exifImageHeight && newExif.exifImageWidth) {
const aspectRatio = newExif.exifImageWidth / newExif.exifImageHeight;
isPanorama = aspectRatio >= 2; // This is a standard way to determine if an image is a panorama
}

await this.exifRepository.upsert(newExif, { conflictPaths: ['assetId'] });
await this.assetRepository.save({ id: asset.id, fileCreatedAt: fileCreatedAt || undefined });
await this.assetRepository.save({
id: asset.id,
fileCreatedAt: fileCreatedAt || undefined,
isPanorama: isPanorama,
dmitry-brazhenko marked this conversation as resolved.
Show resolved Hide resolved
});

return true;
}
Expand Down
9 changes: 9 additions & 0 deletions server/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const assetEntityStub = {
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
mimeType: null,
isFavorite: true,
isPanorama: false,
isArchived: false,
duration: null,
isVisible: true,
Expand Down Expand Up @@ -251,6 +252,7 @@ export const assetEntityStub = {
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
mimeType: null,
isFavorite: true,
isPanorama: false,
isArchived: false,
duration: null,
isVisible: true,
Expand Down Expand Up @@ -285,6 +287,7 @@ export const assetEntityStub = {
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
mimeType: null,
isFavorite: true,
isPanorama: false,
isArchived: false,
isReadOnly: false,
duration: null,
Expand Down Expand Up @@ -316,6 +319,7 @@ export const assetEntityStub = {
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
mimeType: null,
isFavorite: true,
isPanorama: false,
isArchived: false,
isReadOnly: false,
duration: null,
Expand Down Expand Up @@ -351,6 +355,7 @@ export const assetEntityStub = {
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
mimeType: null,
isFavorite: true,
isPanorama: false,
isArchived: false,
isReadOnly: false,
duration: null,
Expand Down Expand Up @@ -412,6 +417,7 @@ export const assetEntityStub = {
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
mimeType: null,
isFavorite: false,
isPanorama: false,
isArchived: false,
isReadOnly: false,
duration: null,
Expand Down Expand Up @@ -447,6 +453,7 @@ export const assetEntityStub = {
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
mimeType: null,
isFavorite: true,
isPanorama: false,
isArchived: false,
isReadOnly: false,
duration: null,
Expand Down Expand Up @@ -618,6 +625,7 @@ const assetResponse: AssetResponseDto = {
fileCreatedAt: today,
updatedAt: today,
isFavorite: false,
isPanorama: false,
isArchived: false,
mimeType: 'image/jpeg',
smartInfo: {
Expand Down Expand Up @@ -905,6 +913,7 @@ export const sharedLinkStub = {
createdAt: today,
updatedAt: today,
isFavorite: false,
isPanorama: false,
isArchived: false,
isReadOnly: false,
mimeType: 'image/jpeg',
Expand Down
Loading