Why GIF Quality has no effect
Changing GifExportParams.Quality in govips can leave a GIF entirely unchanged. These static GIFs, generated from the same project-owned photograph, separate that legacy field from the controls that actually affect palette encoding.
Inspect the generated outputs
Section titled “Inspect the generated outputs”Every variant starts from the same pixels at 600×400. Compare govips with Quality=10 and Quality=90, then explore the effective parameters and other entries. Parameters, byte sizes, and decoded colour counts come from the actual files. Each image is downloadable.
govips v2.20.0 / libvips 8.17.3

{"height":400,"width":600}ICC: 3048 bytesDownload generated output
{"Bitdepth":8,"Dither":1,"Effort":7,"Quality":90}Decoded RGB colours: 255Download generated output
{"Bitdepth":8,"Dither":1,"Effort":7,"Quality":10}Decoded RGB colours: 255Download generated output
{"Bitdepth":8,"Dither":1,"Effort":7,"Quality":90}Decoded RGB colours: 255Download generated output
{"Bitdepth":4,"Dither":1,"Effort":7,"Quality":90}Decoded RGB colours: 16Download generated output
{"Bitdepth":8,"Dither":0,"Effort":7,"Quality":90}Decoded RGB colours: 255Download generated output
{"Bitdepth":8,"Dither":0.01,"Effort":7,"Quality":90}Decoded RGB colours: 255Download generated output
{"Bitdepth":8,"Dither":1,"Effort":1,"Quality":90}Decoded RGB colours: 255Download generated output
{"Bitdepth":8,"Dither":1,"Effort":10,"Quality":90}Decoded RGB colours: 255Download generated outputsharp 0.35.5 / libvips 8.18.7
This entry has no equivalent of govips’s legacy Quality field; only its supported GIF controls are compared here.

{"width":600,"height":400}ICC: absentDownload generated output
{"colours":256,"dither":1,"effort":7}Decoded RGB colours: 255Download generated output
{"colours":16,"dither":1,"effort":7}Decoded RGB colours: 16Download generated output
{"colours":256,"dither":0,"effort":7}Decoded RGB colours: 255Download generated output
{"colours":256,"dither":1,"effort":1}Decoded RGB colours: 255Download generated output
{"colours":256,"dither":1,"effort":10}Decoded RGB colours: 255Download generated outputpyvips 3.2.0 / libvips 8.17.3
This entry has no equivalent of govips’s legacy Quality field; only its supported GIF controls are compared here.

{"width":600,"height":400}ICC: 3048 bytesDownload generated output
{"bitdepth":8,"dither":1,"effort":7}Decoded RGB colours: 255Download generated output
{"bitdepth":4,"dither":1,"effort":7}Decoded RGB colours: 16Download generated output
{"bitdepth":8,"dither":0,"effort":7}Decoded RGB colours: 255Download generated output
{"bitdepth":8,"dither":1,"effort":1}Decoded RGB colours: 255Download generated output
{"bitdepth":8,"dither":1,"effort":10}Decoded RGB colours: 255Download generated outputvipsCli 8.17.3 / libvips 8.17.3
This entry has no equivalent of govips’s legacy Quality field; only its supported GIF controls are compared here.

