From 3337c9c145745c255ba53d043f186d7833ae60ef Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Thu, 12 Oct 2023 13:17:03 +0300 Subject: [PATCH] Fix animation not preserved to GIFs in case of AUTO_WEBP --- source/constructs/test/__snapshots__/constructs.test.ts.snap | 2 +- source/image-handler/image-handler.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/constructs/test/__snapshots__/constructs.test.ts.snap b/source/constructs/test/__snapshots__/constructs.test.ts.snap index 06a901a79..a7d8eea5b 100644 --- a/source/constructs/test/__snapshots__/constructs.test.ts.snap +++ b/source/constructs/test/__snapshots__/constructs.test.ts.snap @@ -1150,7 +1150,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = ` "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}", }, - "S3Key": "41ef15a3e6b6b8f15863cb611acea96ea2fc7691ede4f30e039824930c06e3ef.zip", + "S3Key": "0d34710eeb4659e4f7f2b33f1083ac6db94fb42834e94ca30fc5deccd2fb599e.zip", }, "Description": "sih (v6.2.2): Performs image edits and manipulations", "Environment": { diff --git a/source/image-handler/image-handler.ts b/source/image-handler/image-handler.ts index 82cd67937..3d48fefd1 100644 --- a/source/image-handler/image-handler.ts +++ b/source/image-handler/image-handler.ts @@ -75,7 +75,8 @@ export class ImageHandler { */ async process(imageRequestInfo: ImageRequestInfo): Promise { const { originalImage, edits } = imageRequestInfo; - const options = { failOnError: false, animated: imageRequestInfo.contentType === ContentTypes.GIF }; + const supportsAnimation = imageRequestInfo.contentType === ContentTypes.GIF || imageRequestInfo.contentType === ContentTypes.WEBP; + const options = { failOnError: false, animated: supportsAnimation }; let base64EncodedImage = ""; // Apply edits if specified