Skip to content

Commit 334f8c5

Browse files
authored
fix: take only first page of gif images (#241)
1 parent e9349ce commit 334f8c5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/token-processor/images/image-cache.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ async function downloadImage(imgUrl: string, tmpPath: string): Promise<string> {
6363
async function transformImage(filePath: string, resize: boolean = false): Promise<string> {
6464
return new Promise((resolve, reject) => {
6565
const outPath = resize ? `${filePath}-small.png` : `${filePath}.png`;
66-
let sharpStream = sharp(filePath, { failOn: 'error' });
66+
let sharpStream = sharp(filePath, {
67+
failOn: 'error',
68+
// TODO: This ignores multi-frame GIF formats to optimize memory and because we're converting
69+
// to PNG anyway. We should support animated images in the future.
70+
pages: 1,
71+
page: 0,
72+
animated: false,
73+
});
6774
if (resize) {
6875
sharpStream = sharpStream.resize({
6976
width: ENV.IMAGE_CACHE_RESIZE_WIDTH,

0 commit comments

Comments
 (0)