From 6da50626e1b31eeb57f2de6328c5fc539d686c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Wed, 22 Mar 2023 21:56:00 +0200 Subject: [PATCH] fix(server): Return the original path for gif playback (#2022) * 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. --- server/apps/immich/src/api-v1/asset/asset.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/apps/immich/src/api-v1/asset/asset.service.ts b/server/apps/immich/src/api-v1/asset/asset.service.ts index 76a0ab2327..ebac2fb910 100644 --- a/server/apps/immich/src/api-v1/asset/asset.service.ts +++ b/server/apps/immich/src/api-v1/asset/asset.service.ts @@ -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); @@ -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, });