How to Fix Lighthouse “Displays images with incorrect aspect ratio”
Lighthouse's "Displays images with incorrect aspect ratio" audit goes away when you set the width and height of the <img> to the image's actual size and add height: auto in CSS. If you need to fit an image into a fixed-shape frame, such as a thumbnail, crop it with object-fit: cover in CSS. This warning appears when photos are stretched vertically or horizontally, for example in blog post cards or product lists. In Japanese Lighthouse output, the same audit has a Japanese title that means "Displays images with incorrect aspect ratio."
On the page I tested, a landscape image (640×360) was displayed with width="300" height="300", and this warning appeared. The Best Practices score was 96. After I fixed the attributes and CSS, the warning went away and the score became 100.
The test environment was Ubuntu 24.04, Node.js 22, and Lighthouse 13.6.0 (the npm package). For Chrome, I used Chrome for Testing 153, which is bundled with Playwright 1.63.0, and specified it with the environment variable CHROME_PATH. I ran Lighthouse from the command line with the default mobile settings and checked only the Best Practices category. The test page was served from a server running in the test environment (localhost:8080). I did not test the Lighthouse panel in Chrome DevTools, PageSpeed Insights, desktop settings, images using srcset or <picture>, or results from a live public site.
The page that raised the warning, and Lighthouse's output
The warning appeared on the following page. cat.png is an image that is 640px wide and 360px tall, and the <img> attributes display it as a 300×300 square.
<style>
body { margin: 0 auto; max-width: 640px; padding: 0 16px; font-family: sans-serif; }
img { max-width: 100%; }
</style>
<h1>猫の手日記</h1>
<img src="/cat.png" alt="水色の猫の顔" width="300" height="300">
<p>画像の下に続く本文です。</p>
I checked this page with Lighthouse. I used a small script (summarize.mjs) to extract the Best Practices score and the result of this audit (its name inside Lighthouse is image-aspect-ratio) from the JSON result.
$ npx lighthouse http://localhost:8080/before.html --only-categories=best-practices --output=json --output=html --output-path=./out/before --chrome-flags="--headless=new --no-sandbox" --quiet
$ node summarize.mjs out/before.report.json
lighthouseVersion: 13.6.0 formFactor: mobile locale: en-US
requestedUrl: http://localhost:8080/before.html
best-practices score: 96
image-aspect-ratio: score=0 title="Displays images with incorrect aspect ratio"
<img src="/cat.png" alt="水色の猫の顔" width="300" height="300"> | url=http://localhost:8080/cat.png | displayed=300 x 300 (1.00) | actual=640 x 360 (1.78)
(In practice, I ran this from a small shell script that set CHROME_PATH. I have omitted the other lines of output.)
In the HTML report, the Best Practices section lists the displayed size and aspect ratio (Aspect Ratio (Displayed)) and the actual size and aspect ratio (Aspect Ratio (Actual)). The number in parentheses is width divided by height. The same values appear in audits["image-aspect-ratio"].details.items in the JSON. When I ran it with --locale=ja, the column names were shown in Japanese, meaning "Aspect Ratio (Displayed)" and "Aspect Ratio (Actual)."

This audit has a weight of 1 and is pass/fail. On this page, this one audit failed, and the score dropped from 100 to 96.
Visually, the cat's face is stretched vertically. The official explanation of this audit also says that when the aspect ratio does not match, the image looks distorted.

Set width and height to the image's actual size
First, set the width and height attributes to the image's actual size (640 and 360). On a phone screen the image is shrunk to fit, so also add height: auto in CSS.
<style>
img { max-width: 100%; height: auto; }
</style>
<img src="/cat.png" alt="水色の猫の顔" width="640" height="360">
On this page, the audit changed to "Displays images with correct aspect ratio" and passed. The score became 100.
best-practices score: 100
image-aspect-ratio: score=1 title="Displays images with correct aspect ratio"
I displayed this page with Playwright at a width of 412px. The image was 380×214 (the values read from the width and height of the <img>). The width shrank to 380px, and the height became 214px while the aspect ratio was kept.
If you forget height: auto when the image shrinks on a narrow screen, the warning does not go away even after fixing the attributes. This is because max-width: 100% shrinks only the width to 380px, and the height stays at the 360px from the attribute.
best-practices score: 92
image-aspect-ratio: score=0 title="Displays images with incorrect aspect ratio"
<img src="/cat.png" alt="水色の猫の顔" width="640" height="360"> | url=http://localhost:8080/cat.png | displayed=380 x 360 (1.06) | actual=640 x 360 (1.78)
image-size-responsive: score=0 title="Serves images with low resolution"
On this page, a separate warning about insufficient image resolution (image-size-responsive) also appeared, and the score dropped to 92.
For images whose height is set in CSS, crop with object-fit
Even with correct attributes, the warning still appears if the width and height are both set in CSS. This was the page where I wrote the following to make card images the same height.
img { max-width: 100%; height: auto; }
.card img { width: 100%; height: 200px; }
best-practices score: 96
image-aspect-ratio: score=0 title="Displays images with incorrect aspect ratio"
<img src="/cat.png" alt="水色の猫の顔" width="640" height="360"> | url=http://localhost:8080/cat.png | displayed=380 x 200 (1.90) | actual=640 x 360 (1.78)
The official explanation lists two common causes: the width and height are set to values different from the image's size, or the width and height are set as percentages of a container whose size changes.
If you don't want to change the shape of the frame, add object-fit: cover. As the MDN explanation of object-fit describes, cover fills the frame while keeping the aspect ratio, and crops the parts that overflow. The default value is fill, which stretches the image to fit the frame.
.card img { width: 100%; height: 200px; object-fit: cover; }
best-practices score: 100
image-aspect-ratio: score=1 title="Displays images with correct aspect ratio"
The displayed size stays at 380×200, and the warning went away. The same applies if you want square thumbnails. A page with width: 300px; height: 300px; object-fit: cover and a page with width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover both passed and scored 100.
Reading the source code of this audit in Lighthouse 13.6.0, the audit only checks images whose object-fit is fill. Images with cover or contain are excluded from the check. Also excluded are CSS background images, SVG images, and images whose natural width or height is 5px or less.
According to the MDN explanation, contain also keeps the aspect ratio, but if the frame and the image have different shapes, empty space appears at the top and bottom or on the sides. With cover, the edges of the image are cut off, so for images where cropping is not acceptable, change the aspect ratio of the frame to match the image instead of cropping.
A difference under 2px passes
The same source code passes an image when the difference between the height calculated from the displayed width and the natural aspect ratio, and the height actually displayed, is less than 2px. (For landscape images the comparison uses height, and for portrait images it uses width.) The natural height of a 640×360 image displayed at 300px wide is 168.75px. To check this, I tested a page that shows the same image with height="170" and height="172".
best-practices score: 96
image-aspect-ratio: score=0 title="Displays images with incorrect aspect ratio"
<img src="/cat.png?b" alt="水色の猫の顔 2" width="300" height="172"> | url=http://localhost:8080/cat.png?b | displayed=300 x 172 (1.74) | actual=640 x 360 (1.78)
The height="170" image, which differs by 1.25px, passed and did not appear in the table. Only the height="172" image, which differs by 3.25px, was flagged.





