Convert PNG to GIF: 4 Methods (ffmpeg, ImageMagick, GIMP, Pillow)
PNG is the right format for most static images. GIF is the right format when you need animation, strict color-palette icons, or compatibility with systems that predate modern image formats. The most common reason to convert is exactly that: you have a sequence of PNG frames and want to assemble them into an animated GIF, or you have a logo/icon that needs to work in an older environment capped at 256 colors.
Before you start, understand the tradeoff: GIF's 256-color limit means it will lossy-convert any PNG with more than 256 unique colors. Gradients, photographs, and complex illustrations will look noticeably worse as GIFs. Simple icons, line art, and low-color logos convert cleanly.
Methods at a Glance
| Tool | Version | OS | Batch Support | Animated GIF | License |
|---|---|---|---|---|---|
| ffmpeg | 7.0 | Windows, Mac, Linux | Yes (shell loop) | Yes (image sequence) | LGPL 2.1+ / GPL v2+ |
| ImageMagick | 7.1 | Windows, Mac, Linux | Yes (native) | Yes (-delay flag) | Apache 2.0 |
| GIMP | 2.10 | Windows, Mac, Linux | Script-Fu | Yes (layers as frames) | GPL v3 |
| Python Pillow | 10.4 | Windows, Mac, Linux | Yes (script) | Yes (save_all) | HPND |
Need a quick one-off conversion without installing anything? Pixotter's converter runs in your browser and handles PNG → GIF with no upload required. For anything involving sequences or batch processing, keep reading.
Need to convert image formats?
Pixotter converts PNG, JPG, WebP, and AVIF instantly in your browser — free, no upload needed.
Try it yourself
Convert between any image format instantly — free, instant, no signup. Your images never leave your browser.
When PNG → GIF Makes Sense (and When It Doesn't)
Good reasons to convert:
- Animation — You have a sequence of PNG frames (from a screen recording, sprite export, or rendered image sequence) and want to deliver them as a single animated GIF. This is by far the most common use case.
- Legacy compatibility — A CMS, email client, or platform only accepts GIF. Some older HTML email templates still rely on animated GIFs for visual motion.
- Simple icons with limited colors — A logo or icon with 8-16 colors will convert to GIF without visible degradation, and the resulting file may be small enough to justify it.
Reasons to reconsider:
- Your PNG has gradients or photographs. GIF's 256-color palette will produce banding — discrete color steps where smooth transitions were. See the PNG format guide for what PNG is actually optimized for.
- You want animation with good quality. Animated GIF compresses poorly compared to modern alternatives. If your target platform supports it, WebP animation or a short MP4 will be a fraction of the file size at the same visual quality.
- File size is the concern. Converting PNG → GIF will not reliably reduce file size. For compression, compress your images with Pixotter instead.
For a deeper look at what GIF actually is and when it excels, see What is a GIF?
PNG vs GIF: Format Comparison
| Feature | PNG | GIF |
|---|---|---|
| Color depth | 24-bit (16.7M colors) | 8-bit (256 colors max) |
| Transparency | Full alpha channel | 1-bit (on/off, no partial) |
| Animation | No (APNG is separate) | Yes (multi-frame) |
| Compression | DEFLATE (lossless) | LZW (lossless per frame) |
| File size (photos) | Smaller | Larger (after dithering) |
| File size (simple icons) | Comparable | Often smaller |
| Browser support | Universal | Universal |
Method 1: ffmpeg 7.0
ffmpeg is the most reliable tool for image sequence → animated GIF pipelines. It gives precise control over frame rate, palette generation, and dithering. License: LGPL 2.1+ for the libraries, GPL v2+ if you compile with GPL components.
Download from ffmpeg.org/download.html. On macOS: brew install ffmpeg. On Ubuntu/Debian: sudo apt install ffmpeg.
Convert a single PNG to GIF
ffmpeg -i input.png output.gif
This works, but ffmpeg's default palette for a single-image GIF is often suboptimal. For better color accuracy:
ffmpeg -i input.png -vf "palettegen" palette.png
ffmpeg -i input.png -i palette.png -filter_complex "paletteuse" output.gif
The two-pass approach generates an optimized palette from the source image, then applies it. Noticeable improvement on images with subtle color gradients.
Create an animated GIF from a PNG sequence
If your frames are named frame_001.png, frame_002.png, etc.:
ffmpeg -framerate 10 -i frame_%03d.png -vf "palettegen" palette.png
ffmpeg -framerate 10 -i frame_%03d.png -i palette.png -filter_complex "paletteuse=dither=bayer:bayer_scale=5" output.gif
-framerate 10sets 10 frames per second. Adjust to taste.dither=bayer:bayer_scale=5applies Bayer dithering — a good default for most content. Trydither=sierra2_4afor photographic sequences.- For a looping GIF, ffmpeg animated GIFs loop by default.
Batch convert a folder of PNGs to individual GIFs
# Linux/macOS
for f in *.png; do ffmpeg -i "$f" "${f%.png}.gif"; done
# Windows (Command Prompt)
for %f in (*.png) do ffmpeg -i "%f" "%~nf.gif"
Method 2: ImageMagick 7.1
ImageMagick handles both single conversions and animated GIF creation natively, without shell scripting tricks for batches. License: Apache 2.0.
Install from imagemagick.org/script/download.php. On macOS: brew install imagemagick. On Ubuntu: sudo apt install imagemagick.
Convert a single PNG to GIF
magick input.png output.gif
With dithering control:
magick input.png -dither Riemersma -remap output.gif
-dither Riemersma applies error-diffusion dithering, which generally produces smoother gradients than the default.
Create an animated GIF from a PNG sequence
magick -delay 10 -loop 0 frame_*.png output.gif
-delay 10sets the frame delay in centiseconds (10 = 100ms = 10fps).-loop 0means loop infinitely. Use-loop 1to play once.frame_*.pngglob-expands in order — make sure your files are named with zero-padded numbers (frame_001.png, notframe_1.png) to get the right sort order.
Batch convert with a single command
magick mogrify -format gif *.png
mogrify modifies files in place and writes filename.gif alongside each filename.png. It does not delete the originals.
For more on reducing GIF file sizes after conversion, see the GIF compression guide.
Method 3: GIMP 2.10
GIMP is the right choice when you want a GUI, need to manually adjust frames, or want to preview the animation before exporting. License: GPL v3.
Download from gimp.org/downloads/.
Convert a single PNG to GIF
- Open GIMP → File → Open → select your PNG
- File → Export As
- Set the filename to
output.gif - Click Export
- In the GIF dialog: set the comment, check Interlace if needed, click Export
GIMP will warn you if the image has more than 256 colors and ask you to convert the color mode. Go to Image → Mode → Indexed → choose the maximum number of colors (up to 256) and a dithering method before exporting.
Create an animated GIF from PNG frames
- Open the first PNG frame: File → Open
- Add each additional frame: File → Open As Layers → select all remaining PNGs in order
- Each layer is one animation frame. Name layers with delay info:
frame (100ms)sets that frame to 100ms duration - Filters → Animation → Playback to preview
- File → Export As →
output.gif→ check As Animation → set loop count → Export
GIMP's animation export gives you frame-level control that command-line tools require more flags to replicate. It is slower for large batches but excellent for fine-tuning a specific GIF.
Method 4: Python Pillow 10.4
Pillow is the right choice for scripted, conditional, or integrated batch workflows — when you need to convert images programmatically as part of a larger process. License: HPND (permissive, compatible with commercial projects).
Install: pip install Pillow==10.4.0
Convert a single PNG to GIF
from PIL import Image
img = Image.open("input.png")
# GIF requires palette mode (P) — convert with dithering
img_gif = img.convert("P", palette=Image.ADAPTIVE, colors=256)
img_gif.save("output.gif")
Image.ADAPTIVE builds a palette optimized for the image's actual colors. This produces better results than the default web palette for most content.
Create an animated GIF from PNG frames
from PIL import Image
frames = []
frame_paths = sorted(["frame_001.png", "frame_002.png", "frame_003.png"])
for path in frame_paths:
frame = Image.open(path).convert("P", palette=Image.ADAPTIVE, colors=256)
frames.append(frame)
frames[0].save(
"output.gif",
save_all=True,
append_images=frames[1:],
duration=100, # ms per frame
loop=0 # 0 = loop forever
)
For production use, build the frame list from a directory rather than hardcoding paths:
import os
from PIL import Image
frame_dir = "frames/"
frame_paths = sorted(
os.path.join(frame_dir, f)
for f in os.listdir(frame_dir)
if f.endswith(".png")
)
frames = [Image.open(p).convert("P", palette=Image.ADAPTIVE, colors=256) for p in frame_paths]
frames[0].save(
"output.gif",
save_all=True,
append_images=frames[1:],
duration=100,
loop=0
)
For building an image sequence into a GIF from scratch, see the full create GIF from images guide.
Tips for Best Quality
Use two-pass palette generation (ffmpeg). A palette built from all frames of an animation produces far better color accuracy than a per-frame palette, especially for sequences with consistent color schemes.
Choose the right dithering algorithm. Dithering simulates more colors than the 256-color palette allows by mixing adjacent pixels:
| Algorithm | Best for | Tools |
|---|---|---|
| Bayer | Hard edges, pixel art, icons | ffmpeg, ImageMagick |
| Sierra2_4a | Photographic sequences | ffmpeg |
| Floyd-Steinberg | General purpose | ImageMagick, Pillow |
| Riemersma | Smooth gradients | ImageMagick |
Understand transparency differences. PNG supports full alpha transparency (0–255 per pixel). GIF supports only 1-bit transparency — a pixel is either fully transparent or fully opaque. If your PNG has soft edges or semi-transparent areas (common in logos and icons), those will become hard edges in the GIF. Plan for this before converting.
Match color count to image complexity. Not every image needs all 256 palette slots. A simple icon with 8 colors converted with colors=8 in Pillow (or -colors 8 in ImageMagick) produces a smaller file with no visible quality loss.
Reduce frame rate for smaller animated GIFs. 10fps is often indistinguishable from 25fps for non-video content and roughly halves the file size. Start at 10fps and increase only if the animation looks choppy.
For the reverse operation — converting GIF back to PNG — see how to convert GIF to PNG.
FAQ
Does converting PNG to GIF reduce image quality? Yes, if your PNG has more than 256 unique colors. GIF's palette is capped at 256 colors, so conversion requires mapping (and dithering) the full color range into a limited set. Simple icons and line art with few colors convert without visible degradation.
Can I convert a static PNG to an animated GIF? Not from a single static image — animation requires multiple frames. You can duplicate a single PNG multiple times to create a trivially looping GIF, but that just produces a larger file that appears identical to a static one. For real animation, you need a sequence of PNGs.
What frame rate should I use for animated GIFs?
10fps works well for most non-video content. For video-derived sequences, 15–25fps looks smoother but increases file size proportionally. GIF frame delays are specified in centiseconds (hundredths of a second), so 10fps = -delay 10 in ImageMagick or duration=100 in Pillow.
Why does my converted GIF have visible color banding? Banding happens when a smooth gradient is forced into 256 discrete color steps without dithering. Enable dithering in whichever tool you use (see the dithering table above). If banding persists, the source PNG has too many unique colors for GIF to represent faithfully — this is a format limitation, not a tool limitation.
Is GIF smaller than PNG? It depends on the image. GIFs are often smaller for simple icons and line art with few colors. For photographs, complex illustrations, and anything with gradients, PNG is usually smaller. For reducing file size, compress your images directly rather than changing formats.
Does GIF support transparency like PNG does? No. GIF supports only 1-bit transparency — each pixel is fully transparent or fully opaque. PNG supports full alpha transparency with 256 levels of opacity per pixel. If your PNG uses soft or semi-transparent edges, they will become hard edges in the GIF.
What's the difference between GIF and animated WebP? Animated WebP supports full color depth (not capped at 256), full alpha transparency, and compresses dramatically better than GIF — typically 25–35% smaller for the same content. If your target platform supports WebP, it is strictly better than GIF for animation. GIF wins only on universal legacy compatibility.
How do I convert a GIF back to PNG after converting? The same tools work in reverse. See how to convert GIF to PNG for the exact commands. Note that you will not recover quality lost during the original PNG → GIF conversion — lossless round-tripping through GIF is only possible for images that already fit within the 256-color constraint.
Can I convert a GIF to JPEG instead of PNG? Yes — JPEG is better than PNG for photographic content where you can tolerate minor compression artifacts. See how to convert GIF to JPG for the methods. JPEG does not support transparency, so frames with transparent backgrounds will need a fill color before conversion.
Try it yourself
Ready to convert formats? Drop your image and get results in seconds — free, instant, no signup. Your images never leave your browser.