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.
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.
Grundlagen
gifsicle <input.gif> -o <output.gif> — GIF lesen und schreiben (einfache Kopie).
gifsicle animation.gif -o copy.gifgifsicle -I <input.gif> — Informationen zu einem GIF anzeigen (Frames, Abmessungen, Farben).
gifsicle -I animation.gifgifsicle --info --color-info <input.gif> — Ausführliche Infos inklusive Farbtabelle und Frame-Daten anzeigen.
gifsicle --info --color-info animation.gifgifsicle --explode <input.gif> — Alle Frames als einzelne GIF-Dateien extrahieren.
gifsicle --explode animation.gifgifsicle <input.gif> '#0' -o <output.gif> — Einen einzelnen Frame extrahieren (0-basiert).
gifsicle animation.gif '#0' -o first-frame.gifOptimierung
gifsicle -O3 <input.gif> -o <output.gif> — Maximale Optimierung (beste Kompression, am langsamsten).
gifsicle -O3 animation.gif -o optimized.gifgifsicle -O2 <input.gif> -o <output.gif> — Standard-Optimierung (gute Balance aus Tempo und Größe).
gifsicle -O2 animation.gif -o optimized.gifgifsicle -O3 --lossy=<n> <input.gif> -o <output.gif> — Verlustbehaftete Kompression für deutlich kleinere Dateien (n = 30–200, höher = kleiner).
gifsicle -O3 --lossy=80 animation.gif -o small.gifgifsicle --colors <n> <input.gif> -o <output.gif> — Farbpalette reduzieren (2–256 Farben).
gifsicle --colors 64 animation.gif -o reduced.gifgifsicle --color-method median-cut --colors <n> <input.gif> -o <output.gif> — Farben mit dem Median-Cut-Verfahren reduzieren (bessere Qualität).
gifsicle --color-method median-cut --colors 128 animation.gif -o reduced.gifgifsicle -O3 --lossy=80 --colors 128 <input.gif> -o <output.gif> — Verlustbehaftete Kompression mit Farbreduktion für maximale Einsparung kombinieren.
gifsicle -O3 --lossy=80 --colors 128 animation.gif -o tiny.gifGröße ändern & zuschneiden
gifsicle --resize <width>x<height> <input.gif> -o <output.gif> — Auf exakte Abmessungen skalieren.
gifsicle --resize 320x240 animation.gif -o small.gifgifsicle --resize-fit <width>x<height> <input.gif> -o <output.gif> — In die Abmessungen einpassen (Seitenverhältnis bleibt erhalten).
gifsicle --resize-fit 400x300 animation.gif -o fitted.gifgifsicle --resize-width <width> <input.gif> -o <output.gif> — Auf eine bestimmte Breite skalieren (Höhe automatisch).
gifsicle --resize-width 320 animation.gif -o resized.gifgifsicle --resize-height <height> <input.gif> -o <output.gif> — Auf eine bestimmte Höhe skalieren (Breite automatisch).
gifsicle --resize-height 200 animation.gif -o resized.gifgifsicle --scale <factor> <input.gif> -o <output.gif> — Um einen Faktor skalieren (z. B. 0.5 für halbe Größe).
gifsicle --scale 0.5 animation.gif -o half.gifgifsicle --crop <x>,<y>+<width>x<height> <input.gif> -o <output.gif> — Einen Bereich aus der Animation ausschneiden.
gifsicle --crop 10,10+200x150 animation.gif -o cropped.gifgifsicle --crop-transparency <input.gif> -o <output.gif> — Transparente Ränder rund um das Bild entfernen.
gifsicle --crop-transparency animation.gif -o trimmed.gifFrames bearbeiten
gifsicle <input.gif> '#0-9' -o <output.gif> — Einen Bereich von Frames extrahieren.
gifsicle animation.gif '#0-9' -o first10.gifgifsicle <input.gif> '#0' '#2' '#4' -o <output.gif> — Bestimmte Frames extrahieren.
gifsicle animation.gif '#0' '#5' '#10' -o selected.gifgifsicle --delete '#<n>' <input.gif> -o <output.gif> — Einen bestimmten Frame löschen.
gifsicle --delete '#0' animation.gif -o no-first.gifgifsicle --delete '#<start>-<end>' <input.gif> -o <output.gif> — Einen Bereich von Frames löschen.
gifsicle --delete '#5-10' animation.gif -o shorter.gifgifsicle <a.gif> <b.gif> -o <output.gif> — Zwei Animationen aneinanderhängen.
gifsicle intro.gif main.gif -o combined.gifgifsicle --merge <a.gif> <b.gif> -o <output.gif> — Frames aus mehreren GIFs zu einer Animation zusammenführen.
gifsicle --merge part1.gif part2.gif part3.gif -o full.gifgifsicle --reverse <input.gif> -o <output.gif> — Frame-Reihenfolge umkehren (rückwärts abspielen).
gifsicle --reverse animation.gif -o reversed.gifTiming & Schleifen
gifsicle --delay <ticks> <input.gif> -o <output.gif> — Verzögerung für alle Frames festlegen (in 1/100 Sekunde).
gifsicle --delay 10 animation.gif -o fast.gifgifsicle '#0' --delay <ticks> '#1-' <input.gif> -o <output.gif> — Unterschiedliche Verzögerung für ersten Frame und Rest festlegen.
gifsicle animation.gif '#0' --delay 100 '#1-' --delay 5 -o custom.gifgifsicle --loopcount=<n> <input.gif> -o <output.gif> — Schleifenanzahl festlegen (0 = unendlich, 1 = einmal abspielen).
gifsicle --loopcount=0 animation.gif -o looping.gifgifsicle --no-loopcount <input.gif> -o <output.gif> — Schleife entfernen (einmal abspielen und stoppen).
gifsicle --no-loopcount animation.gif -o once.gifTransformieren
gifsicle --rotate-90 <input.gif> -o <output.gif> — Um 90 Grad im Uhrzeigersinn drehen.
gifsicle --rotate-90 animation.gif -o rotated.gifgifsicle --rotate-180 <input.gif> -o <output.gif> — Um 180 Grad drehen.
gifsicle --rotate-180 animation.gif -o flipped.gifgifsicle --rotate-270 <input.gif> -o <output.gif> — Um 270 Grad drehen (90 Grad gegen den Uhrzeigersinn).
gifsicle --rotate-270 animation.gif -o rotated.gifgifsicle --flip-horizontal <input.gif> -o <output.gif> — Horizontal spiegeln.
gifsicle --flip-horizontal animation.gif -o mirrored.gifgifsicle --flip-vertical <input.gif> -o <output.gif> — Vertikal spiegeln.
gifsicle --flip-vertical animation.gif -o flipped.gifTypische 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.
gifsicle -O3 --lossy=80 --resize-fit 480x360 --colors 128 large.gif -o web.gifgifsicle -b -O3 *.gif — Alle GIFs stapelweise in-place optimieren (-b = Originale überschreiben).
gifsicle -b -O3 *.gifgifsicle <input.gif> '#0-' '#-2-1' -o <output.gif> — Eine Ping-Pong-Schleife (Boomerang) erzeugen.
gifsicle animation.gif '#0-' '#-2-1' -o boomerang.gifconvert -delay 10 frames/*.png gif:- | gifsicle -O3 --lossy=80 -o <output.gif> — Optimiertes GIF aus PNG-Frames erzeugen (ImageMagick-und-gifsicle-Pipeline).
convert -delay 10 frames/*.png gif:- | gifsicle -O3 --lossy=80 -o animation.gif 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) – Download, Dokumentation und Hintergründe zum Werkzeug
- gifsicle-Handbuch (man page) – vollständige Referenz aller Optionen und Frame-Selektoren