Picture Resize for Web — Optimal Dimensions & Compression Settings
Key recommendations
- Format: Use WebP (best balance of size and quality). Fallback to JPEG for wide compatibility; PNG/SVG for logos/icons needing transparency or scalability.
- Max dimensions: For most images, generate up to 1920–2560 px wide for full-width/hero images; 1280 px for large content images; 640–768 px for mobile; thumbnails 150–400 px (use 300 px as a common thumbnail).
- File-size targets: Aim < 250 KB per image where possible; acceptable up to 500 KB for hero/background images only.
- Compression/quality: For WebP/JPEG, start at quality 70–80 (q=70–80) — lowers size with minimal visible loss. Use lossless only when needed (icons/transparent assets).
- Responsive images: Provide multiple widths with srcset (e.g., 480, 768, 1024, 1920, 2560) and use sizes attribute so browsers choose the right file.
- Max pixel rule: Limit the longest side to ~2000–2560 px unless you need ultra-high-res; avoid generating 4K/8K unless required.
- Aspect ratios & cropping: Export images in the same aspect ratio as their container to prevent runtime scaling/cropping and layout shift.
- Retina/HiDPI: Serve 2x assets only when necessary (use srcset x descriptors or higher-width variants) rather than always uploading double-size originals.
- Transparency & vectors: Use PNG-24 or SVG for graphics with transparency; convert to WebP lossless if file-size improves.
- Metadata & color: Strip EXIF/metadata and save in sRGB for consistent web rendering.
- Automation & batch tools: Use build-time tools (imagemin, sharp, svgo), CMS plugins, or CDNs (Cloudflare Images, Imgix, ImageKit) to auto-resize, convert formats, and deliver optimized variants.
Example srcset (practical)
Code
srcset=” image-480.webp 480w, image-768.webp 768w, image-1024.webp 1024w, image-1920.webp 1920w “ sizes=”(max-width: 600px) 100vw, (max-width:1200px) 50vw, 900px”
Quick rules-of-thumb
- Photos → WebP/JPEG @ q70–80, max 1920–2560 px, <250 KB ideal.
- Logos/icons → SVG or PNG (or WebP lossless), keep vector where possible.
- Thumbnails → 150–400 px, aggressively compressed.
- Always serve responsive variants and let the browser pick.
If you want, I can generate exact export dimensions and a srcset list for a specific layout (hero + article image + thumbnail) — I’ll assume common breakpoints unless you provide widths.
Leave a Reply