Home FAQ Gifski – A Cross-platform High-quality GIF Encoder
Gifski - A Cross-platform High-quality GIF Encoder

Gifski – A Cross-platform High-quality GIF Encoder

By sk
173 Views

As a content writer, I need to add images in my articles. Sometimes, it is better to add videos or gif images to explain the concept a bit easier. The readers can easily understand the guide much better by watching the output in video or gif format than the text. The other day, I have written about Flameshot, a feature-rich and powerful screenshot tool for Linux. Today, I will show you how to make high quality GIF images either from a video or set of images. Meet Gifski, a cross-platform, open source, command line High-quality GIF encoder based on Pngquant.

For those wondering, pngquant is a command line lossy PNG image compressor. Trust me, pngquant is one of the best PNG compressor that I ever use. It compresses PNG images up-to 70% without losing the original quality and and preserves full alpha transparency. The compressed images are compatible with all web browsers and operating systems. Since Gifski is based on Pngquant, it uses pngquant's features for creating efficient GIF animations. Gifski is capable of creating animated GIFs that use thousands of colors per frame. Gifski is also requires ffmpeg to convert video into PNG images.

Install Gifski On Linux

Make sure you have installed FFMpeg and Pngquant.

FFmpeg is available in the official repositories of most Linux distributions, so you can install it using the default package manager. For installation instructions, refer the following guide.

Pngquant is also available in the default repositories. To install Pngquant on Linux, refer the following guide:

After installing the prerequisites, install Gifski. You can install it using cargo if Rust programming language is installed on your system.

$ cargo install gifski

You can also get it with Linuxbrew package manager.

$ brew install gifski

If you don't want to install cargo or Linuxbrew, download the latest binary executables from releases page and compile and install gifski manually.

Create high-quality GIF animations using Gifski GIF encoder

Go to the location where you have kept the PNG images and run the following command to create GIF animation from the set of images:

$ gifski -o file.gif *.png

Here file.gif is the final output gif animation.

Gifski has also some other additional features, like;

  • Create GIF animation with specific dimension,
  • Show specific number of animations per second,
  • Encode with a specific quality,
  • Encode faster,
  • Encode images exactly in the order given, rather than sorted.

To create GIF animation with specific dimension, for example width=800 and height=400, use the following command:

$ gifski -o file.gif -W 800 -H 400 *.png

You can set how many number of animation frames per second you want in the gif animation. The default value is 20.

For example, to use one animation frame per second, use the following command:

$ gifski -o file.gif --fps 1 *.png

We can encode with specific quality on the scale of 1-100. Obviously, the lower quality may give smaller file and higher quality give bigger seize gif animation.

$ gifski -o file.gif --quality 50 *.png

Gifski will take more time when you encode large number of images. To make the encoding process 3 times faster than usual speed, run:

$ gifski -o file.gif --fast *.png

Please note that it will reduce quality to 10% and create bigger animation file.

To encode images exactly in the order given (rather than sorted), use --nosort option.

$ gifski -o file.gif --nosort *.png

If you don't want to loop the GIF, simple use --once option.

$ gifski -o file.gif --once *.png

Create GIF animation from Video file

Creating animated file from a video is also possible. This is where FFmpeg comes in help. First convert the video into PNG frames first like below.

$ ffmpeg -i video.mp4 frame%04d.png

The above command makes image files namely "frame0001.png", "frame0002.png", "frame0003.png"..., etc., from video.mp4 (%04d makes the frame number) and save them in the current working directory.

As one of the reader Dennisk stated in the comment section, the above command will generate thousands of output frame images depending upon the length of the video file. If you want to limit the number of output images, you can use -t option like below.

$ ffmpeg -i video.mp4 -t 10 frame%04d.png

The -t 10 option instructs ffmpeg to stop after 10 seconds of video.

After converting the image files, simply run the following command to make the animated GIF file.

$ gifski -o file.gif *.png

For more details, refer the help section.

$ gifski -h

Here is the sample animated file created using Gifski.

Animated GIF File created using Gifski

Animated GIF File created using Gifski

As you can see, the quality of the GIF file is really great.

For more details, refer the project's website given below.

Resources:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

1 comment

DennisK September 8, 2018 - 10:15 pm

The ffmpeg instruction shown:
$ ffmpeg -i video.mp4 frame%04d.png

Should be constrained like this:
$ ffmpeg -i video.mp4 -t 10 frame%04d.png

The -t 10 option says stop after 10 seconds of video. Otherwise, you could generate thousands of output frame images. 10 seconds @ 25fps = 250 images.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More