demobook

Next.js: Adjust Image Quality on the fly

Demo summary

The video demonstrates using the quality prop to dynamically change image compression levels, showing the visual difference between 90% and 5% quality.

Step-by-step

  1. Add the quality prop to the Next.js Image component
  2. Set the value to a number between 1 and 100 (e.g., 90 for high quality or 5 for high compression)
  3. Perform a hard refresh in the browser to see the changes
  4. Inspect the image URL to verify the 'Q-' parameter matches your specified value

Options

  • Manually adjust the quality by editing the 'Q-' parameter directly in the ImageKit URL

Watch out for

  • The default image optimization quality is 80 if the quality prop is not configured

Tips

  • Use a quality of 75 as a good alternative default for a balance of performance and visual fidelity
  • Don't always use full quality images; lower quality (even 5%) can be sufficient depending on the use case

Highlights

the quality prop is quite powerful because you can adjust it on the fly dynamically

All demos from “Ultimate Guide to Image Optimization in Next.js (CLS, Placeholders, Transformations, ImageKit)

  1. 30:062:27Adjust Image Quality on the flyCurrentThe video demonstrates using the quality prop to dynamically change image compression levels, showing the visual difference between 90% and 5% quality.Next.jsAI Image/Photo Enhancer
  2. 43:491:32Chained Image Transformations with ImageKitThe creator demonstrates chaining multiple transformations including width, height, focus, crop, rotation, blur, and grayscale using the transformation prop.ImageKitAI Photo Editor
  3. 47:351:49Overlay Text on ImagesThe demo shows how to use ImageKit's overlay property to programmatically add a 'Subscribe' text badge with custom background and padding to an image.ImageKitAI Photo Editor
  4. 50:490:48AI-Powered Object-Aware CroppingThe video demonstrates using ImageKit's AI focus (fo-cat, fo-dog) to automatically crop images around specific subjects without manual coordinates.ImageKitAI Crop Image
  5. Watch “Ultimate Guide to Image Optimization in Next.js (CLS, Placeholders, Transformations, ImageKit)” →

AI Image/Photo Enhancer

  1. 30:062:27Adjust Image Quality on the flyCurrentThe video demonstrates using the quality prop to dynamically change image compression levels, showing the visual difference between 90% and 5% quality.Jan Marshal