# gifsicle — animierte GIFs erstellen, optimieren und bearbeiten

> Praxis-Guide zu gifsicle: animierte GIFs an der Kommandozeile erstellen, optimieren, Frames bearbeiten und die Dateigröße verkleinern.

Source: https://www.jpkc.com/db/cheatsheets/images-media/gifsicle/

<!-- PROSE:intro -->
gifsicle ist das Schweizer Taschenmesser für GIFs auf der Kommandozeile: Damit erstellst, optimierst und bearbeitest du animierte GIFs, extrahierst oder löschst einzelne Frames, änderst Timing und Schleifenverhalten und drückst die Dateigröße mit `-O3`, `--colors` und `--lossy` spürbar nach unten. Achte dabei auf zwei Dinge: `--lossy` arbeitet verlustbehaftet, und `--batch` (`-b`) bearbeitet Dateien direkt in-place – das Original wird dabei überschrieben. Lege darum vorab ein Backup an oder schreibe das Ergebnis in eine separate Ausgabedatei.
<!-- PROSE:intro:end -->

## Grundlagen

`gifsicle <input.gif> -o <output.gif>` — GIF lesen und schreiben (einfache Kopie).

```bash
gifsicle animation.gif -o copy.gif
```

`gifsicle -I <input.gif>` — Informationen zu einem GIF anzeigen (Frames, Abmessungen, Farben).

```bash
gifsicle -I animation.gif
```

`gifsicle --info --color-info <input.gif>` — Ausführliche Infos inklusive Farbtabelle und Frame-Daten anzeigen.

```bash
gifsicle --info --color-info animation.gif
```

`gifsicle --explode <input.gif>` — Alle Frames als einzelne GIF-Dateien extrahieren.

```bash
gifsicle --explode animation.gif
```

`gifsicle <input.gif> '#0' -o <output.gif>` — Einen einzelnen Frame extrahieren (0-basiert).

```bash
gifsicle animation.gif '#0' -o first-frame.gif
```

## Optimierung

`gifsicle -O3 <input.gif> -o <output.gif>` — Maximale Optimierung (beste Kompression, am langsamsten).

```bash
gifsicle -O3 animation.gif -o optimized.gif
```

`gifsicle -O2 <input.gif> -o <output.gif>` — Standard-Optimierung (gute Balance aus Tempo und Größe).

```bash
gifsicle -O2 animation.gif -o optimized.gif
```

`gifsicle -O3 --lossy=<n> <input.gif> -o <output.gif>` — Verlustbehaftete Kompression für deutlich kleinere Dateien (n = 30–200, höher = kleiner).

```bash
gifsicle -O3 --lossy=80 animation.gif -o small.gif
```

`gifsicle --colors <n> <input.gif> -o <output.gif>` — Farbpalette reduzieren (2–256 Farben).

```bash
gifsicle --colors 64 animation.gif -o reduced.gif
```

`gifsicle --color-method median-cut --colors <n> <input.gif> -o <output.gif>` — Farben mit dem Median-Cut-Verfahren reduzieren (bessere Qualität).

```bash
gifsicle --color-method median-cut --colors 128 animation.gif -o reduced.gif
```

`gifsicle -O3 --lossy=80 --colors 128 <input.gif> -o <output.gif>` — Verlustbehaftete Kompression mit Farbreduktion für maximale Einsparung kombinieren.

```bash
gifsicle -O3 --lossy=80 --colors 128 animation.gif -o tiny.gif
```

## Größe ändern & zuschneiden

`gifsicle --resize <width>x<height> <input.gif> -o <output.gif>` — Auf exakte Abmessungen skalieren.

```bash
gifsicle --resize 320x240 animation.gif -o small.gif
```

`gifsicle --resize-fit <width>x<height> <input.gif> -o <output.gif>` — In die Abmessungen einpassen (Seitenverhältnis bleibt erhalten).

```bash
gifsicle --resize-fit 400x300 animation.gif -o fitted.gif
```

`gifsicle --resize-width <width> <input.gif> -o <output.gif>` — Auf eine bestimmte Breite skalieren (Höhe automatisch).

```bash
gifsicle --resize-width 320 animation.gif -o resized.gif
```

`gifsicle --resize-height <height> <input.gif> -o <output.gif>` — Auf eine bestimmte Höhe skalieren (Breite automatisch).

```bash
gifsicle --resize-height 200 animation.gif -o resized.gif
```

`gifsicle --scale <factor> <input.gif> -o <output.gif>` — Um einen Faktor skalieren (z. B. 0.5 für halbe Größe).

```bash
gifsicle --scale 0.5 animation.gif -o half.gif
```

`gifsicle --crop <x>,<y>+<width>x<height> <input.gif> -o <output.gif>` — Einen Bereich aus der Animation ausschneiden.

```bash
gifsicle --crop 10,10+200x150 animation.gif -o cropped.gif
```

`gifsicle --crop-transparency <input.gif> -o <output.gif>` — Transparente Ränder rund um das Bild entfernen.

```bash
gifsicle --crop-transparency animation.gif -o trimmed.gif
```

## Frames bearbeiten

`gifsicle <input.gif> '#0-9' -o <output.gif>` — Einen Bereich von Frames extrahieren.

```bash
gifsicle animation.gif '#0-9' -o first10.gif
```

`gifsicle <input.gif> '#0' '#2' '#4' -o <output.gif>` — Bestimmte Frames extrahieren.

```bash
gifsicle animation.gif '#0' '#5' '#10' -o selected.gif
```

`gifsicle --delete '#<n>' <input.gif> -o <output.gif>` — Einen bestimmten Frame löschen.

```bash
gifsicle --delete '#0' animation.gif -o no-first.gif
```

