mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 09:15:35 +03:00
Add webp thumbnail conversion task to optimize performance of fast scrolling (#172)
* Update readme * Added webp to table and entity * Added cronjob and sharp dependencies * Added conversion of webp every 5 minutes and endpoint will now server webp image if exist
This commit is contained in:
@@ -114,7 +114,11 @@ export class AssetService {
|
||||
public async getAssetThumbnail(assetId: string) {
|
||||
const asset = await this.assetRepository.findOne({ id: assetId });
|
||||
|
||||
return new StreamableFile(createReadStream(asset.resizePath));
|
||||
if (asset.webpPath != '') {
|
||||
return new StreamableFile(createReadStream(asset.webpPath));
|
||||
} else {
|
||||
return new StreamableFile(createReadStream(asset.resizePath));
|
||||
}
|
||||
}
|
||||
|
||||
public async serveFile(authUser: AuthUserDto, query: ServeFileDto, res: Res, headers: any) {
|
||||
@@ -132,7 +136,11 @@ export class AssetService {
|
||||
if (query.isThumb === 'false' || !query.isThumb) {
|
||||
file = createReadStream(asset.originalPath);
|
||||
} else {
|
||||
file = createReadStream(asset.resizePath);
|
||||
if (asset.webpPath != '') {
|
||||
file = createReadStream(asset.webpPath);
|
||||
} else {
|
||||
file = createReadStream(asset.resizePath);
|
||||
}
|
||||
}
|
||||
|
||||
file.on('error', (error) => {
|
||||
|
||||
Reference in New Issue
Block a user