图片压缩与缩放工具
在浏览器中压缩并缩放图片,减小文件体积、加快上传和页面速度。文件不会离开你的设备。
Why file size matters
Image weight is usually the single biggest factor in how fast a page loads. A 4 MB hero photo will hurt your Largest Contentful Paint far more than any amount of script optimisation.
Practical targets:
| Image type | Target size |
|---|---|
| Thumbnail | under 50 KB |
| Card / grid image | under 150 KB |
| Hero / banner | under 300 KB |
| Full-width photo | under 500 KB |
Which format should you use?
- JPEG — best for photographs. No transparency, small files.
- PNG — best for screenshots, logos and anything needing transparency. Large files.
- WebP — usually 25–35% smaller than JPEG at the same quality, with transparency and animation support. Supported by every current browser.
- AVIF — even smaller, but slower to encode and decode.
The tool converts to JPEG by default. If a PNG is already smaller, it keeps the PNG.
How the compression works
The browser's canvas.toDataURL() re-encodes the image as you draw it. Raising the quality setting keeps more detail and produces a larger file; lowering it discards detail and shrinks the file. The tool shows the before/after size and the percentage saved so you can tune it.
Privacy
Your image is read with FileReader and processed in a canvas element on your machine. Nothing is uploaded. This matters when you are compressing screenshots of private documents or client work.
Tip
Resizing is often more effective than recompressing. Scaling a 4000px photo down to 1600px typically removes 70–80% of the pixels, which reduces the file far more than any quality tweak.
常见问题
Is my image uploaded anywhere?
No. It is read with the FileReader API and processed on a canvas in your browser. Nothing is sent to a server, which matters for screenshots of private documents.
Why is my PNG still large?
PNG is a lossless format, so it does not compress photographic content well. The tool falls back to JPEG when that produces a smaller file.
Should I resize or recompress?
Resize first. Scaling a 4000px photo down to 1600px removes roughly 90% of the pixels, which usually dwarfs what any quality setting can save.
What file sizes should I aim for?
Under 50 KB for thumbnails, 150 KB for grid images, 300 KB for hero banners and 500 KB for full-width photographs.
Does it work on a phone?
Yes. The canvas API is universally supported, though very large images may be slow on older devices.