`gifsicle --delete '#<start>-<end>' <input.gif> -o <output.gif>` — Einen Bereich von Frames löschen.

```bash
gifsicle --delete '#5-10' animation.gif -o shorter.gif
```

`gifsicle <a.gif> <b.gif> -o <output.gif>` — Zwei Animationen aneinanderhängen.

```bash
gifsicle intro.gif main.gif -o combined.gif
```

`gifsicle --merge <a.gif> <b.gif> -o <output.gif>` — Frames aus mehreren GIFs zu einer Animation zusammenführen.

```bash
gifsicle --merge part1.gif part2.gif part3.gif -o full.gif
```

`gifsicle --reverse <input.gif> -o <output.gif>` — Frame-Reihenfolge umkehren (rückwärts abspielen).

```bash
gifsicle --reverse animation.gif -o reversed.gif
```

## Timing & Schleifen

`gifsicle --delay <ticks> <input.gif> -o <output.gif>` — Verzögerung für alle Frames festlegen (in 1/100 Sekunde).

```bash
gifsicle --delay 10 animation.gif -o fast.gif
```

`gifsicle '#0' --delay <ticks> '#1-' <input.gif> -o <output.gif>` — Unterschiedliche Verzögerung für ersten Frame und Rest festlegen.

```bash
gifsicle animation.gif '#0' --delay 100 '#1-' --delay 5 -o custom.gif
```

`gifsicle --loopcount=<n> <input.gif> -o <output.gif>` — Schleifenanzahl festlegen (0 = unendlich, 1 = einmal abspielen).

```bash
gifsicle --loopcount=0 animation.gif -o looping.gif
```

`gifsicle --no-loopcount <input.gif> -o <output.gif>` — Schleife entfernen (einmal abspielen und stoppen).

```bash
gifsicle --no-loopcount animation.gif -o once.gif
```

## Transformieren

`gifsicle --rotate-90 <input.gif> -o <output.gif>` — Um 90 Grad im Uhrzeigersinn drehen.

```bash
gifsicle --rotate-90 animation.gif -o rotated.gif
```

`gifsicle --rotate-180 <input.gif> -o <output.gif>` — Um 180 Grad drehen.

```bash
gifsicle --rotate-180 animation.gif -o flipped.gif
```

`gifsicle --rotate-270 <input.gif> -o <output.gif>` — Um 270 Grad drehen (90 Grad gegen den Uhrzeigersinn).

```bash
gifsicle --rotate-270 animation.gif -o rotated.gif
```

`gifsicle --flip-horizontal <input.gif> -o <output.gif>` — Horizontal spiegeln.

```bash
gifsicle --flip-horizontal animation.gif -o mirrored.gif
```

`gifsicle --flip-vertical <input.gif> -o <output.gif>` — Vertikal spiegeln.

```bash
gifsicle --flip-vertical animation.gif -o flipped.gif
```

## Typische Anwendungsfälle

`gifsicle -O3 --lossy=80 --resize-fit 480x360 --colors 128 <input.gif> -o <output.gif>` — Fürs Web optimieren: skalieren, Farben reduzieren, verlustbehaftete Kompression.

```bash
gifsicle -O3 --lossy=80 --resize-fit 480x360 --colors 128 large.gif -o web.gif
```

`gifsicle -b -O3 *.gif` — Alle GIFs stapelweise in-place optimieren (-b = Originale überschreiben).

```bash
gifsicle -b -O3 *.gif
```

`gifsicle <input.gif> '#0-' '#-2-1' -o <output.gif>` — Eine Ping-Pong-Schleife (Boomerang) erzeugen.

```bash
gifsicle animation.gif '#0-' '#-2-1' -o boomerang.gif
```

`convert -delay 10 frames/*.png gif:- | gifsicle -O3 --lossy=80 -o <output.gif>` — Optimiertes GIF aus PNG-Frames erzeugen (ImageMagick-und-gifsicle-Pipeline).

```bash
convert -delay 10 frames/*.png gif:- | gifsicle -O3 --lossy=80 -o animation.gif
```

<!-- PROSE:outro -->
## Fazit

gifsicle gehört in jede Werkzeugkiste, wenn animierte GIFs klein und schnell sein sollen – für den Alltag reichen meist `-O3`, `--colors` und `--lossy` in Kombination mit `--resize-fit`. Behalte aber im Kopf, dass `--lossy` Bildinformationen unwiderruflich verwirft und sich die Qualität bei hohen Werten sichtbar verschlechtert. Besonders heikel ist `--batch` (`-b`): Es schreibt das Ergebnis direkt in die Originaldatei zurück, ein Fehlversuch lässt sich dann nicht mehr rückgängig machen. Arbeite im Zweifel immer mit einer separaten Ausgabedatei (`-o`) oder einem Backup und prüfe das Ergebnis, bevor du Originale ersetzt.

## Weiterführende Links

- [gifsicle – offizielle Projektseite (LCDF)](https://www.lcdf.org/gifsicle/) – Download, Dokumentation und Hintergründe zum Werkzeug
- [gifsicle-Handbuch (man page)](https://www.lcdf.org/gifsicle/man.html) – vollständige Referenz aller Optionen und Frame-Selektoren
<!-- PROSE:outro:end -->

## Verwandte Kommandos

- [convert](https://www.jpkc.com/db/cheatsheets/images-media/convert/) – ImageMagick-Werkzeug zum Konvertieren und Bearbeiten von Bildern
- [optipng](https://www.jpkc.com/db/cheatsheets/images-media/optipng/) – verlustfreier PNG-Optimierer
- [pngquant](https://www.jpkc.com/db/cheatsheets/images-media/pngquant/) – verlustbehaftete PNG-Kompression mit reduzierter Palette

