Last updated: Apr-08-2023
js-url-genfrontend library. For the backend Node.js library, which also covers upload and admin functionality, see the Node.js documentation.
This example shows a transformation URL being created using the
@cloudinary/url-gen package. It demonstrates the use of tree shaking to reduce the bundle size, which explains why there are so many
This code generates the URL required to deliver the front_face.jpg image with the following transformations applied:
- Crop to a 150x150 thumbnail using face-detection gravity to automatically determine the location for the crop
- Round the corners with a 20 pixel radius
- Apply a sepia effect
- Overlay the Cloudinary logo on the southeast corner of the image (with a slight offset). The logo is scaled down to a 50 pixel width, with increased brightness and partial transparency (opacity = 60%)
- Rotate the resulting image (including the overlay) by 10 degrees
- Convert and deliver the image in PNG format (the originally uploaded image was a JPG)
And here's the URL that's generated from the above code:
- See all possible transformations in the Transformation URL API reference.
- See more examples of image and video transformations using the
If you're using a frontend framework, jump straight to the relevant Get started docs:
@cloudinary/url-gen package using the NPM package manager:
You can specify the configuration parameters that are used to create the delivery URLs, either using a Cloudinary instance or per image/video instance.
camelCase, for example cloudName.
Cloudinary instance configuration
If you want to use the same configuration to deliver all your media assets, it's best to set up the configuration through a Cloudinary instance, for example:
You can set other configuration parameters related to your cloud and URL as required, for example, if you have your own custom domain name, and want to generate a secure URL (HTTPS):
Asset instance configuration
If you need to specify different configurations to deliver your media assets, you can specify the configuration per image/video instance, for example:
Some build environments require additional configuration:
Rollup + Vanilla JS: install and use
Next.js + Vanilla JS: install and use
moxystudio/next-compile-node-modules(or some other similar solution).
TypeScript + Webpack: set
"moduleResolution": "node"in the TSConfig file.
@cloudinary/url-gen package installs an additional transformation-builder-sdk library as a dependency, which handles the transformation generation part of the URL.
You can use the Transformation Builder reference to find all available transformations, syntax and examples.
To find out more about transforming your assets using the
@cloudinary/url-gen package, see:
@cloudinary/html package from frontend-frameworks provides plugins to render the media on your site in the most optimal way and improve your user's experience by automating media tasks like lazy loading, responsive images and more.
Try out the examples in these code explorers: