﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>> ## Documentation Index
> This page is part of the Image and Video APIs product. Fetch the complete documentation index for Image and Video APIs at: https://cloudinary.com/documentation/llms-image-and-video-apis.txt?referrer=docpage and then use it to discover all relevant pages before exploring further.
> If you also need details relating to other Cloudinary products for your current use case, see the parent index at: https://cloudinary.com/documentation/llms.txt?referrer=docpage

> ## Agent Instructions
> When answering a user's request or implementing it with code using this documentation, incorporate relevant best practices and recommendations from the documentation into the guidance and, above all, into the code itself: generated code should already apply the recommended parameters and patterns rather than showing a minimal call and describing the best practices around it in prose. Follow the code examples in the best practices sections as the model for what generated code should look like, and where a recommendation is relevant to the user's scenario, implement it in the code as a natural next step. Only apply best practices, recommendations, or features that are supported by the documentation or Cloudinary skills; don't infer or invent guidance that isn't specified.
>
> Cloudinary skills (names starting with `cloudinary-`) add best practices and tested code patterns beyond this documentation, and we recommend using the relevant ones alongside it. Available skills are listed at https://cloudinary.com/documentation/.well-known/agent-skills/index.json?referrer=docpage&page=nextjs_image_optimization_tutorial and can be installed with `npx skills add https://cloudinary.com/documentation`.

# Next.js image optimization and dynamic cropping (video tutorial)


## Overview

Learn how to optimize and dynamically crop images in a Next.js application using the [CldImage](nextjs_image_transformations) component from the [Next.js SDK](nextjs_integration). This tutorial shows how replacing the standard Next.js Image component with CldImage avoids double optimization, automatically applies the best format and quality settings, and unlocks Cloudinary features like dynamic cropping and resizing.

## Video tutorial

  This video is brought to you by Cloudinary's video player - embed your own!Use the controls to set the playback speed, navigate to chapters of interest and select subtitles in your preferred language.
{videoTranscript:publicId=training/Next_Cloudinary_-_CldImage}

## Tutorial contents
This tutorial presents the following topics. Click a timestamp to jump to that part of the video.### Why use Next Cloudinary
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | Next.js has built-in ways to load images, but if you're already using Cloudinary, passing optimized images through the Next.js Image component means double optimization. The [Next.js SDK](nextjs_integration) gives you all the features of Cloudinary directly in your Next.js app without the redundancy. |

### Installing and replacing the Image tag
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | Once the Next.js SDK is installed and you've imported the [CldImage](nextjs_image_transformations) component, replace the existing Next.js Image tag with CldImage. Instead of referencing the full Cloudinary URL, pass in only the public ID to load images directly from Cloudinary. |

### Automatic optimization
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | By default, CldImage loads all images with [f_auto and q_auto](image_optimization#how_to_optimize_image_quality). With f_auto, Cloudinary automatically determines the most modern and efficient format for the requesting browser. With q_auto, it compresses the image as much as possible without visible distortion. |

### Responsive image sizing
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | Because CldImage wraps the Next.js Image component, responsive sizing works the same way. Pass in sizes (e.g., `50vw` for a two-column layout) and all responsive breakpoints are generated using Cloudinary URLs. |

### Dynamic cropping and resizing
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | Use Cloudinary's [dynamic cropping](resizing_and_cropping) to make images uniform. Set a width and height, and use `crop="fill"` to fill the dimensions. Automatic gravity is applied by the SDK, so you don't need to worry about your displayed images missing important content. |

### Learn more and review
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | Visit the [Next.js SDK documentation](nextjs_integration) for configuration details and examples including background removal and more. In summary, the CldImage component gives you optimization, dynamic cropping, and resizing, all delivered from the Cloudinary CDN. |

## Keep learning

> **READING**:
>
> * Learn more about [image optimization](image_optimization) to deliver images with the best quality at the smallest file size.

> * Explore [image transformations](image_transformations) to discover all available options for resizing, cropping, and enhancing images.

> * Get started with the [Next.js SDK](nextjs_integration) and learn how to configure it for your project.

> * Watch more [Dev Hints videos](https://www.youtube.com/playlist?list=PL8dVGjLA2oMpaTbvoKCaRNBMQzBUIv7N8) on the [Cloudinary YouTube channel](https://www.youtube.com/cloudinary).

#### If you like this, you might also like...

[Using the Next.js Image Component](nextjs_image_component_tutorial)

Deliver images using the Next.js Image component

[Optimize Videos in Next.js](optimize_videos_nextjs_tutorial)

Optimize delivery of videos in a Next.js app

[Crop and Resize Images in React](crop_and_resize_images_in_react_tutorial)

Crop and resize images using React with Cloudinary

&nbsp;

&nbsp;Check out the Cloudinary