CldImage Examples
Basic Transformations
Cloudinary supports a wide variety of powerful transformations that allow you to not only deliver, but easily edit and build new images on the fly.
Background Removal
Remove Background
removeBackground
: Removes the background of the image using AI
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
removeBackground
alt=""
/>
The Cloudinary AI Background Removal add-on is required to use this feature.
Color Background
background
: Specifies a color to use as a background.
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
removeBackground
background="blueviolet"
alt=""
/>
Image Background
underlay
: Specifies a public ID to use as an underlaying image.
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
removeBackground
underlay="<Your Public ID>"
alt=""
/>
Cropping & Resizing
Cropping
crop
: Specifies the mode to use when cropping an image based on the given dimensions.
Note: By default, CldImage uses a gravity of auto, meaning the crop will automatically position the subject in the center of the resulting image.
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="300"
height="300"
crop="fill"
alt=""
sizes="100vw"
/>
Cloudinary additionally supports dynamic crop modes like thumb
that
may provide a different result based on the given width and height. To
help provide more options for controlling cropping images, you can specify
and object or array of objects.
For instance, to crop the original source image, which will then later resize it to the initial width and height, you can use:
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="300"
height="300"
crop={{
type: 'thumb',
width: 600,
height: 600,
source: true
}}
alt=""
sizes="100vw"
/>
Which will provide a consistent crop for all rendered sizes.
You can also use coordinates to crop to the exact location you need:
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="300"
height="300"
crop={{
type: 'crop',
width: 400,
height: 400,
x: 80,
y: 350,
gravity: 'north_east',
source: true
}}
alt=""
sizes="100vw"
/>
Learn more about cropping and responsive images.
Fill Parent
fill
: a Next Image feature (opens in a new tab) that
renders an image that fills its parent, not requiring you to pass in a width or height.
You can optionally use this in conjunction with other transformations, such as Aspect Ratio, to automatically crop to a specific ratio without specifying the width and height.
Note: Aspect Ratio requires you to use a crop mode that actually crops the image such as "fill" (not to be confused with Next Image's Fill)
import { CldImage } from 'next-cloudinary';
<div style={{ position: 'relative', aspectRatio: '16 / 9' }}>
<CldImage
src="<Your Public ID>"
sizes="100vw"
aspectRatio="16:9"
crop="fill"
fill={true}
alt=""
/>
</div>
Extract
extract
: Extracts an area or multiple areas of an image, described in natural language.
Prompt: toys; Multiple: true
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="960"
height="600"
extract="<Prompt>"
alt=""
sizes="100vw"
/>
The extract transformation is currently in Beta. Learn more.
Generative Fill
fillBackground
: Fills the background of an image using Generative AI
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="960"
height="600" // Original 1440
crop="pad" // Returns the given size with padding
fillBackground
alt=""
sizes="100vw"
/>
The generative fill transformation is currently in Beta. Learn more.
Generative Recolor
recolor
: Recolors an object in an image using Generative AI
Recolor: shoelaces; Color: purple
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="960"
height="600"
crop="fill"
recolor={['shoelaces', 'purple']}
alt=""
sizes="100vw"
/>
The generative recolor transformation is currently in Beta. Learn more.
Generative Remove
remove
: Removes an object in an image using Generative AI
Prompt: mountain
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="960"
height="600"
remove="<Prompt>"
alt=""
sizes="100vw"
/>
The generative remove transformation is currently in Beta. Learn more.
Generative Replace
replace
: Replaces an object in an image using Generative AI
Replace: turtle; With: Shark
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
crop="fill"
src="<Your Public ID>"
replace={['turtle', 'shark']}
alt=""
sizes="100vw"
/>
The generative replace transformation is currently in Beta. Learn more.
Generative Replace Background
replaceBackground
: Replaces the background of an image with an AI-generated background.
Prompt: big fish tank
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="960"
height="600"
replaceBackground="<Prompt>"
alt=""
sizes="100vw"
/>
The generative replace background transformation is currently in Beta. Learn more.
Generative Restore
restore
: Restores an image using Generative AI
import { CldImage } from 'next-cloudinary';
<CldImage
src="<Your Public ID>"
width="960"
height="600"
crop="fill"
restore
sizes="100vw"
alt=""
/>
The generative restore transformation is currently in Beta. Learn more.
Filters & Effects
Included in the Cloudinary transformations library are different filters and effects that allow you to recolor, improve, fix, and artistically transform your images.
Blur
blur
: Applies a blurring filter to an asset.
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
blur="1200"
alt=""
/>
Grayscale
grayscale
: Converts an image to grayscale (multiple shades of gray).
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
grayscale
alt=""
/>
Opacity
opacity
: Controls the opacity level of an image.
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
opacity="50"
alt=""
/>
Pixelate
pixelate
: Applies a pixelation effect.
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
pixelate
alt=""
/>
Tint
tint
: Blends an image with one or more tint colors.
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
tint="equalize:80:blue:blueviolet"
alt=""
/>
Chaining Multiple Effects
effects
: An array of objects the configure the effects to apply to an image.
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
effects={[
{
background: 'green'
},
{
gradientFade: true
},
{
gradientFade: 'symetric,x_0.5'
}
]}
alt=""
/>
More Filters & Effects
Learn about what other filters and effects are supported on CldImage Configuration.
Image Overlays
Image overlays allow you to place one or multiple images on top of another image.
Overlay Image by Public ID
overlays
: Any array of overlay objects
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
overlays={[{
publicId: '<Your Public ID>',
position: {
x: 50,
y: 50,
gravity: 'north_west',
},
effects: [
{
crop: 'fill',
gravity: 'auto',
width: 500,
height: 500
}
]
}]}
alt=""
/>
Overlay Image with Blend Mode
appliedEffects
: When configured on an overlay object, allows you to set an effect
that applies a blend mode, such as "multiply"
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
crop="fill"
src="<Your Public ID>"
overlays={[{
publicId: '<Your Public ID>',
effects: [
{
crop: 'fill',
gravity: 'auto',
width: '1.0',
height: '1.0',
}
],
flags: ['relative'],
appliedEffects: [
{
multiply: true
}
]
}]}
alt=""
/>
Image Underlays
Image underlays allow you to place one or multiple images behind a base image.
Replace Background with Image
underlay
: Public ID of image to use under base image
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
removeBackground
underlay="<Your Public ID>"
alt=""
/>
Replace Background with Multiple Images
underlays
: Array of underlay objects
import { CldImage } from 'next-cloudinary';
<CldImage
width="960"
height="600"
src="<Your Public ID>"
sizes="100vw"
removeBackground
underlays={[
{
publicId: 'images/galaxy',
width: '0.5',
height: '1.0',
crop: 'fill',
position: {
gravity: 'north_west'
},
flags: ['relative']
},
{
publicId: 'images/mountain',
width: '0.5',
height: '1.0',
crop: 'fill',
position: {
gravity: 'south_east'
},
flags: ['relative']
},
]}
alt=""
/>
Text Overlays
Text overlays allow you to place text on top of an image.
Adding Custom Text
overlays
: Uses overlay objects to add text on top of an image.
import { CldImage } from 'next-cloudinary';
<CldImage
width="1335"
height="891"
src="<Your Public ID>"
sizes="100vw"
overlays={[{
position: {
x: 140,
y: 140,
angle: -20,
gravity: 'south_east',
},
text: {
color: 'blueviolet',
fontFamily: 'Source Sans Pro',
fontSize: 280,
fontWeight: 'bold',
textDecoration: 'underline',
letterSpacing: 14,
text: 'Cool Beans'
}
}]}
alt=""
/>
Adding Text with Effects
effects
: Applies effects to the overlaid text.
import { CldImage } from 'next-cloudinary';
<CldImage
width="1335"
height="891"
src="<Your Public ID>"
sizes="100vw"
overlays={[{
text: {
color: 'white',
fontFamily: 'Source Sans Pro',
fontSize: 500,
fontWeight: 'bold',
text: 'Into the Galaxy'
},
effects: [
{
shear: '40:0',
opacity: 50
}
]
}]}
alt=""
/>
Misc
Video Thumbnail
assetType
: Specifies the type of asset to be delivered.
This is handy when wanting to create an image thumbnail from a video, where the asset type would be "video", yet delivering an image.
import { CldImage } from 'next-cloudinary';
<CldImage
assetType="video"
width="1920"
height="1080"
src="<Your Video Public ID>"
sizes="100vw"
alt=""
/>
More Examples
Find more examples on Social Card Templates.