
Compressing Images: Step-by-Step Tutorial

Michael Foster
Content Creator & Tutorial Expert
Large images slow down websites and fill up storage. This step-by-step tutorial explains image compression — lossy vs. lossless, quality vs. file size — and shows how to compress images using free and paid tools.
Table of Contents
- Why Compress Images?
- Understanding Compression Types
- Method 1: Compress Images Online
- Method 2: Compress Images with Desktop Software
- Method 3: Compress Images with Command-Line Tools
- Compression Strategies for Different Use Cases
- Common Compression Problems
- Best Practices for Image Compression
- Conclusion
Image compression reduces file size while maintaining acceptable visual quality. This is essential for web performance, email attachments, and storage management. This step-by-step tutorial explains how image compression works and shows you how to compress images effectively using free and paid tools.
Why Compress Images?
Large image files cause several problems:
- Slow websites: Images are often the largest elements on a web page. Large images slow page load times, which hurts user experience and SEO.
- Email attachment limits: Email servers limit attachment sizes (typically 10–25 MB). Large images may be rejected or take too long to upload.
- Storage costs: Large images consume more storage on your device, in the cloud, and on servers.
- Mobile data usage: Large images consume more mobile data, which matters for users on limited plans.
- Upload times: Uploading large images takes longer, which is frustrating for users and inefficient for workflows.
The Quality vs. File Size Tradeoff
Image compression is always a tradeoff between quality and file size. The goal is to find the sweet spot where the file is small enough for your needs but the quality is still acceptable. Different use cases require different balances:
- Web thumbnails: Small file size is critical; quality can be moderate.
- Web content images: Balance of quality and size.
- Web hero images: Higher quality needed; size is less critical (but still matters).
- Email: Small file size is important; quality can be moderate.
- Print: Quality is critical; file size is not a concern.
- Archival: Quality is critical; use lossless compression.
Understanding Compression Types
Lossy Compression
Lossy compression reduces file size by permanently discarding some image data. The compressed image is not identical to the original — some detail is lost. However, at appropriate quality settings, the difference is often imperceptible to the human eye.
- Formats: JPG, WEBP (lossy mode), AVIF (lossy mode).
- Best for: Photographs and images with many colors and gradients.
- Pros: Much smaller file sizes (often 5–20x smaller than uncompressed).
- Cons: Quality loss is permanent. Each re-save degrades quality further ("generation loss").
Lossless Compression
Lossless compression reduces file size without discarding any data. The compressed image is identical to the original when decompressed. File size reduction is more modest than with lossy compression.
- Formats: PNG, WEBP (lossless mode), AVIF (lossless mode), TIFF (with lossless compression).
- Best for: Graphics, screenshots, images with text, and images requiring perfect quality.
- Pros: No quality loss. Can be re-saved without degradation.
- Cons: Larger file sizes than lossy compression. Less effective for photographs.
Method 1: Compress Images Online
Online compression tools are the fastest option for most users.
Step-by-Step: Compressing an Image Online
- Choose a compression tool: Look for one that offers adjustable quality and supports your image format. VisualDocs provides a free image compressor.
- Upload your image: Drag and drop the file or browse to select it.
- Choose compression settings:
- Quality: For lossy formats (JPG, WEBP), choose quality level (1–100). 80–85 is a good starting point.
- Format: Some tools let you convert to a more efficient format (e.g., PNG to WEBP) during compression.
- Click compress: The tool processes the image.
- Compare results: Many tools show a before/after comparison and the file size reduction percentage.
- Download the compressed image: Save it to your device.
Tips for Online Compression
- Try different quality levels: Start at 85 and decrease until you find the lowest acceptable quality.
- Check the result: Open the compressed image and zoom in to check for artifacts (especially around text and sharp edges).
- Use the right format: If the tool offers format conversion, try WEBP — it often produces smaller files than JPG at equivalent quality.
Method 2: Compress Images with Desktop Software
Using Image Editing Software
Most image editors offer compression options during export:
- Open the image in your editor (Photoshop, GIMP, Paint.NET, etc.).
- Go to File > Export or File > Save As.
- Choose the format (JPG, PNG, WEBP).
- Set the quality/compression level in the export dialog.
- Click Save.
Using ImageOptim (macOS)
ImageOptim is a free macOS tool that optimizes images by removing unnecessary metadata and applying optimal compression:
- Drag and drop images into the ImageOptim window.
- ImageOptim automatically compresses them using the best method for each format.
- The compressed images replace the originals (or are saved to a location you choose).
ImageOptim is excellent for batch compression and produces very small files without visible quality loss.
Using FileOptimizer (Windows)
FileOptimizer is a free Windows tool similar to ImageOptim:
- Drag and drop images into the FileOptimizer window.
- The tool applies lossless optimization to reduce file size.
- The optimized images are saved in place.
Method 3: Compress Images with Command-Line Tools
For batch processing and automation, command-line tools are powerful.
Using ImageMagick
ImageMagick can compress images with precise control. For JPG, you specify the quality level (1–100). For PNG, you specify the compression level (0–9). ImageMagick also supports conversion to more efficient formats like WEBP. Batch processing is straightforward — you can compress an entire folder of images with a single command.
Using jpegoptim
jpegoptim is a specialized tool for optimizing JPEG files. It applies lossless optimization (removing metadata, optimizing Huffman tables) and optional lossy compression (reducing quality). It is ideal for batch-optimizing JPEGs for web use.
Using optipng
optipng is a specialized tool for optimizing PNG files. It applies lossless optimization to reduce file size without any quality loss. It tries different compression strategies and keeps the best result. It is ideal for batch-optimizing PNGs.
Using cwebp
cwebp is Google's tool for converting images to WEBP format. It supports both lossy and lossless compression and often produces smaller files than both JPG and PNG. It is ideal for web image optimization.
Compression Strategies for Different Use Cases
Web Images
For web images, the goal is the smallest file size at acceptable quality:
- Choose the right format: WEBP for modern browsers (best compression), JPG for photos (universal compatibility), PNG for graphics with transparency.
- Set quality to 80–85: This is the sweet spot for most web images. Below 80, artifacts become visible. Above 85, file size increases with little perceptible quality improvement.
- Resize to display dimensions: Do not serve a 4000px image in a 400px space. Resize to the display size before compressing.
- Remove metadata: Strip EXIF data, ICC profiles, and other metadata that adds file size without visual benefit (unless metadata is needed).
- Use responsive images: Serve different image sizes for different screen sizes using the srcset attribute in HTML.
Email Attachments
For email, the goal is to stay under the attachment size limit:
- Resize to reasonable dimensions: 1024 × 768 pixels is usually sufficient for email.
- Compress to quality 80: This produces a small enough file for most email limits.
- Use JPG format: JPG produces the smallest files for photos.
Archival
For archival, the goal is to preserve quality:
- Use lossless compression: PNG, TIFF, or WEBP (lossless mode).
- Keep the original resolution: Do not resize.
- Keep metadata: EXIF data, ICC profiles, and other metadata may be valuable in the future.
Common Compression Problems
Problem: Compressed Image Has Visible Artifacts
Artifacts (blocky areas, color banding, ringing around edges) appear when quality is too low. Increase the quality setting or use a less aggressive compression level. For images with text or sharp edges, use PNG instead of JPG.
Problem: File Size Does Not Decrease
If the image is already well-compressed, further compression has little effect. Try converting to a more efficient format (e.g., PNG to WEBP). Also, check if the file has large metadata that can be stripped.
Problem: Text Becomes Blurry
JPG compression blurs text because it is designed for photographs, not graphics. For images with text, use PNG (lossless) or WEBP. If you must use JPG, increase the quality to 90+.
Problem: Transparent Areas Become Solid
JPG does not support transparency. If you compress a PNG with transparency as JPG, the transparent areas will be filled with a solid color (usually white). If you need transparency, use PNG or WEBP.
Best Practices for Image Compression
- Compress from the original: Always compress from the highest-quality original, not from a previously compressed version. Repeated compression causes generation loss.
- Test different settings: Try different quality levels and formats to find the best balance for each image.
- Use the right format: JPG for photos, PNG for graphics with transparency, WEBP for web optimization.
- Strip unnecessary metadata: EXIF data, thumbnails, and ICC profiles add file size. Remove them unless they are needed.
- Resize before compressing: Resizing to the display dimensions before compressing produces smaller files than compressing at full resolution.
- Automate when possible: For websites and batch workflows, use command-line tools or build scripts to automate compression.
- Keep the original: Always keep an uncompressed (or losslessly compressed) original for future use.
Conclusion
Image compression is a critical skill for anyone who works with digital images. For most users, an online compressor is the fastest option. Desktop tools like ImageOptim and FileOptimizer provide excellent batch optimization. Command-line tools like ImageMagick, jpegoptim, and cwebp enable automation and precise control. The key is understanding the difference between lossy and lossless compression, choosing the right format and quality for your use case, and always compressing from the original. With this tutorial, you can confidently compress any image for web, email, or storage.
Sources & References
About the Author

Michael Foster
Content Creator & Tutorial Expert
Michael creates in-depth tutorials and guides that make complex tools accessible to everyone. He has a passion for teaching and clear communication.
Frequently Asked Questions
What is the difference between lossy and lossless compression?
What quality level should I use for web images?
Can I compress images without losing quality?
Which image format produces the smallest files?
How do I compress multiple images at once?
Start working smarter today
Join 500,000+ users who trust VisualDocs for their daily image and PDF workflows.
