<Image/> causing image degradation
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Node: 16.13.2
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.2.3-canary.12
eslint-config-next: 11.1.2
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome 103.0.5060.114
How are you deploying your application? (if relevant)
No response
Describe the Bug
Using the <Image/> tag and adding a specific width & height to an image that is much larger than that and adding the CSS property object-fit: cover;
causes the image’s resolution to degrade by a lot.
When we switch to the normal HTML tag with the same image, width, and CSS, the image is displayed fine in full resolution.
Expected Behavior
The image quality should not degrade like this and it should keep full resolution
Link to reproduction
https://codesandbox.io/s/romantic-vaughan-j332co?file=/pages/index.tsx
To Reproduce
Use <Image/>
to display an image, style it with object-fit: cover
(I used tailwindcss to achieve this here) and put a width and height that’s smaller than the original image
<Image
src={"/image.png"}
className="object-cover"
width={300}
height={550}
/>
Check link for comparison with <img/>
with the same styling
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Degraded Image - an overview | ScienceDirect Topics
The input to the processing system is a degraded image (or set of images or video signal) such as blurred image, noisy image,...
Read more >What are image degradation and restoration models?
Image degradation is the loss of image quality for a variety of reasons. When there is image deterioration, the quality of the image...
Read more >Image Restoration - Degradation Model
The purpose of image restoration is to "compensate for" or "undo" defects which degrade an image. Degradation comes in many forms such as...
Read more >A Basic Introduction to Preventing Jpg Image Degradation
This issue of JPG image degradation is true for small images with low resolution for the Web - and equally true as well...
Read more >Sources of Image Degradation in Fundamental and Harmonic ...
First, the sources of image degradation in the fundamental images are primarily due to phase aberration and reverberation in near-field abdominal structures.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think you are changing the aspect ratio of the image with your width & height?
use layout fill with objectFit cover
Docs: https://nextjs.org/docs/api-reference/next/image#objectfit Demo: https://image-component.nextjs.gallery/layout-fill
https://codesandbox.io/s/proud-sea-3oo17s
Just tried
quality={100}
, and the extremely bad quality is still the same, so that’s not the issue sadly.