Transform your images easily in Vue & Nuxt with Cloudinary
Tags: vue, nuxt, javascript, typescript
Published: 2024-01-15 10:24:26

I always thought that you can only transform and modify images by using some kind of advanced design tool like Photoshop and in order to do so, you basically have to be a designer. And in many cases, I wanted to utilize even a simple remove background functionality which was not possible for me.

But then, I found out that Cloudinary offers many useful transformations for your images that make them 10 times better with a simple property or boolean value.

![Nuxt Cloudinary images](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oxp61vkhx4lwsexb772n.png)

In this article, I wanted to show you some of the cool examples of image transformations in Vue & Nuxt apps with Cloudinary 🚀

Enjoy!

## 🤔 Using Cloudinary in Nuxt

There are two ways of using Cloudinary in Nuxt apps:

1. Using [Nuxt Image module](https://image.nuxt.com/)
2. Using [Nuxt Cloudinary module](https://cloudinary.nuxtjs.org/)

Why two? Because they are meant to be used for different cases. The first approach allows you to use Cloudinary as your image provider and in general it works really well but the main aim of it is to serve as a way to delivering performant and optimized images. For this use case, the image module works great, however it does not deliver that many useful transformations options due to limited (agnostic) API.

Nuxt Cloudinary on the other hand, allows you to utilize many interesting image transformations like:

* Removing background
* Underlays and Overlays
* Generative AI (fill background, replace, recolor, remove)
* Filters and Effects

In general, if you want to use Cloudinary just for optimized images, the Nuxt Image module will probably be the best solution. However if you would like to have some advanced and cool looking transformations, I would highly recommend to use the Nuxt Cloudinary module 💚

## 🏞️ Image Transformations

As I mentioned previously, Cloudinary allows you to utilize powerful transformations API to do almost anything with your images. Below, I wanted to list some of the best image transformations that I have managed to do right now with some code examples.

### Multiple Effects

Apply multiple visual effects to one image

![Nuxt Cloudinary Multiple Effects](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wxttt1ybw3v1o0wnuvc.png)

```html
  <CldImage
    src="images/turtle"
    width="900"
    height="900"
    alt="Sample Product"
    crop="fill"
    :effects="[
      {
        background: 'green',
      },
      {
        gradientFade: true,
      },
      {
        gradientFade: 'symetric,x_0.5',
      },
    ]"
  />
```

### Generative AI Recolor

Change color of an element on the image (shoelaces were originally white)

![Nuxt Cloudinary Generative AI Recolor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83gsqtij8oq0c3opx7ls.png)

```html
  <CldImage
    src="images/sneakers"
    width="900"
    height="900"
    alt="Sample Product"
    crop="fill"
    :recolor="['shoelaces', 'purple']"
  />
```

### Generative AI Fill Background

Extend the image with AI generated background (first image is an originall image, the second one is transformed with Generatite AI)

![Nuxt Cloudinary Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdbh2uo1xthf44alqbfu.png)

![Nuxt Cloudinary Generative AI Fill Background](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jeod185spgyx5q2vffni.png)

```html
  <CldImage
    src="images/sneakers"
    width="1200"
    height="1200"
    alt="Sample Product"
    crop="fill"
    fillBackground
  />
```

And many many more! Check out the [documentation](https://cloudinary.nuxtjs.org/) for more examples! 🚀

## 📖 Learn more 

If you would like to learn more about Vue, Nuxt, JavaScript or other useful technologies, checkout VueSchool by clicking this [link](https://vueschool.io/courses?friend=baroshem) or by clicking the image below:

[![Vue School Link](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mm7hxr3zzxyoiigm5hwq.png)](https://vueschool.io/courses?friend=baroshem)

It covers most important concepts while building modern Vue or Nuxt applications that can help you in your daily work or side projects 😉

## ✅ Summary

Well done! You have just learned how to use Cloudinary to deliver amazingly transformed images in your Vue & Nuxt apps.

Take care and see you next time!

And happy coding as always 🖥️