How I Compress GIFs for Medium — Part 1

Arthur Wilton
2 min readApr 13, 2021

Compressing GIFs using open source tools

It’s pronounced GIF

The Graphics Interchange Format or GIF (pronounced with a hard G) is a filetype that stores animated images. In the last few years GIFs have had a resurgence on the internet, with every major social media platform allowing users to upload and share them. There are even GIF specific search engines like Giphy that let you search for and share animated clips, and they have become a vital tool for communication.

A lot of websites have limits on the file size of GIFs that users can upload. In the case of this article we’re focusing on Medium, which has a limit of 5 MB. A smaller file size usually means lower quality, but sometimes you just really need a high quality GIF for your blogpost, whether it’s for aesthetic or functional purposes.

Some websites have created workarounds for this, like Imgur which uses the .gifv format, which is really just an h.264 file wrapped in a different container, which allows for GIFs to be viewed at much higher quality with smaller file sizes. Unfortunately Medium does not make use of this format, so if you want to upload a GIF that retains quality you’ll have to compress it.

I have a few main ways I prefer to compress GIFs, and in part 1 of this series I’m demonstrating using open source tools in the command line.

How To Compress a GIF (for free)

A quick and efficient way of compressing your GIF is to use a combination of imagemagick and gifsicle. I’ve provided a GitHub gist below that I use for my own personal reference, which explains each parameter that you’ll need to edit. This method will require you to have homebrew installed, so if you aren’t familiar with that I recommend checking out my homebrew blog post to help get started.

If you are comfortable using homebrew and working with the command line, simple install imagemagick and gifsicle using:

brew install imagemagickbrew install gifsicle

Next week I’ll be demonstrating how to do the same thing in Adobe Photoshop. Using Photoshop is more user friendly as it uses a GUI and is a popular tool, however it does cost money so I wanted to present the open source option first.

Click here to read part 2.

--

--

Arthur Wilton

Software Developer and Video/Post Production Professional. Recent graduate of Flatiron School.