Skip to content

Commit

Permalink
fix: take only first page of gif images (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr authored Aug 24, 2024
1 parent e9349ce commit 334f8c5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/token-processor/images/image-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ async function downloadImage(imgUrl: string, tmpPath: string): Promise<string> {
async function transformImage(filePath: string, resize: boolean = false): Promise<string> {
return new Promise((resolve, reject) => {
const outPath = resize ? `${filePath}-small.png` : `${filePath}.png`;
let sharpStream = sharp(filePath, { failOn: 'error' });
let sharpStream = sharp(filePath, {
failOn: 'error',
// TODO: This ignores multi-frame GIF formats to optimize memory and because we're converting
// to PNG anyway. We should support animated images in the future.
pages: 1,
page: 0,
animated: false,
});
if (resize) {
sharpStream = sharpStream.resize({
width: ENV.IMAGE_CACHE_RESIZE_WIDTH,
Expand Down

0 comments on commit 334f8c5

Please sign in to comment.