Skip to content

Commit cf33ced

Browse files
authored
Gifsicle
1 parent 02acafe commit cf33ced

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

imagemagick/compress-animated-gif.md

+37-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1-
# Compressing an animated GIF with ImageMagick mogrify
1+
# Compressing an animated GIF with gifsicle or ImageMagick mogrify
2+
3+
## Using gifsicle
4+
5+
Tip via Mark Norman Francis [on Twitter](https://twitter.com/cackhanded/status/1423526489623044098):
6+
7+
> Saw your GIF size TIL, and `gifsicle -O3 --colors 48 --lossy` gets it down to 320k. You can tweak the number of colours and loss to get it smaller but that’s when it starts to look worse to my eyes
8+
9+
I installed it using `brew install gifsicle` and ran it like this:
10+
11+
```
12+
/tmp % ls -lah datasette-launch.gif
13+
-rw-r--r--@ 1 simon wheel 3.7M Sep 13 12:52 datasette-launch.gif
14+
/tmp % gifsicle -O3 --colors 48 --lossy -o datasette-launch-smaller.gif datasette-launch.gif
15+
/tmp % ls -lah datasette-launch*
16+
-rw-r--r-- 1 simon wheel 613K Sep 13 12:54 datasette-launch-smaller.gif
17+
-rw-r--r--@ 1 simon wheel 3.7M Sep 13 12:52 datasette-launch.gif
18+
```
19+
20+
Original: 3.7MB file:
21+
22+
![datasette-launch](https://user-images.githubusercontent.com/9599/133148193-89a01999-7fb4-407c-bb02-2bc79a70bd44.gif)
23+
24+
Compressed 613KB file:
25+
26+
![datasette-launch-smaller](https://user-images.githubusercontent.com/9599/133148197-e52db60d-442d-4db3-bf7c-28d5579e3b8a.gif)
27+
28+
The reduced colours there were a bit too much for me, especially for the purple gradient buttons at the end. So I tried this instead:
29+
30+
```
31+
gifsicle -O3 --colors 128 --lossy -o datasette-launch-smaller-2.gif datasette-launch.gif
32+
```
33+
Which gave me a 723KB file which I think looks good enough for my purposes:
34+
35+
![datasette-launch-smaller-2](https://user-images.githubusercontent.com/9599/133148592-b98d5e78-f7fa-49e5-84d3-7c257c0bff17.gif)
36+
37+
## Using ImageMagick mogrify
238

339
Found this tip [on Stack Overflow](https://stackoverflow.com/a/47343340/6083): to reduce the site of an animated GIF, you can use the `mogrify` tool like this:
440

@@ -17,9 +53,3 @@ The result was this 401KB GIF:
1753
The `-fuzz 7%` option is [documented here](https://imagemagick.org/script/command-line-options.php#fuzz) - it treats similar colours as the same colour:
1854

1955
> The distance can be in absolute intensity units or, by appending % as a percentage of the maximum possible intensity (255, 65535, or 4294967295).
20-
21-
## Next time, try gifsicle
22-
23-
Mark Norman Francis [on Twitter](https://twitter.com/cackhanded/status/1423526489623044098):
24-
25-
> Saw your GIF size TIL, and `gifsicle -O3 --colors 48 --lossy` gets it down to 320k. You can tweak the number of colours and loss to get it smaller but that’s when it starts to look worse to my eyes

0 commit comments

Comments
 (0)