Prompt
How do I avoid blurry thumbnails after resizing images?
Latest observation
Blurry thumbnails usually happen because the image is being resized in a way that doesn’t preserve sharp edges or because the source image is too small. Here are the main ways to avoid it:
1) Start with a high-quality source image
- Use the original, full-resolution image if possible.
- Avoid enlarging small images to make thumbnails.
- A thumbnail should generally be a downscale, not an upscale.
2) Use a good resizing algorithm
Different libraries offer different resampling methods. For downscaling, use a high-quality filter such as:
- Lanczos (often best for thumbnails)
- Bicubic
- Area/Box for some downscaling cases
Examples:
- Pillow (Python):
Image.Resampling.LANCZOS - ImageMagick:
-filter Lanczos - Sharp (Node.js): default is usually good, but specifying a sharp kernel can help
3) Resize in one step, not repeatedly
If you resize an image multiple times (e.g., 4000 → 1000 → 300 → 100), quality drops each time.
Instead, resize directly from the original to the final thumbnail size.
4) Keep the aspect ratio
Stretching or squashing can make thumbnails look bad.
Use crop/fit methods that preserve proportions:
containif you want the whole image visiblecoverif you want a fixed-size thumbnail and don’t mind cropping
5) Save with enough quality
If you output to JPEG/WebP/AVIF:
- Use a reasonable quality setting
- Avoid aggressive compression that adds blur or artifacts
For JPEG, something like 80–90 is often a good balance.
6) Sharpen slightly after resizing
A small amount of sharpening can improve perceived crispness, especially after downscaling.
Be careful not to overdo it.
7) For text or UI images, use special handling
Images with text, screenshots, or logos are more sensitive to blur:
- Prefer lossless formats like PNG or WebP lossless when possible
- Use sharper resizing and maybe a slight sharpen pass
8) Watch out for CSS scaling
If you’re displaying thumbnails on a website:
- Make sure the browser isn’t stretching a small thumbnail to a larger display size with CSS
- Set the rendered size close to the actual image dimensions
If you want, I can give you:
- a Python/Pillow example
- a JavaScript/Node sharp example
- or help troubleshoot a specific thumbnail pipeline.