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:
Alex
2022-05-22 06:56:36 -05:00
committed by GitHub
parent ce06af0c9b
commit 55c5027539
11 changed files with 731 additions and 21 deletions

View File

@@ -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) => {