Skip to main content
Technical guide

How to optimize images for web and SEO

Images account for over half of most web pages' total weight. Optimizing them correctly improves page speed, search rankings, and user experience - without sacrificing visual quality or the protection of your work.

Reading time: 9 min Updated on 17 February 2026
1

Choosing the right image format

The format you choose has the single biggest impact on file size and quality. Modern formats deliver dramatically smaller files at the same visual quality compared to older standards. Here is what to use and when.

Format comparison:

  • WebP - the best all-round format for the web. 25-35% smaller than JPEG at equivalent quality, supports transparency, and is now supported by all major browsers. Use this as your default
  • AVIF - the newest option, offering 40-50% savings over JPEG. Excellent quality at very low file sizes, but encoding is slower and browser support is still catching up (no Safari on older iOS)
  • JPEG - still the universal fallback. Use quality 75-85 for a good balance between file size and visual quality. Best for photographs with no transparency needs
  • PNG - use only when you need transparency or pixel-perfect graphics (logos, screenshots, icons). Significantly larger than JPEG or WebP for photographs

The ideal approach is to serve multiple formats using the HTML <picture> element. Offer AVIF first, WebP as fallback, and JPEG as the final fallback. The browser will automatically pick the best format it supports.

2

Compression without visible quality loss

Compression reduces file size by removing data the human eye cannot easily perceive. The key is finding the sweet spot where file size drops significantly but quality remains visually identical to the original.

There are two types of compression. Lossy compression (JPEG, WebP, AVIF) permanently removes data to achieve smaller files - this is what you want for photographs on the web. Lossless compression (PNG, WebP lossless) preserves every pixel but achieves smaller reductions - better for graphics and screenshots.

Compression best practices:

  • Quality 75-85 for JPEG - below 70 you start seeing visible artifacts around edges and in gradients. Above 85 the file size increases rapidly with minimal visual improvement
  • Quality 75-80 for WebP - WebP's encoder is more efficient, so you can use slightly lower quality values than JPEG for the same visual result
  • Strip unnecessary metadata - EXIF data, colour profiles, and thumbnails can add 50-200 KB to each file. Strip them for web versions (but always keep them in your originals)

Tools like Squoosh, ImageOptim, or Sharp (Node.js) let you preview the quality difference before committing. Always compare the compressed version against the original at full size before deploying.

3

Writing alt text that ranks

Alt text (the alt attribute on <img> tags) serves two purposes: it describes the image for screen readers and visually impaired users, and it tells search engines what the image contains. Google uses alt text as a primary signal for image search rankings.

Good alt text is descriptive, concise, and naturally includes relevant keywords without stuffing. Instead of "photo.jpg" or "image1", write something like "golden retriever running through autumn leaves in a park". Describe what is in the image, not what it is (avoid starting with "image of" or "picture of").

Alt text guidelines:

  • Be specific - "red 2024 Porsche 911 on a mountain road" is better than "sports car"
  • Keep it under 125 characters - screen readers may truncate longer descriptions, and search engines give less weight to overly long alt text
  • Include your target keyword naturally - if the page is about landscape photography, mention it in the alt text where it genuinely describes the image

For decorative images that do not add informational value (borders, spacers, background patterns), use an empty alt attribute (alt="") so screen readers skip them entirely.

4

Lazy loading and responsive images

Lazy loading delays the loading of images until they are about to enter the viewport. This means a page with 50 images does not download all 50 on initial load - only the ones visible on screen. The rest load as the user scrolls. This dramatically reduces initial page load time and bandwidth usage.

In modern HTML, lazy loading is as simple as adding loading="lazy" to your <img> tags. Do not lazy-load images that are visible above the fold (the first screen) - these should load immediately to avoid layout shifts and poor Largest Contentful Paint (LCP) scores.

Responsive images adapt to different screen sizes so mobile users do not download a 4000px wide image when their screen is only 400px. Use the srcset and sizes attributes to provide multiple resolutions. The browser picks the smallest version that fits the user's screen, saving bandwidth and improving load time.

Always specify width and height attributes on every image to prevent Cumulative Layout Shift (CLS) - a Core Web Vitals metric that penalises pages where content jumps around during loading.

5

File naming conventions and structured data

Image file names are another SEO signal that many people overlook. Search engines read file names to understand image content. A file named sunset-over-lake-geneva.webp tells Google far more than IMG_4829.webp.

File naming rules:

  • Use hyphens, not underscores - Google treats hyphens as word separators but underscores as word joiners. "red-rose" = two words, "red_rose" = one word
  • Be descriptive but concise - 3 to 5 words is ideal. Avoid generic names like "photo1" or "final-version"
  • Use lowercase only - some servers treat URLs as case-sensitive, which can cause broken images or duplicate content issues

For advanced SEO, add structured data (schema.org ImageObject) to your pages. This markup tells search engines the image's caption, creator, license, and content URL. Pages with structured data are more likely to appear in Google's image search results with rich snippets.

If you watermark your images before publishing, the watermark itself becomes part of the file. For guidance on watermarking without hurting image quality, see our watermark best practices guide.

6

Balancing quality, protection, and performance

Photographers and creators face a unique challenge: they want images that look stunning on the web, load fast for SEO, and remain protected from theft. These goals can feel contradictory, but they are not - you just need a clear workflow.

Keep your original high-resolution files stored safely offline - these are your masters and your proof of authorship. For the web, export resized versions (typically 1200-2000px on the longest edge) in WebP format at quality 80. This gives you excellent visual quality at a fraction of the original file size.

Before uploading, add a watermark to your web versions. A semi-transparent watermark at 30-40% opacity will not meaningfully affect file size or load speed, but it provides visual protection that deters casual theft. After watermarking, run the image through a compression tool for a final size reduction.

For the full guide on securing your images beyond optimization, see our article on protecting photos from theft online and our watermark tutorial.

Add a watermark to your web images with Markly

Fast, optimized, and protected

Optimize your images for speed and SEO, then watermark them for protection.

Markly

Add text or logo watermarks to your optimized images in seconds - free, no account required.

Try Markly free

Ready to watermark your images?

Free, instant, works right in your browser.

Add a watermark now