# PNG to GIF

> Quantize a PNG into GIF's 256-color palette in your browser. An animated PNG keeps every frame, and the measured sample fell from 1,689,485 to 792,677 bytes.

- URL: https://bytescope.dev/en/image-convert/png-to-gif/
- Locale: en · Also: [ja](https://bytescope.dev/ja/image-convert/png-to-gif.md) · [zh-Hant](https://bytescope.dev/zh-Hant/image-convert/png-to-gif.md)
- Runs: Your files never leave your browser — all processing is local.
- Requires: Any modern browser (Chrome, Edge, Firefox, Safari), desktop and mobile.
- Updated: 2026-09-08

## What it does

### What a PNG loses on the way to GIF

Color is the headline loss, and it is not subtle. Every pixel has to land in a palette of at most 256 entries — the slider above sets the ceiling — chosen by the quantizer in `@tools/core-image` and applied with Floyd–Steinberg error diffusion unless you switch the dithering off. A photograph that held tens of thousands of distinct colors is redrawn from those 256: skies and skin tones band, and the diffusion hides the banding by scattering a fine dot pattern across it. Turn dithering off and the dots are replaced by cleaner, blockier bands instead. Flat artwork, pixel art and screenshots with a handful of colors come through almost untouched, because they never needed more than the palette offers.

Transparency is kept, but only one bit of it. Before quantizing, alpha is thresholded at 128: anything more opaque becomes fully opaque, anything less becomes fully invisible, and the partly transparent pixels in between are blended into the background color from the settings before that decision is made. So a soft antialiased edge or a drop shadow turns into a hard staircase, and the converter warns you the moment it finds one. Whenever transparency is present one palette slot is reserved for it, leaving 255 for the picture rather than 256.

Animation, unusually, is not on the loss list. If the browser's `ImageDecoder` reports more than one frame in the file, the converter takes the animated route: it samples colors across the whole animation to build one shared global palette, then writes only the changed region of each frame, keeping the original delays and the loop setting. What GIF has no room for at all is the metadata — there is no ICC profile, no EXIF block and nothing deeper than 8 bits anywhere in the format, so a 16-bit master and a Display P3 tag are gone before the palette question even arises.

### How the file size changed in a measured run

On 2026-09-12, `apps/web/scripts/measurePairs.ts` took a 1280 × 854 PNG produced from the commit-pinned libheif example photo, 1,689,485 bytes after "optimize (oxipng)" — that option is off by default on this tool. Encoding it with 256 colors, Floyd–Steinberg dithering and a white background gave 792,677 bytes — about 53% smaller. A lossless-format output that halves the input sounds contradictory until you remember where the saving came from: the palette reduction threw away almost all of the color information, and GIF then stored what was left exactly. Lowering the palette shrinks the file further and the banding gets worse in step; dithering costs bytes, because the dot pattern is noise and noise resists the LZW compressor. An animated source is a different calculation entirely, since you are paying for every frame.

### When you should not convert PNG to GIF

Do not send a photograph down this route unless something at the other end genuinely accepts nothing else — 256 colors is a visible downgrade at any palette setting, and both WebP and AVIF hold the full range in far fewer bytes. Do not convert a logo whose edges need to stay soft, because the one-bit threshold will leave a jagged outline and, if the artwork was matted against a different color, a fringe around it. Do not convert a 16-bit master, an icon destined for an app pipeline, or anything you will edit again. The route earns its place for pixel art and flat graphics, for a short animation you need in the one format every chat window and forum will autoplay, for email templates that predate everything newer, and for hardware or software whose accepted-format list stopped in the nineties.

Conversion happens entirely in your browser — no upload, no queue, no watermark. Drop in as many files as you like and download them individually or as a zip.

## Limits

Color is the headline loss, and it is not subtle. Every pixel has to land in a palette of at most 256 entries — the slider above sets the ceiling — chosen by the quantizer in `@tools/core-image` and applied with Floyd–Steinberg error diffusion unless you switch the dithering off. A photograph that held tens of thousands of distinct colors is redrawn from those 256: skies and skin tones band, and the diffusion hides the banding by scattering a fine dot pattern across it. Turn dithering off and the dots are replaced by cleaner, blockier bands instead. Flat artwork, pixel art and screenshots with a handful of colors come through almost untouched, because they never needed more than the palette offers.

Transparency is kept, but only one bit of it. Before quantizing, alpha is thresholded at 128: anything more opaque becomes fully opaque, anything less becomes fully invisible, and the partly transparent pixels in between are blended into the background color from the settings before that decision is made. So a soft antialiased edge or a drop shadow turns into a hard staircase, and the converter warns you the moment it finds one. Whenever transparency is present one palette slot is reserved for it, leaving 255 for the picture rather than 256.

Animation, unusually, is not on the loss list. If the browser's `ImageDecoder` reports more than one frame in the file, the converter takes the animated route: it samples colors across the whole animation to build one shared global palette, then writes only the changed region of each frame, keeping the original delays and the loop setting. What GIF has no room for at all is the metadata — there is no ICC profile, no EXIF block and nothing deeper than 8 bits anywhere in the format, so a 16-bit master and a Display P3 tag are gone before the palette question even arises.

## FAQ

### Does an animated PNG stay animated as a GIF?

Yes. When the file has more than one frame the converter builds an animated GIF with the original delays and loop setting, using one shared palette across the animation and writing only the changed part of each frame. A note after the conversion tells you how many frames were kept.

### Why did the transparent edges of my PNG turn jagged?

GIF stores one bit of transparency, so each pixel must end up either fully visible or fully gone. Alpha is thresholded at the halfway point and the partly transparent pixels are blended into the background color first, which is what turns a soft antialiased outline into a staircase.

### Is 256 colors enough for a photograph?

Rarely. A typical photo uses far more distinct colors than the palette can hold, so gradients band and dithering covers the banding with a visible dot texture. It is a real downgrade, not a compression setting — pick GIF only when the destination accepts nothing else.

### Are my images uploaded anywhere?

No. Conversion happens inside your browser using the canvas API and a Web Worker — files never leave your device. There is no upload step, no queue and no file size limit beyond your machine's memory.

### Is EXIF metadata kept in the converted image?

No — and that's a feature. Re-encoding through the canvas strips all metadata: GPS location, camera model, timestamps and color profiles. The output contains pixels only, which is usually what you want before sharing an image publicly.

### Can I convert many images at once?

Yes. Drop or paste any number of files; each is converted in the background with its own progress and download button, and you can grab everything at once as a .zip archive.

### Will converting lower my image quality?

It depends on the target. The converter always decodes to raw pixels and re-encodes, whichever formats are involved, which is also how metadata gets stripped. For lossless targets (PNG, and GIF within its 256-color limit) the pixels stay identical to what was decoded; for JPEG, WebP and AVIF the quality slider controls the trade-off, and converting a file that is already lossy adds one more generation of loss.
