Skip to content

Commit dd7e97d

Browse files
Fix gif support
1 parent 0809f9c commit dd7e97d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@types/express": "^4.17.17",
5555
"@types/jasmine": "~5.1.0",
5656
"@types/node": "^18.18.0",
57+
"gifwrap": "^0.10.1",
5758
"husky": "^8.0.3",
5859
"jasmine-core": "~5.1.0",
5960
"jimp": "^0.22.12",

tools/process-images/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ const walk = async dir => {
5757
});
5858
});
5959
} else if (/(gif)$/i.test(file)) {
60-
// Object.entries(SIZES).forEach(([size, [width, height]]) => {
61-
// const distDir = path.join(dir, 'dist', size);
62-
// fs.copyFileSync(fromPath, `${distDir}/${file}`);
63-
// })
60+
Object.entries(SIZES).forEach(([size, [width, height]]) => {
61+
const distDir = path.join(dir, 'dist', size);
62+
GifUtil.read(fromPath).then(gif => {
63+
gif.width = width;
64+
gif.height = height ?? Math.ceil((width * gif.height) / gif.width);
65+
GifUtil.write(path.join(distDir, file), gif.frames, gif)
66+
});
67+
});
6468
}
6569
}
6670
};

0 commit comments

Comments
 (0)