AI generative fill in Next.js (video tutorial)
Last updated: Dec-06-2024
On this page:
Overview
This video tutorial shows you how to extend your images to different aspect ratios, automatically filling in the extra space using generative AI.
Video tutorial
View the code
You can find the code from this tutorial in GitHub.Tutorial contents
This tutorial presents the following topics. Click a timestamp to jump to that part of the video.
Introduction
See how easy it is to extend images with generative fill using the Cloudinary Next.js library. | |
Display an image
Start off in the pages folder of your Next.js app, importing CldImage from next-cloudinary , and displaying an image from Cloudinary: |
|
Use generative fill on the image
To use generative fill on the image, add the fillBackground prop to the CldImage component and change the aspect ratio of the image, for example by swapping the width and height. |
|
Create a banner with a text overlay
To create a banner, leaving room for a text overlay on the right, you can extend an image to the right, keeping the original focal point on the left. To do this, add a custom object to the fillBackground property, setting gravity to west : |
|
Reuse the template for any image
You can use the same template on any image, giving you the ability to extend images automatically, and at scale. | |
Keep learning
Related topics
- See more of Cloudinary's AI capabilities in action.
- Learn more about image and video transformations.
- Check out the Transformation reference for a listing of all Cloudinary transformations, including syntax details and examples.
- Watch more Dev Hints videos on the Cloudinary YouTube channel.
If you like this, you might also like...
Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.
✖️