{"width":600,"height":400}ICC: 3048 bytesDownload generated output
{"bitdepth":8,"dither":1,"effort":7}Decoded RGB colours: 255Download generated output
{"bitdepth":4,"dither":1,"effort":7}Decoded RGB colours: 16Download generated output
{"bitdepth":8,"dither":0,"effort":7}Decoded RGB colours: 255Download generated output
{"bitdepth":8,"dither":1,"effort":1}Decoded RGB colours: 255Download generated output
{"bitdepth":8,"dither":1,"effort":10}Decoded RGB colours: 255Download generated outputWhy Quality has no effect
Section titled “Why Quality has no effect”Native libvips gifsave has no JPEG-style quality option. The govips field exists for the ImageMagick fallback used with older libvips versions. With govips v2.20.0 / libvips 8.17.3 and its native saver, the two Quality values produce identical GIF bytes and identical decoded pixels in this example.
That establishes the behaviour of this native path, rather than every version or similarly named parameter. Sharp’s GIF options do not expose this legacy govips field; the other three entries do not invent a Quality comparison.
Choose an effective control
Section titled “Choose an effective control”| Goal | Change in this example | Interpretation |
|---|---|---|
| Limit palette size | Change only Bitdepth from 8 to 4; sharp uses colours: 16 |
This sets an upper bound. Input colours and reserved transparency indices affect the actual count; do not expect exactly 16 or 256 colours |
| Inspect dithering | Keep 8 bit / Effort 7 and change only Dither from 1 to 0 | Look at sky gradients, dark areas, and grain. Dithering does not add palette entries or represent a universal quality setting |
| Adjust encoding effort | Keep 8 bit / Dither 1 and change only Effort to 1 or 10 | Higher values allow more quantisation work, without guaranteeing smaller files. This example makes no timing benchmark claim |
Govips v2.20.0 also has a zero-value boundary: Dither=0 is not forwarded to the native saver, so the underlying default still applies. Its pixels therefore match the baseline. The additional Dither=0.01 variant takes effect, but represents low dithering rather than disabling it. A value of 0 is verified to disable dithering in sharp, pyvips, and the CLI. Cards show requested parameters so forwarding differences remain visible. interlace controls progressive loading; this example neither treats it as a quality control nor presents an unverified govips switch.
Complete implementations
Section titled “Complete implementations”All four entries have executed. Govips supplies the reference outputs; use the tabs above to inspect the other entries and their parameters. General pixel equivalence between entries remains unverified.
Run command
go run . photo.jpg output/Complete source
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/davidbyttow/govips/v2/vips"
"github.com/webp-sh/vips-handbook/examples/internal/recipeutil"
)
func main() {
if err := run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run(args []string) error {
if len(args) != 3 {
return fmt.Errorf("usage: main INPUT OUTPUT_DIRECTORY")
}
if err := os.MkdirAll(args[2], 0o755); err != nil {
return err
}
if err := vips.Startup(nil); err != nil {
return err
}
defer vips.Shutdown()
outputs := []recipeutil.Output{}
variants := []struct {
id string
quality, bitdepth, effort int
dither float64
}{
{"baseline", 90, 8, 7, 1}, {"quality-10", 10, 8, 7, 1}, {"quality-90", 90, 8, 7, 1},
{"bitdepth-4", 90, 4, 7, 1}, {"dither-0", 90, 8, 7, 0}, {"dither-near-zero", 90, 8, 7, 0.01}, {"effort-1", 90, 8, 1, 1}, {"effort-10", 90, 8, 10, 1},
}
for _, variant := range variants {
output, err := makeVariant(args[1], args[2], variant.id, variant.quality, variant.bitdepth, variant.effort, variant.dither)
if err != nil {
return err
}
outputs = append(outputs, output)
}
image, err := vips.NewImageFromFile(args[1])
if err != nil {
return err
}
defer image.Close()
if err := image.Resize(600.0/float64(image.Width()), vips.KernelLanczos3); err != nil {
return err
}
output, err := recipeutil.ExportPng(image, args[2], "source.png", map[string]any{"width": 600, "height": 400})
if err != nil {
return err
}
outputs = append(outputs, output)
return recipeutil.WriteResult(args[2], "gif-quality", args[1], outputs)
}
func makeVariant(input, dir, id string, quality, bitdepth, effort int, dither float64) (recipeutil.Output, error) {
image, err := vips.NewImageFromFile(input)
if err != nil {
return recipeutil.Output{}, err
}
defer image.Close()
if err := image.Resize(600.0/float64(image.Width()), vips.KernelLanczos3); err != nil {
return recipeutil.Output{}, err
}
params := vips.NewGifExportParams()
params.Quality = quality
params.Bitdepth = bitdepth
params.Effort = effort
params.Dither = dither
data, meta, err := image.ExportGIF(params)
if err != nil {
return recipeutil.Output{}, err
}
name := id + ".gif"
if err := os.WriteFile(filepath.Join(dir, name), data, 0o644); err != nil {
return recipeutil.Output{}, err
}
return recipeutil.Output{Path: name, Format: "gif", Width: meta.Width, Height: meta.Height, Size: len(data), Parameters: map[string]any{"Quality": quality, "Bitdepth": bitdepth, "Dither": dither, "Effort": effort}}, nil
}Run command
node index.mjs photo.jpg output/Complete source
import sharp from 'sharp';
import { mkdir, writeFile } from 'node:fs/promises';
import path from 'node:path';
const [input, out] = process.argv.slice(2);
if (!input || !out) throw new Error('usage: node index.mjs INPUT OUTPUT_DIRECTORY');
await mkdir(out, { recursive: true });
const outputs = [];
async function save(pipeline, name, parameters) {
await pipeline.toFile(path.join(out, name));
outputs.push({ path: name, parameters });
}
const variants = [
['baseline', 8, 1, 7], ['bitdepth-4', 4, 1, 7], ['dither-0', 8, 0, 7],
['effort-1', 8, 1, 1], ['effort-10', 8, 1, 10],
];
await save(sharp(input).resize(600, 400).png(), 'source.png', { width: 600, height: 400 });
for (const [id, bitdepth, dither, effort] of variants) {
const options = { colours: 2 ** bitdepth, dither, effort };
await save(sharp(input).resize(600, 400).gif(options), `${id}.gif`, options);
}
// sharp GIF options do not expose govips's legacy Quality field.
await writeFile(path.join(out, 'result.json'), JSON.stringify({ recipeId: 'gif-quality', input: path.basename(input), generator: { sharp: sharp.versions.sharp, libvips: sharp.versions.vips }, outputs }, null, 2) + '\n');Run command
python3 main.py photo.jpg output/Complete source
import json
from pathlib import Path
import sys
import pyvips
if len(sys.argv) != 3:
raise SystemExit("usage: python3 main.py INPUT OUTPUT_DIRECTORY")
source, out = Path(sys.argv[1]), Path(sys.argv[2])
out.mkdir(parents=True, exist_ok=True)
outputs = []
def record(name, parameters):
outputs.append({"path": name, "parameters": parameters})
image = pyvips.Image.new_from_file(str(source))
image = image.resize(600 / image.width, kernel="lanczos3")
image.pngsave(str(out / "source.png"))
record("source.png", {"width": 600, "height": 400})
for name, bitdepth, dither, effort in [("baseline", 8, 1, 7), ("bitdepth-4", 4, 1, 7), ("dither-0", 8, 0, 7), ("effort-1", 8, 1, 1), ("effort-10", 8, 1, 10)]:
options = dict(bitdepth=bitdepth, dither=dither, effort=effort)
image.gifsave(str(out / f"{name}.gif"), **options)
record(f"{name}.gif", options)
(out / "result.json").write_text(json.dumps({"recipeId": "gif-quality", "input": source.name, "generator": {"pyvips": pyvips.__version__, "libvips": ".".join(str(pyvips.version(i)) for i in range(3))}, "outputs": outputs}, indent=2) + "\n")Run command
bash run.sh photo.jpg output/Complete source
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -ne 2 ]]; then
echo 'usage: bash run.sh INPUT OUTPUT_DIRECTORY' >&2
exit 2
fi
input="$1"
out="$2"
mkdir -p "$out"
scratch="$(mktemp -d)"
trap 'rm -rf "$scratch"' EXIT
width="$(vipsheader -f width "$input")"
scale="$(python3 - "$width" <<'SCALE'
import sys
print(600 / int(sys.argv[1]))
SCALE
)"
vips resize "$input" "$out/source.png" "$scale" --kernel lanczos3
vips gifsave "$out/source.png" "$out/baseline.gif" --bitdepth 8 --dither 1 --effort 7
vips gifsave "$out/source.png" "$out/bitdepth-4.gif" --bitdepth 4 --dither 1 --effort 7
vips gifsave "$out/source.png" "$out/dither-0.gif" --bitdepth 8 --dither 0 --effort 7
vips gifsave "$out/source.png" "$out/effort-1.gif" --bitdepth 8 --dither 1 --effort 1
vips gifsave "$out/source.png" "$out/effort-10.gif" --bitdepth 8 --dither 1 --effort 10
python3 - "$input" "$out" <<'METADATA'
import json
from pathlib import Path
import subprocess
import sys
source, out = Path(sys.argv[1]), Path(sys.argv[2])
version = subprocess.check_output(["vips", "--version"], text=True).strip().removeprefix("vips-")
outputs = [{'path': 'source.png', 'parameters': {'width': 600, 'height': 400}}, {'path': 'baseline.gif', 'parameters': {'bitdepth': 8, 'dither': 1, 'effort': 7}}, {'path': 'bitdepth-4.gif', 'parameters': {'bitdepth': 4, 'dither': 1, 'effort': 7}}, {'path': 'dither-0.gif', 'parameters': {'bitdepth': 8, 'dither': 0, 'effort': 7}}, {'path': 'effort-1.gif', 'parameters': {'bitdepth': 8, 'dither': 1, 'effort': 1}}, {'path': 'effort-10.gif', 'parameters': {'bitdepth': 8, 'dither': 1, 'effort': 10}}]
(out / "result.json").write_text(json.dumps({"recipeId": "gif-quality", "input": source.name, "generator": {"vipsCli": version, "libvips": version}, "outputs": outputs}, indent=2) + "\n")
METADATAVerify the change
Section titled “Verify the change”- Decode every GIF and confirm 600×400 dimensions, so a size change caused by resizing cannot masquerade as an encoding effect.
- Compare bytes and decoded pixels for the two Quality values. Both comparisons pass as identical here.
- Count decoded RGB colours in the low-bit-depth output and check the upper bound; compare effective Dither values for changed pixels. For govips, also check that 0 is ignored and 0.01 takes effect.
- Choose parameters using both the image and byte size, without predicting a fixed reduction from the Effort value.
Verification boundary and sources
Section titled “Verification boundary and sources”Reviewed on 2026-10-26. Reference: govips v2.20.0 / libvips 8.17.3. Sharp 0.35.5 uses bundled libvips 8.18.7; pyvips 3.2.0 and the CLI use libvips 8.17.3.
This is a photograph-to-static-GIF example. It does not verify the older ImageMagick fallback or animation optimisation. For missing frames and page-height problems, see animation and multipage images.