Skip to content

Commit

Permalink
fix(server): Return the original path for gif playback (immich-app#2022)
Browse files Browse the repository at this point in the history
* fix(server): Return the original path for gifs.

Usually browser is able to play them directly.

* fix(server): Better place for the condition.

* fix(server): gif viewing works properly.
  • Loading branch information
samip5 authored Mar 22, 2023
1 parent 6239b3b commit 6da5062
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/apps/immich/src/api-v1/asset/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,20 @@ export class AssetService {
/**
* Serve file viewer on the web
*/
if (query.isWeb) {
if (query.isWeb && asset.mimeType != 'image/gif') {
res.set({
'Content-Type': 'image/jpeg',
});

if (!asset.resizePath) {
Logger.error('Error serving IMAGE asset for web', 'ServeFile');
throw new InternalServerErrorException(`Failed to serve image asset for web`, 'ServeFile');
}

if (await processETag(asset.resizePath, res, headers)) {
return;
}

await fs.access(asset.resizePath, constants.R_OK | constants.W_OK);
fileReadStream = createReadStream(asset.resizePath);

Expand All @@ -299,7 +302,7 @@ export class AssetService {
/**
* Serve thumbnail image for both web and mobile app
*/
if (!query.isThumb && allowOriginalFile) {
if ((!query.isThumb && allowOriginalFile) || (query.isWeb && asset.mimeType === 'image/gif')) {
res.set({
'Content-Type': asset.mimeType,
});
Expand Down

0 comments on commit 6da5062

Please sign in to comment.