3/30/2024 0 Comments Convert animated gif to webp![]() Npm i sharp p-map fs-extra -save mkdir sourceĭownload some example animated GIFs from the Internet to the source folder inside the project. Initiate a new Node.js project, add and install sharp as a dependency and create a source folder inside the project folder. Create Node.js project and install Sharp # In this post we'll be using Node.js with the excellent and very performant Sharp module to resize animated GIFs and also convert them to WebP. There's lots of ways to resize and convert images, online-converters, dedicated software, 3rd-party services etc. ![]() How to optimize animated GIFs using Node.js # Resizing the images to an optimal size can reduce the file size somewhat, as each frame, tens of them, becomes smaller.Ī couple of percent reduction for each frame quickly adds up to some nice file size savings.Ĭonverting them to more modern file formats, better suited for complex images, like WebP, can reduce the file size by as much as 70-90%, for example a GIF at around 2 MB can be reduced to a 200 KB WebP file.īrowser support for WebP is at over 95%, all modern browsers have supported it for several years. Small file size reductions multiplied millions or billions of times quickly adds up and makes a real difference. They're used very frivolously in Slack, Facebook, Instagram and webpages, causing tens of megabytes to be downloaded millions of times.Ī lot of bandwidth, storage and the electricity to transfer all those images across the world can be reduced,m by making the size of animated GIFs smaller. In this day and age, animated GIFs are often used for memes and animated reactions in messaging platforms and software, often for complex images like photos.Īn animated GIF can contain tens of frames, each is an image taking up several hundred kilobytes, which makes the total size up to several megabytes. Patents have long since expired making the GIF format free to use. GIFs are suitable for simple sharp lined logos with few colors (up to 256), that's where they shine with small file size and simplicity. It supports up to 256 colors and multiple images with delays between them, e.g. The Graphics Interchange Format, or GIF for short, was created in 1987 which is 35 years ago (2022). I'll improve the guide over time to make it more beginner-friendly. The information is best suited for developers that are familiar with node.js and have some experience converting images with the Sharp library already. I have experienced it a couple of times, however it's very rare, just keep the smaller GIF files. It's possible to convert from animated WebP to GIF as well.Ĭonverting animated GIF images to WebP can actually increase the filesize for some images. Then we'll go through how to convert animated GIFs to WebP format to reduce the filesize even more. In this post we'll first resize animated GIFs and WebP files to reduce their filesize somewhat, Resize and convert animated GIF and WebP images using Sharp Resize and convert animated GIF and WebP images using Sharp Skip to main content Robert Michalski Top level navigation menu
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |