Compare ImageMagick -filter Quality When Shrinking Images
Shrink a PNG with ImageMagick -filter Point, Triangle, Mitchell, Catrom and Lanczos, then compare file size, PSNR, edge ringing and 2x enlargement.
convert big.png -resize 1024x1024 small.png runs without naming a filter. This guide measures what changes when you name one, using the same PNG each time. The test image is not an AI image: it is a 2048×2048 synthetic picture (plasma fractal with lines, circles, 1-pixel stripes and light noise; 8-bit PNG, 7,776,938 bytes). Numbers from real generated images will differ.
[1] List the available filter names.
$ convert -list filterBartlett Blackman Bohman Box Catrom Cosine Cubic Gaussian Hamming Hann Hermite Jinc Kaiser Lagrange Lanczos Lanczos2 Lanczos2Sharp LanczosRadius LanczosSharp Mitchell Parzen Point Quadratic Robidoux RobidouxSharp Sinc SincFast Spline Triangle Welch[2] Put -filter before -resize. Never overwrite the source: save to new names. -strip drops metadata.
$ for f in Point Triangle Mitchell Catrom Lanczos; do> convert orig.png -filter $f -resize 1024x1024 -strip d_${f}_1024.png> convert orig.png -filter $f -resize 512x512 -strip d_${f}_512.png> done[3] Compare file sizes. The same source gives different PNG sizes per filter.
| Filter | 1024×1024 (bytes) | 512×512 (bytes) |
|---|---|---|
Point | 2,018,248 | 539,940 |
Triangle | 1,590,508 | 430,891 |
Mitchell | 1,626,195 | 437,195 |
Catrom | 1,710,749 | 456,538 |
Lanczos | 1,779,810 | 473,999 |
Point is the largest: it picks pixels instead of averaging them, so the synthetic noise survives. Sharper filters tend to give bigger PNGs.
[4] Measure quality with PSNR. A shrunken image has no reference to compare against, so scale each result back to 2048 with the same filter and compare with the original. The number covers shrinking and enlarging together.
$ convert d_Lanczos_1024.png -filter Lanczos -resize 2048x2048 u_Lanczos_1024.png$ compare -metric PSNR orig.png u_Lanczos_1024.png null:24.0585 (0.240585)| Filter | PSNR via 1024 (dB) | PSNR via 512 (dB) |
|---|---|---|
Point | 21.322 | 20.644 |
Triangle | 23.382 | 21.816 |
Mitchell | 23.566 | 21.882 |
Catrom | 23.961 | 22.028 |
Lanczos | 24.059 | 22.088 |
Lanczos scores highest, Point lowest. The whole table sits in the 20 dB range because the test picture is full of noise and 1-pixel stripes; read the order and the gaps, not the absolute values.
[5] Check the default. With no -filter, -resize 1024x1024 produced a file of exactly the same size as the Mitchell result in this version.
$ convert orig.png -resize 1024x1024 -strip d_default_1024.png$ stat -c %s d_default_1024.png1626195Only the byte count was compared. The default in ImageMagick 7 was not tested.
[6] See how Lanczos behaves at an edge. Shrink a 32×1 strip (gray 64 next to gray 192) to 8×1 and read the pixel values.
$ convert -size 16x1 xc:'gray(64)' -size 16x1 xc:'gray(192)' +append -depth 8 edge2.png$ convert edge2.png -filter Lanczos -resize 8x1\! -depth 8 \> -format "%[fx:round(255*p{0,0}.r)] %[fx:round(255*p{1,0}.r)] %[fx:round(255*p{2,0}.r)] %[fx:round(255*p{3,0}.r)] %[fx:round(255*p{4,0}.r)] %[fx:round(255*p{5,0}.r)] %[fx:round(255*p{6,0}.r)] %[fx:round(255*p{7,0}.r)]\n" info:64 64 61 72 183 194 191 192| Filter | The 8 pixel values |
|---|---|
Point | 64 64 64 64 192 192 192 192 |
Mitchell | 64 64 63 79 176 192 192 192 |
Lanczos | 64 64 61 72 183 194 191 192 |
Lanczos dips to 61 (below 64) and rises to 194 (above 192) on either side of the edge. That is ringing: a crisper edge, with a thin dark and bright halo. Mitchell only dips to 63 and transitions more gently. These numbers come from this one strip; how visible ringing is in real photos was not measured.
[7] Try a moiré case. Shrink 64 alternating black and white 1-pixel stripes to 20 pixels.
$ convert st.png -filter Point -resize 20x1\! -depth 8 -format "..." info:255 0 0 255 0 255 0 0 255 0 255 0 0 255 0 255 0 0 255 0$ convert st.png -filter Lanczos -resize 20x1\! -depth 8 -format "..." info:114 130 126 127 127 127 127 127 127 127 127 127 127 127 127 127 127 128 124 140Point mixes black and white irregularly and invents a pattern that was not there. Lanczos averages to about 127 (gray) in the middle. Do not shrink images with 1-pixel stripes using Point. For 8-bit pixel art where edges must stay hard, Point is the right choice.
For converting to WebP and checking metadata afterwards, see Shrink an AI-generated PNG to WebP and check metadata.